Skip to content

Comment on Lisp implemented in Rust macrosparent

Comments

Wouldn’t that match “(foo - bar)” as well as “(foo-bar)”? I don’t think you can get around token whitespace in macro_rules

Yes it would match both, this would require us to assume that "foo - bar" can only be an atom. It's not a great solution.

It would, but lisp has prefix operators, so you wouldn’t have to worry about it getting confused.

Although in a Lisp such as Scheme, you could pass around the negation operator in something like (map - '(1 2 3)), so it would be a valid concern that it might clash.

The problem with that is that there are spaces between map, -, and '(1 2 3). The only way to get spaces into a name is by using vertical bars:

  (defvar |do i 10| 1.100)
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.