JohnEarnest/ok

Float parsing vs trains

leahneukirchen opened this issue · 3 comments

% k
2016.08.09 (c) arthur whitney
 @ . "6.
`f
% ok
oK v0.1
  @ . "6."
107

Recently, Arthur's interpreter went from representing typecodes with magic numbers to using symbols. It's an interesting design tradeoff. Magic numbers make it relatively easy to partition things into type classes (for example, checking their sign to distinguish vectors from scalars as in most K dialects), and this is slightly more difficult with symbols. The symbols are, of course, rather less cryptic and create pleasant symmetry with the behavior of dyadic $. This is on my todo list.

(Fun fact: if you dig back through oK's commit history, I actually experimented with this behavior for a while before reverting to magic numbers!)

Sorry, that's not what I meant. k6 parses 6. as 6.0, ok parses 6. as (6 .)

Ah, I see. Seems like we just need to tweak the regex used to identify numeric tokens:

https://github.com/JohnEarnest/ok/blob/gh-pages/oK.js#L651