top | item 42728449

(no title)

rmgk | 1 year ago

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.

discuss

order

kazinator|1 year ago

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")

bmacho|1 year ago

> 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.