wisp-lang / wisp

A little Clojure-like LISP in JavaScript
https://gozala.github.io/wisp/
Other
982 stars 68 forks source link

Include location information for primitive values. #59

Open Gozala opened 11 years ago

Gozala commented 11 years ago

Location information currently is stored in metadata, but since metadata can be added on primitive values location information is missing on them causing inaccurate source mapping.

I can see few ways to fix that:

  1. Reader can read String Number etc.. instances instead of primitives, in which case metadata could be attached. This is going work but will be very JS specific solution I'm afraid, also nil will require some special treatment.
  2. Store metadata about primitives in the form containing them. I'm afraid it may require a lot of work on the reader side, also API may end up awkward.
Gozala commented 10 years ago

Source map support for strings and numbers has landed as string and number primitives now are read as String and Number instances.

Although booleans and nil are still unsupported. One idea that may work out would be to read primitive forms like applications (boolean true), (boolean false), (and nil) that way they'll be lists to which metadata could be attached, at the same time they will evaluate as expected in macros.

Gozala commented 10 years ago

In fact it would be easier to read all the primitives as:

(quote true)
(quote false)
(quote nil)
(quote 5)
(quote "hello")