-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make GAP.EvalString more convenient #163
Conversation
Rename the current GAP.EvalString to GAP.EvalStringEx (for "Ex"tended), added a new GAP.EvalString which only returns the value of the last command, and which also automatically appends a semicolon to the input string.
Codecov Report
@@ Coverage Diff @@
## master #163 +/- ##
==========================================
+ Coverage 54.39% 54.45% +0.05%
==========================================
Files 37 37
Lines 1682 1684 +2
==========================================
+ Hits 915 917 +2
Misses 767 767
|
res = ccall( :GAP_EvalString, MPtr, | ||
(Ptr{UInt8},), | ||
cmd ); | ||
return res | ||
end | ||
|
||
function EvalString( cmd :: String ) | ||
res = EvalStringEx(cmd * ";") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this is an sensible convention?
I am not sure it makes sense here, but in GAP you can end statements with ;
or ;;
. If you now put ;;
at the end of a statement, this command does not return a value. Is that intentional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, quite intentional:
- if you want to shoot yourself in the foot, you can always do that, and e.g. end the string with a command that returns nothing; or add
;;;;;
to the end (which amounts more or less the same); or do something else that's crazy. You can do so with the existingEvalString
command do - I though about doing something like "check if there is a trailing semicolon and only add one if there is not" -- but then you can continue this game, and ask "what if the user put three semicolons at the end, should I remove some" etc.
- Adding a semicolon is also what GAP's own
EvalString
does, so now the two match in their behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree that more or less all solutions have pitfalls. If GAP's EvalString method behaves like this, it is okay. Stupid question, why don't we make EvalString
just
EvalString( x ) = GAP.Globals.EvalString( julia_to_gap( x ) )
This way we can have the exact same behaviour?
Rename the current GAP.EvalString to GAP.EvalStringEx (for "Ex"tended), added
a new GAP.EvalString which only returns the value of the last command, and
which also automatically appends a semicolon to the input string.