Ultra-short names
John Cowan
(16 Aug 2015 14:56 UTC)
|
Re: Ultra-short names
taylanbayirli@xxxxxx
(16 Aug 2015 16:45 UTC)
|
Re: Ultra-short names Per Bothner (16 Aug 2015 17:20 UTC)
|
Re: Ultra-short names
Per Bothner
(16 Aug 2015 17:29 UTC)
|
Re: Ultra-short names Per Bothner 16 Aug 2015 17:20 UTC
On 08/16/2015 07:56 AM, John Cowan wrote: > What do you think about using `!` instead of `set!` and `$` instead of > `ref`? They are very short, preserve the !-convention, fit in nicely > with Gauche's `~`, and aren't much used in existing Schemes. I ran them > through my 47 Schemes, and found only these: > > Schemik excludes `$` from symbols, but doesn't seem to use it otherwise. > > Llava uses `!` as a synonym for `not`. > > Elk binds `!` to the value of the last expression evaluated at the REPL. > > Inlab has a procedure `!` which invokes an editor on the last expression > typed at the REPL and evaluates it. > > Owl Lisp uses `!` for the factorial function. Kawa uses '!' as (roughly) a synonym for define. A separate operator is needed to avoid ambiguity with the function-defining variants of define. Also, 'let'/'let*'/''letrec' and 'define' are too verbose. (! PATTERN VALUE) Evaluate VALUE and bind against the PATTERN. Most commonly PATTERN is a simple identifier (in which case it's like a 'define'), but it can include a type specifier or be a complex pattern. '|' also implies the bound names are constant (non-assignable) and local by default. (I.e. a file-level name is not exported.) '!' also disallows overriding definitions, to catch common errors, though this feature may need some tweaking. There is also: (? PATTERN VALUE) Can only be used in a conditional context (like an /if' or an 'and'). If the VALUE matches against the PATTERN then the bindings are available if the 'then' clause of the 'if' (or in the case of an 'and', the following sub-expressions), and the boolean value is true. These extensions are relatively new: While the basic syntax was in the 2.0 release, it wasn't really documented, awaiting the more general pattern framework, currently in the "invoke" Subversion branch. -- --Per Bothner xxxxxx@bothner.com http://per.bothner.com/