From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11569 invoked by alias); 23 Apr 2018 09:34:41 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23361 Received: (qmail 11954 invoked by uid 1010); 23 Apr 2018 09:34:41 -0000 X-Qmail-Scanner-Diagnostics: from aurora-borealis.phear.org 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(94.242.205.164):SA:0(-1.9/5.0):. Processed in 2.71214 secs); 23 Apr 2018 09:34:41 -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=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: eiro@phear.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: amavisd-new at phear.org DKIM-Filter: OpenDKIM Filter v2.10.3 aurora-borealis.phear.org 730AFFFBB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=phear.org; s=20180217; t=1524475454; bh=SPr0IHEqCRfjRd/O9BtwOO3wS7nQSxYv4NM02gUejUE=; h=Date:From:To:Subject:From; b=jBXzmWUulKIGJ8VaV25khpDZ0WtZfwjKHbdpcCPDzmp9OAmojLZrnAnwv5uX1V4Nv pVLV9p3icoctWmP8zp99XXXWQkvGt87Lg2TRyBA8PCXCAx8P/4DRZ2IXmKuwqYnSyn Ghjxq2A7YjBU6hucysyeA8OTrdNaNEazrR085+WPl4U9/wi/sgIewS3uISvx6CF/ua GFAIlJBEw2LNUE+2bp61kZ+8I9pwNc/JYKsF7EdClUIKMCSAbCSy7FS2Aulsvjvvtj DA3pUyRuJPUSqDtO2T4naFNeTUchbn5IsMax5Xd1WSpHKVVv8flurhOw4dXRPDNFQp iCCuH5YNMeP+Q== Date: Mon, 23 Apr 2018 11:24:12 +0200 From: Marc Chantreux To: Zsh Users Subject: zsh at perl conference and few questions Message-ID: <20180422204849.GA30387@prometheus.u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) hello people, i'm happy to annonce i'll talk about zsh during the european edition of the perl conference (glasgow) http://act.perlconference.org/tpc-2018-glasgow/talk/7338 as i prepare my slides those days, some questions came to me. some of these are (detailed below): a) can someone tell me why isn't the "alternative" syntax more used ? b) why the while loop can't take (( )) or single instruction as do list ? c) it seems the (+) syntax can't be used outside file expansions d) is there a plan to have something like namespaces ? any comment/feedback/thought would be really appreciated. regards marc a) can someone tell me why isn't the "alternative" syntax more used ? i felt in love with zsh about 20 years now and one of the reason is the alternative syntax. so can someone explain to me why the "old" one seems to be prefered even nowdays ? for x in {1..20}; do print "$x * 2 = $[x * 2]" done seems terrible to me compared to for x ({1..20}) print "$x * 2 = $[x * 2]" as time passed, i added those alias in my .zshenv alias @='for it' alias @-='while {read it}' so i daily (hourly ...) write those kind of thing @ (*.txt) gzip $it b) why the while loop can't take (( )) or single instruction as do list ? those works fine if {true} print ok if (( 2 == 2 )) print ok for ((count=3; count; count--)) print $count while ((count)) {print $[count--]} so why not those ? while ((count)) print $[count--] while {read it} ((sum+=it)) c) it seems the (+) syntax can't be used outside file expansions (or did i miss something?) as you can write by_word_count () REPLY=$( wc -w < $REPLY ) print -l *.html(.o+by_word_count) why shouldn't i write by_word_count () REPLY=$( wc -w < $REPLY ) files=( *.html(.) ) print -l ${(o+by_word_count)files} or filter with something like large () (( $( wc -w < $REPLY ) > 200 )) files=( *.html(.) ) print -l ${(+large)files} d) is there a plan to have something like namespaces ? using setopt pathdirs, you can put functions into files in your path and reuse the name of it into the function names. i use it to create a poor man namespace. so if i have net/utils in my path i can fill it with net/utils/running\? () ping -W 1 -c 1 ${1?ip or hostname to ping} \ &> /dev/null net/utils/report () { local status="missing" net/utils/running\? ${1?ip or hostname to ping} && status="online" print -u2 "$1 is $status" } so now i can write $ . net/utils $ net/utils/report prometheus prometheus is online in uze.zsh, i created something to export a function into the main namespace (just copy the values of $functions ) so i can write $ . net/utils report $ prometheus prometheus is online so for the user of the net/utils lib, that's fine ... *but* when i write functions, i have to be careful about the current namespace. the thing i dream about is the ability to rewrite net/utils/report () { local status="missing" net/utils/running\? ${1?ip or hostname to ping} && status="online" print -u2 "$1 is $status" } as "the report function of this namespace"... if a // prefix could exist, i could write something like //report () { local status="missing" //running\? ${1?ip or hostname to ping} && status="online" print -u2 "$1 is $status" } this should be awesome but i don't know if realistic as zsh don't have syntax closure as well.