Skip to content
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

Merged
merged 1 commit into from
Nov 23, 2018

Conversation

fingolfin
Copy link
Member

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.

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.
@fingolfin fingolfin requested a review from sebasguts November 22, 2018 16:33
@codecov
Copy link

codecov bot commented Nov 22, 2018

Codecov Report

Merging #163 into master will increase coverage by 0.05%.
The diff coverage is 100%.

@@            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
Impacted Files Coverage Δ
LibGAP.jl/src/ccalls.jl 100% <100%> (ø) ⬆️

res = ccall( :GAP_EvalString, MPtr,
(Ptr{UInt8},),
cmd );
return res
end

function EvalString( cmd :: String )
res = EvalStringEx(cmd * ";")
Copy link
Contributor

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?

Copy link
Member Author

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 existing EvalString 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.

Copy link
Contributor

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?

@sebasguts sebasguts merged commit f9d20c8 into oscar-system:master Nov 23, 2018
@fingolfin fingolfin deleted the mh/GAP.EvalString branch November 23, 2018 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants