0xfaded / eval

BSD 3-Clause "New" or "Revised" License
34 stars 7 forks source link

[r=Rocky] Integrate binary checks #37

Closed 0xfaded closed 10 years ago

0xfaded commented 10 years ago

Hi Rocky,

I would like to merge this sooner than later. I've rewritten the binary expression tests to take advantage of the type checker and I think there is now reasonable coverage. One issue you are going to have is that identifiers, such as quit, are now checked and will raised undefined errors.

Im still not convinced about the need for the EvalIdent callback, in my opinion commands like quit would be better handled by some non-go syntax. for example, ghci uses : similar to the way vim works. For example, import is :m and :q is quit. IMO this is something the REPL loop should look for before attempting the evaluation phase. What are your thoughts on this? Once the merge happens go-fish will break, unless you add a dummy quit variable to the environment.

PS. I've just realised I've been hacking away with the vim expandtab option set. There is now a dogs breakfast of tabs and spaces throughout the code. I've been meaning to add a precommit hook for a while which runs go fmt. Once this is merged, I think I'll do that.

rocky commented 10 years ago

The EvalIdent callback is not there to distinguish repl commands from go expressions. It is there because the ssa-interpreter has its own type of "environment" to look things up. Converting that to an eval environment would be extremely time consuming and kind of wasteful, since most of the time most of it isn't used in evaluation.

As for distinguishing commands some way such as the use of a sigil like ":", I am amenable to such an idea. I had I think suggested using % because isn't that what ipython uses?

In the various debuggers I wrote, I have an abbreviation mechanism to an unfinished stage that is in go-fish and gub already. RIght now I've hard-coded in the aliases. In go-fish, "pkg" is an alias for "packages". So it is easy to make :q be an alias for quit or vice versa.

rocky commented 10 years ago

After this merge or was it the previous one. I see tests failing:

go test 
--- FAIL: TestReplaceIdentLookup (0.00 seconds)
    helper_for_test.go:19: Failed to check expression 'fdafdsa' ([undefined fdafdsa])
--- FAIL: TestReplaceSelectorLookup (0.00 seconds)
    helper_for_test.go:19: Failed to check expression 'bogusPackage.something' ([undefined bogusPackage])
--- FAIL: TestBuiltinAppend (0.00 seconds)
    helper_for_test.go:19: Failed to check expression 'append(slice, "three")' ([undefined append])
--- FAIL: TestBuiltinCap (0.00 seconds)
    helper_for_test.go:19: Failed to check expression 'cap(slice)' ([undefined cap])
--- FAIL: TestBuiltinLen (0.00 seconds)
    helper_for_test.go:19: Failed to check expression 'len("abc")' ([undefined len])
--- FAIL: TestBuiltinNew (0.00 seconds)
    helper_for_test.go:19: Failed to check expression 'new(int)' ([undefined int undefined new])
--- FAIL: TestEvalCallTypeExpr (0.00 seconds)
    helper_for_test.go:19: Failed to check expression 'bogus.MyInt(5)' ([undefined bogus])
--- FAIL: TestCompositeStructKeyValues (0.00 seconds)
    helper_for_test.go:19: Failed to check expression 'Alice{ Bob: 10 }' ([undefined Bob])
0xfaded commented 10 years ago

That was this commit, they are related to undefinded values during the typecheck

Carl 2014/01/13 19:45 "R. Bernstein" notifications@github.com:

After this merge or was it the previous one. I see tests failing:

go test --- FAIL: TestReplaceIdentLookup (0.00 seconds) helper_for_test.go:19: Failed to check expression 'fdafdsa' ([undefined fdafdsa]) --- FAIL: TestReplaceSelectorLookup (0.00 seconds) helper_for_test.go:19: Failed to check expression 'bogusPackage.something' ([undefined bogusPackage]) --- FAIL: TestBuiltinAppend (0.00 seconds) helper_for_test.go:19: Failed to check expression 'append(slice, "three")' ([undefined append]) --- FAIL: TestBuiltinCap (0.00 seconds) helper_for_test.go:19: Failed to check expression 'cap(slice)' ([undefined cap]) --- FAIL: TestBuiltinLen (0.00 seconds) helper_for_test.go:19: Failed to check expression 'len("abc")' ([undefined len]) --- FAIL: TestBuiltinNew (0.00 seconds) helper_for_test.go:19: Failed to check expression 'new(int)' ([undefined int undefined new]) --- FAIL: TestEvalCallTypeExpr (0.00 seconds) helper_for_test.go:19: Failed to check expression 'bogus.MyInt(5)' ([undefined bogus]) --- FAIL: TestCompositeStructKeyValues (0.00 seconds) helper_for_test.go:19: Failed to check expression 'Alice{ Bob: 10 }' ([undefined Bob])

— Reply to this email directly or view it on GitHubhttps://github.com/0xfaded/eval/pull/37#issuecomment-32152325 .