From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26644 invoked by alias); 18 May 2017 10:29:09 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41125 Received: (qmail 21238 invoked from network); 18 May 2017 10:29:09 -0000 X-Qmail-Scanner-Diagnostics: from aok120.rev.netart.pl by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(85.128.245.120):SA:0(0.0/5.0):. Processed in 1.74561 secs); 18 May 2017 10:29:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: psprint@zdharma.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at zdharma.org does not designate permitted sender hosts) X-Virus-Scanned: by amavisd-new using ClamAV (20) Date: Thu, 18 May 2017 12:29:05 +0200 From: Sebastian Gniazdowski To: Bart Schaefer , zsh-workers@zsh.org Message-ID: In-Reply-To: <170517154337.ZM27772@torch.brasslantern.com> References: <170517154337.ZM27772@torch.brasslantern.com> Subject: Re: Naive question: how hard are namespaces for functions X-Mailer: Airmail (231) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 18 maja 2017 at 00:43:39, Bart Schaefer (schaefer=40brasslantern.com) = wrote: > On May 17, 4:20pm, Sebastian Gniazdowski wrote: > =7D > =7D Maybe namespaces are easy=3F > =20 > This depends entirely on what you mean by =22namespaces=22. > =20 > Voluntarily naming functions with an identifiable prefix string is easy= . > =20 > Calling those functions by a name other than the full name with the > prefix string is probably of middling difficulty, but would require > some sort of collision resolution if the same suffix appeared with two > or more prefixes. I might be too simple on this, but thought that calling would be with ful= l prefix, only display of =24functions (also output of builtin =60functio= ns=60) would be changed. That might be not too much, but it lead me to an= idea: - prefix is always separated with =22:=22 or =22::=22 - when defining, one sets ZSH=5FNSPACE=3D=22name=22 - then he has functions name::load, name::exit, etc. - such definition, confronted with ZSH=5FNSPACE, results in: =C2=A0 - internal change of name of the functions to =5EAname=5EAload, =5E= Aname=5EAexit, =C2=A0 - when any call is made, =22::=22 is detected, and first the =5EA.= .. fields in functions hash table are checked, =C2=A0 - then normal string e.g. =22name::exit=22 is searched - displaying of =24functions skips elements starting with =5EA unless ZSH= =5FNSPACE is set Just free thinking. Double-searching functions tab is an obvious slowdown= , but it would happen only to =22::=22 functions. Legacy software would r= arely suffer because =22::=22 function names are rare (and would suffer n= ot much except when performance-hungry), maintained software would utiliz= e ZSH=5FNSPACE and single search would happen. But what namespace should completion functions have, not breaking too muc= h similarity to current version. > Dividing =24functions (or any hash parameter value) up into named secti= ons > that the shell somehow understands natively, is very difficult. > =20 > I'm not following what this would have to do with how long it takes to > load function definitions. I've did a run on this (in other mail), it was an connected issue =22many= functions feel hard=22 with =22many functions might require optimization= =22, and also the division you mentioned, introducing namespaces might be= through some division, which might open way to optimization. -- Sebastian Gniazdowski psprint /at/ zdharma.org