wolfgangj / bone-lisp

The Bone Lisp programming language
Other
321 stars 21 forks source link

Files with `#!` can not be `read` #22

Open wolfgangj opened 8 years ago

wolfgangj commented 8 years ago

While bone_load() skips the first line of a file if it starts with #!, the reader itself does not. Trying to read such a file results in an error due to the unknown reader macro that was requested to be called.

chrisosaurus commented 8 years ago

does the read sub know where it is in a file?

worst case we can define ! as a reader that consumes a line, but then any occurrence of #!foo in the code base will be silently ignored.

Ideally #!foo will only be consumed and ignored if it is the first line.

wolfgangj commented 8 years ago

We can find out about the line in read.

By the way, ! as a reader would not work, because we use symbols as reader names, not single characters, so #!foo is the reader !foo. Sure, Unix has always supported optional whitespace after the #!, but we wouldn't want to limit users to #! foo.

My advice for designers of new Lisp dialects: Just use # as a comment character and use something else (like $ or %) for reader macros etc. That'll help you keep your sanity.