Make ArithmeticElementCreator understand re-read mode#5956
Make ArithmeticElementCreator understand re-read mode#5956fingolfin merged 1 commit intogap-system:masterfrom
ArithmeticElementCreator understand re-read mode#5956Conversation
In GAP one can use `Reread` (and its variants) instead of `Read` (and its variants) while developing code; this suppresses errors caused by re-defining global read-only variables. But this didn't work when using `ArithmeticElementCreator` because that had its own check for detecting and rejecting such redefinitions. This patch teaches it to honor the `REREADING` global for a smoother developer experience.
ThomasBreuer
left a comment
There was a problem hiding this comment.
The proposed change addresses the situation where a file gets read with Reread that contains a call to ArithmeticElementCreator.
With this change the following happens.
- Read the file for the first time. Let us assume the return value of
ArithmeticElementCreatoris assigned to the variableaecafterwards. - Create some arithmetic objects:
a:= aec( ... ); b:= aec( ... ); .... - Reread the file. Now
aecis a new object. - Create more arithmetic objects:
c:= aec( ... ); .... - Now
a + bworks, buta + cdoes not work becauseaandchave been created by different creator objects.
In this sense, isn't this change asking for trouble?
Of course one can argue that the same happens if a file contains the creation of a free group, and rereading this file will create a new group whose elements are not compatible with elements of the original group.
However, I think the difference is that here one can see that the underlying objects are different, whereas the return value of ArithmeticElementCreator looks like an innocent function, and rereading such code is regarded as safe.
|
While all your points are valid, I still think this change is beneficial: in the end, In my eyes it is a low-level tool for developers who (think they) know what they are doing. I see no advantage in defeating it in this scenario for the sake of protecting developers from shooting themselves in their foot -- in my mind if we followed that line of reasoning then we should abolish |
|
@ChrisJefferson any thoughts on this? |
|
I agre I'm happy with this. I'd also be happy to ban Reread, but if we are going to keep supporting it, this make is function in another case. There are lots of ways Reread can get you in an inconsistent state. |
In GAP one can use
Reread(and its variants) instead ofRead(and its variants) while developing code; this suppresses errors caused by re-defining global read-only variables.But this didn't work when using
ArithmeticElementCreatorbecause that had its own check for detecting and rejecting such redefinitions.This patch teaches it to honor the
REREADINGglobal for a smoother developer experience.Based on questions by @TWiedemann