Hacker News new | ask | show | jobs
by bmacho 519 days ago
> and the universal DSL for calling programs (program name, space separated list of arguments).

Yeah, don't do that. Both the program name, and the arguments can and do contain spaces. Do instead what every other languages do, that is, use a list of strings to invoke programs.

> The latter is even the same syntax that lisp uses for functions calls

No it's not.

1 comments

The way that this syntax (see bash, zsh, fish, etc) usually work is that these lists are separated by spaces. You can still quote arguments if they contain spaces (or escape the spaces).

Choosing space for a very common thing in your language often makes sense, as you reduce the amount of visual elements. Thus space is often used to apply arguments to functions. Lisp and Haskell are common examples Though, you could argue that in Lisp it only is an application if it is within parenthesis.

Lisp looks like it uses spaces, but that's only when we look at certain kinds of tokens that are terminated by whitespace, like numbers and symbols.

So (ls -l .foo) is a three element list of symbols in Common Lisp or Scheme, sure.

Symbols are not strings though; we don't necessarily want to use symbols this way. For one thing, they get interned. That means they stick around forever, or until explicitly uninterned. The symbols are memorized so that the next time they appear, the same object is returned (almost always implemented as a pointer to the same symbol).

String tokens use mandatory double quotes: ("ls" "-l" ".foo")

> The way that this syntax (see bash, zsh, fish, etc) usually work is that these lists are separated by spaces.

And programming languages that have variables, string type, and function calls do the opposite. In C, Python, JavaScript etc, in order to start a program you make a function call with a list of strings.

> Choosing space for a very common thing in your language often makes sense,

Not interpreting space separated things as strings but as keywords (built ins, variable names, literals) makes more sense for bigger programs.