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

Added IsLIBGAP constant #2528

Merged
merged 1 commit into from
Jun 12, 2018
Merged

Conversation

sebasguts
Copy link
Member

This constant can be set to true in the initialize_libgap function (future work)
to stop GAP from starting an interactive session

This replaces #2527

lib/init.g Outdated
SESSION();
else
BIND_GLOBAL( "IsLIBGAP", true );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use BIND_CONSTANT instead

Copy link
Member

@fingolfin fingolfin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but let's wait to see if tests pass.

Copy link
Member

@markuspf markuspf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lib/init.g Outdated
@@ -1019,8 +1019,11 @@ end );
if IsHPCGAP and THREAD_UI() then
ReadLib("hpc/consoleui.g");
MULTI_SESSION();
else
elif not IsBound( IsLIBGAP ) or IsLIBGAP = false then
BIND_CONSTANT( "IsLIBGAP", false );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test fail, partially because of your .tst file... e.g. in HPC-GAP, we will not define IsLIBGAP. Better is to do this before line 1019:

  if not IsBound(IsLIBGAP) then
    BIND_CONSTANT( "IsLIBGAP", false );
  fi;

and then change this check here back to elif not IsLIBGAP, and drop the else part.

##
gap> START_TEST("IsLIBGAP.tst");
gap> IsBound( IsLIBGAP );
true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to run ./gap tst/testinstall.g before submitting an updated version of this PR, to make sure it really works.

@codecov
Copy link

codecov bot commented Jun 7, 2018

Codecov Report

Merging #2528 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #2528   +/-   ##
=======================================
  Coverage    74.4%    74.4%           
=======================================
  Files         481      481           
  Lines      243488   243488           
=======================================
  Hits       181157   181157           
  Misses      62331    62331
Impacted Files Coverage Δ
lib/init.g 71.54% <ø> (ø) ⬆️

@sebasguts
Copy link
Member Author

I updated the PR.

I now initialize the IsLIBGAP variable before the systems gvar list is created. Otherwise the test will not work (and I think IsLIBGAP should be a system gvar).

@olexandr-konovalov olexandr-konovalov added the gapdays2018-spring Issues and PRs that arose at http://www.gapdays.de/gap-jupyter-days2018 label Jun 8, 2018
lib/init.g Outdated

#############################################################################
##
## Initialize the IsLIBGAP variable (if not done before). If this variable is false, an interactive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please line-wrap this (I think at 78 chars... anyway, at the same width as the ####... line above.

lib/init.g Outdated
@@ -936,7 +947,6 @@ end );
#T as system variables!
##


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't remove this line.

lib/init.g Outdated
## Initialize the IsLIBGAP variable (if not done before). If this variable
## is false, an interactive session will be started.
## Otherwise no interactive session is started.
## This should be done before the system GVAR list is created.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "should" -> "must" Or rather, just drop that line?

Anyway, let's not worry about this and merge as-is; I only mention it in case we need to update this again, say due to a build issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Should" is the right word here. It works if you do it afterwards (however that should be done), but it will not be marked as a system gvar.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is more like this: There are countless variables which "should" or "must" be system vars, and none of them has a comment like this. It feels odd to point this out for just this variable. While I understand that this was a stumbling block during development of this PR, I don't quite see what it adds -- OK, hypothetically it might stop somebody from "moving" it around, but then, why would somebody do that? OTOH, if I just want to understand what it is, then reading this adds cognitive burden.

That said, I am not going to get stuck on that -- I merely point it out.

lib/init.g Outdated
MULTI_SESSION();
fi;
elif IsLIBGAP = false then
BIND_CONSTANT( "IsLIBGAP", false );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, this call to BIND_CONSTANT is redundant, isn't it? After all, you just checked that value.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was supposed to make IsLIBGAP constant, which does not work in this case anyway, so I will remove it.

lib/init.g Outdated
@@ -1018,8 +1030,11 @@ end );

if IsHPCGAP and THREAD_UI() then
ReadLib("hpc/consoleui.g");
MULTI_SESSION();
else
if IsLIBGAP = false then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I was confused by the new logic for a moment (sorry for missing it in the previous version)... How about this

if IsLIBGAP then
   # GAP is used as a library, so don't start a session
elif IsHPCGAP and THREAD_UI() then
  MULTI_SESSION();
else
  SESSION();
fi;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure actually. If we ever decide to have a HPC-GAP libGAP, the way it is now we could leave this as it is.

Copy link
Member Author

@sebasguts sebasguts Jun 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, nevermind. I will change it to do have this logic.

This constant can be set to true in the initialize_libgap function (future work)
to stop GAP from starting an interactive session
@sebasguts
Copy link
Member Author

I removed the questionable sentence :).

@fingolfin fingolfin merged commit d05bbd2 into gap-system:master Jun 12, 2018
@fingolfin fingolfin added the release notes: added PRs introducing changes that have since been mentioned in the release notes label Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gapdays2018-spring Issues and PRs that arose at http://www.gapdays.de/gap-jupyter-days2018 release notes: added PRs introducing changes that have since been mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants