bone-lisp icon indicating copy to clipboard operation
bone-lisp copied to clipboard

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

Open wolfgangj opened this issue 9 years ago • 2 comments

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.

wolfgangj avatar Jul 30 '16 15:07 wolfgangj

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.

chrisosaurus avatar Jul 31 '16 04:07 chrisosaurus

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.

wolfgangj avatar Jul 31 '16 08:07 wolfgangj