From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3394 invoked by alias); 19 Nov 2014 02:51:10 -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: X-Seq: 19409 Received: (qmail 19831 invoked from network); 19 Nov 2014 02:51:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=Cp8Iqc8G c=1 sm=1 tr=0 a=FT8er97JFeGWzr5TCOCO5w==:117 a=kj9zAlcOel0A:10 a=q2GGsy2AAAAA:8 a=oR5dmqMzAAAA:8 a=-9mUelKeXuEA:10 a=5y4faFyK3SkA:10 a=L_bJj_VcXZRqsBmkkTAA:9 a=vbBbCboVQPFd9zon:21 a=TBl15xdiKnVxEZzX:21 a=CjuIK1q_8ugA:10 From: Bart Schaefer Message-id: <141118185124.ZM5238@torch.brasslantern.com> Date: Tue, 18 Nov 2014 18:51:24 -0800 In-reply-to: Comments: In reply to TJ Luoma "Function or Alias - Does it matter?" (Nov 18, 7:13pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh-Users List Subject: Re: Function or Alias - Does it matter? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Nov 18, 7:13pm, TJ Luoma wrote: } } Is there any practical difference between making an alias or a } function if they do the same thing? This depends on how precisely you mean "the same thing". An alias is a textual replacement. It works like that setting in your phone SMS app that your friends use to prank you by having "LOL" expand to a rude phrase if you leave the phone unlocked where they can find it. A function is a semantic construct that encapsulates a series of other semantic constructs so you can easily/repeatedly execute that series, even if it's a series of only one item. } Is there any reason to prefer one or the other? An alias can change the semantics of the construct in which it appears by changing the text and syntax before parsing is done. A function can manage a local environment (parameters, options, etc.) without altering the environment of its caller. Which one to prefer depends on what you want to accomplish.