On 4/20/06, Philip Ganchev <[EMAIL PROTECTED]> wrote: > On 4/20/06, Axel Liljencrantz <[EMAIL PROTECTED]> wrote: > > On 4/20/06, Philip Ganchev <[EMAIL PROTECTED]> wrote: > > > Why did you decide to disallow the naive syntax "command1 | $commandstr"? > > > > Because using variables as a poor mans functions has several drawbacks: > > > > * It makes it much harder to validate the code without executing it > > * It blurs the distinction between code and data > > > > In the rare cases where you really _have_ to evaluate the contents of > > a variable as a command, simply use the eval builtin. Forcing the user > > to do this means that we can clearly and easily find all places where > > unvalidated and potentially problematic code is executed - simply > > search for and calls to 'eval'. > > > > [...] separate namespaces for > > code and data, [...] > > one of the biggest drawback of interpreted code is mostly removed - > > syntax bugs can be weeded out without having to make sure every > > codepath is executed first. > > > > None of these issues are important for quick throwaway hacks, but > > using a real function isn't really wordier or harder to us, so why not > > use the proper syntax instead of one which has no benefits and several > > drawbacks? > > Those are good points.
:) > > On the other hand, the mental model of the language is simpler if > variables are used the same way anywhere in a command: they are > replaced by their expansions before the command is executed. > Evidently Ray expected this behaviour. A simpler mental model is > easier to grasp and avoids snags of this kind -- Ray's code would work > as he expects. In fish, the command is subject to fundamentally different parameter expansion rules compared to arguments. Commands may not expand to more than one item, aren't subject to process substitution, etc.. > > If you don't change the design, perhaps it would help to make the > error messages smarter: > > fish> say$hello > fish: Invalid character '$' in command name. Only alphabetic and > numeric characters and underscore are valid. > > fish> $command1 > fish: Invalid character '$' in command name. Only alphabetic and > numeric characters and underscore are valid. If you are trying to use > the variable 'command1' as a command, define a function instead. > > fish> sayhello > fish: Unknown command 'sayhello' > > fish> function say!hello; echo hello; end > fish: Invalid character '!' in function name. Only alphabetic and > numeric characters and underscore are valid. > Absolutely! I'll go over these and improve them. More suggestions are welcome. -- Axel ------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid0709&bid&3057&dat1642 _______________________________________________ Fish-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fish-users
