4 ms·
Hah! Why am I not surprised to see that nick on HN too :-) I have no experience with LispWorks whatsoever, but I am curious, how did they implemented it if you
by amno 3y ago
Hah! Why am I not surprised to see that nick on HN too :-)
I have no experience with LispWorks whatsoever, but I am curious, how did they implemented it if you know? I mean, how do they differ between calling first as a value or first as a function? In your example first could be a defvared to have some value, and then I might have called a function to produce some unrelated output. I mean it is a contrived example, and probably nobody types in a repl like that, but the language does not forbid it since white spaces are insignificant.
If they just treat the first token as operator always, than they could call any function with any arguments:
CL-USER> op arg1 arg2 ... argN
but then they would have to eval all values at the start of repl by calling (symbol-function arg), instead of just type arg to examine a value. I don't think it would be a bad think in itself tbh; but I am not sure the win is big enough to introduce a new concept.
By the way, I think I have stumbled on some mailing list comment somewhere once, where they said, that Hemlock can use commands named more "english like", i.e. they can have names with spaces in it, not just the hyphenated function name as in Emacs. Do you know more about it, or how they have implemented it? I am just curious; seen your comments on Reddit, and if you are the same person, I understand you are well experienced and familiar with various Lisps and implementations; hope you don't mind asking. :)
- lispm 3y ago> how did they implemented it if you know? It's relatively easy: a variable: CL-USER> foo an operator with no arguments: CL-USER> (foo) an operator with one or more arguments: CL-USER> foo 1 CL-USER> foo 1 2 CL-USER> foo 1 (+ 1 2) (+ 3 4) and so on. > Hemlock can use commands named more "english like" That's like Emacs (called Zmacs) on the Lisp Machine does it. It does not use hyphens at all. I can't remember how the first Emacs, the TECO Emacs, did it. M-x compile-changed-definitions-of-buffer is then M-x Compile Changed Definition Of Buffer Basically instead of hyphens it uses spaces. In LispWorks & Zmacs one enters the command M-x Replace String <return> and then the editor prompts for the arguments.
- amno 3y ago> CL-USER> foo 1 > > CL-USER> foo 1 2 > > CL-USER> foo 1 (+ 1 2) (+ 3 4) But then they do have the problem I mentions: they can't distinguish between calling (foo 1 (+ 1 2) (+ 3 4)) and calling (foo 1) (+ 1 2) (+ 3 4). I don't think it is important ether, I certainly wouldn't type code like that in a repl either. I don't even know if sly/slime repl even support typing several expressions on the same line in repl. I am not at home to test it. > Basically instead of hyphens it uses spaces. > > In LispWorks & Zmacs one enters the command M-x Replace String <return> and then the editor prompts for the arguments. I understand, thanks. I thought they were a bit more finicky about it. I think that could be relatively easily done in Emacs as well, but I don't see much gain to implement a M-x replacement like that. Especially with modern completion systems like Helm and fuzzy completing which basically don't care how we type. Thank you for your time and answers.
- lispm 3y ago> they can't distinguish between calling (foo 1 (+ 1 2) (+ 3 4)) and calling (foo 1) (+ 1 2) (+ 3 4). It uses always (foo 1 (+ 1 2) (+ 3 4)). It uses the complete input. > I don't even know if sly/slime repl even support typing several expressions on the same line in repl. Most Lisp REPLs use multiline input. Here LispWorks requires that + 1 2 is on a single line. If one enters more than one expression to a single prompt, possibly on/spanning multiple lines, each will be executed. > but I don't see much gain It looks better. Much better. Minus: the command now has spaces in its name, which makes it more difficult to use in scripts.
- amno 3y ago>> but I don't see much gain > It looks better. Much better. I think it is just preference. I don't think it would be difficult to implement in Emacs, by just transforming the symbol name and presenting that to user instead. I think the read-extended-command-1 is the place where they actually do the work. They could also store a display string for each command in symbols plist as they do with interactive form, but it would be more surgery and as you say harder to use in the code. If display string is decoupled from the function name than the programmer has to remember as well the name for the command, but if they just do a transformation than the programmer can remember the rule. We are used to this in menus and gui stuff like that indeed, labels are often different strings than actual symbol names used for function callbacks, but I am not sure if we would prefer that on the command line. In my opinion there is still discrepancy between the spoken language and the function names. I guess that is why people have come up with llamas and what not they call those AI llms and chatgpt and so on. I personally am not so fun of using spoken languages as a programming language or a way to control the computer, but who knows, perhaps one day M-x will run some llm search instead of precise lisp function names.