JohnEarnest / ok

An open-source interpreter for the K5 programming language.
MIT License
587 stars 72 forks source link

some odd results #22

Closed ngn closed 8 years ago

ngn commented 9 years ago

Possibly not all of them wrong.

  ""
()
  []
parse error. name expected.
  " / "
unexpected character '"'

If my understanding is correct, a[b], a@b, and a b should be equivalent. But:

  [a:0][`a]
unexpected character '['
  [a:0]@`a
0
  [a:0]`a
`a

  `a[0]
the name 'a' has not been defined.
  `a@0
the name 'a' has not been defined.
  `a 0
0

  "a"[0]
function or list expected.
  "a"@0
dictionary expected, found char.
  "a"0
0
JohnEarnest commented 9 years ago

Some of these do appear to be bugs.

"" and () being equivalent is correct given the current behavior of oK's type system- oK does not presently distinguish between unitype and mixed type vectors for the sake of simplicity. k5 has some very odd edge cases as a result of how drawing this distinction interacts with various features. [] by itself is not a syntax error in k5, presumably denoting an empty dictionary. " / " producing a parse error is very strange and may be a result of my parser being overly eager about consuming what it thinks is a comment.

Indexing dictionaries via [], @ or juxtaposition, in the cases you show, should do the same thing.

k5 does not permit any form of indexing directly on symbols, even if they match a defined array for which the indexes would be valid, so oK is doing the wrong thing in at least the third case you demonstrate.

The literal "a" represents a scalar value, so indexing it in any form should be a rank error. oK's error message in the second case is confusing and the third case is incorrect behavior.

It will take me a while to address all of these, but they're on my todo list.

JohnEarnest commented 8 years ago

The remaining issue here was corrected as part of https://github.com/JohnEarnest/ok/pull/34