-
Notifications
You must be signed in to change notification settings - Fork 162
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
Remove support for float literals starting with a period [DO NOT MERGE] #3280
base: master
Are you sure you want to change the base?
Remove support for float literals starting with a period [DO NOT MERGE] #3280
Conversation
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.
This looks sensible to me. My original idea was to implement all C floating point literals (except the ones that were already integers), but that failed anyway because we wanted 2E6 to be a an identifier rather than a number.
9ff60d3
to
bb15065
Compare
There's one drawback, which is that mpfr standardizes things by printing
all floats with an initial ".":
gap> SetFloats(MPFR);
gap> 0.1;
.1e0
gap> .1e0;
.1e0
gap> 0.e0;
.0e0
We can change that by always printing an initial "0", but I'd like to check
that it doesn't snowball.
Out of curiosity, what is the plans about writing new (external) parsers?
…On Tue, Feb 12, 2019 at 9:01 AM Steve Linton ***@***.***> wrote:
***@***.**** commented on this pull request.
This looks sensible to me. My original idea was to implement all C
floating point literals (except the ones that were already integers), but
that failed anyway because we wanted 2E6 to be a an identifier rather than
a number.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3280 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACIIUEOR6VS7vCLjgsesDeIFx4U7M1WJks5vMnTogaJpZM4a1PYc>
.
--
Laurent Bartholdi laurent.bartholdi<at>gmail<dot>com
Bureau GN1 Nord 472, tel. +33 4 72728722
École Normale Supérieure
46 allée d'Italie, 69364 Lyon Cedex 07
|
Can you give an example of what makes the initial . hard to recognise, or is it just because they were added later in a slightly hacky way? |
The problem is how to tokenise something like
without a clue from the parser level, this could be either a name followed by the float The existing hack supplies that hint. |
@laurentbartholdi I don't see a major problem with that output. Sure, it's not again valid input, but that's the case for many objects (and any dreams to the contrary are doomed). That said, as you say, it's easy to correct, too.... I am not quite sure what you have in mind when you say that you'd "like to check that it doesn't snowball." ? |
I vaguely remember that in some cases the Float library uses the output
string, and makes some assumption on the initial dot; I'd rather make sure
that it was only for convenience that I did it that way, and that it won't
cause lots of other problems that have to be fixed... whence a snowball. In
all cases, if my fears are correct, then the new GAP will only be
compatible with a new Float.
…On Tue, Feb 12, 2019 at 11:32 AM Max Horn ***@***.***> wrote:
@laurentbartholdi <https://github.com/laurentbartholdi> I don't see a
major problem with that output. Sure, it's not again valid input, but
that's the case for many objects (and any dreams to the contrary are
doomed). That said, as you say, it's easy to correct, too....
I am not quite sure what you have in mind when you say that you'd "like to
check that it doesn't snowball." ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#3280 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACIIUEsVgfGuTBGTqKIsJQ8hNm13h0IQks5vMpgjgaJpZM4a1PYc>
.
--
Laurent Bartholdi laurent.bartholdi<at>gmail<dot>com
Bureau GN1 Nord 472, tel. +33 4 72728722
École Normale Supérieure
46 allée d'Italie, 69364 Lyon Cedex 07
|
I'm not super-enthusiastic about this, while I'd be happy to have never accepted The rules around how |
@laurentbartholdi that sounds like very fragile code to begin with. In any case, I of course run the float test suite, which still passes -- but it's rather small, and e.g. does not seem to cover printing at all, nor many other functions, so I guess it passing does not mean much. That of course by itself is kind of a problem, too. @ChrisJefferson the rules are actually not that messy. I refactored the code last year, and it's IMHO pretty clear now, though of course not exactly trivial; but that holds for any code parsing floats, as one has to deal with exponent notation and whatnot. In any case, as I wrote, part of the motivation is precisely so that code does not have to reimplement the logic, but rather can directly lift the tokenizer (i.e. the code in |
But it's good that you made me look again -- I actually can simplify the code some more in this PR, by removing |
bb15065
to
d6f5450
Compare
Codecov Report
@@ Coverage Diff @@
## master #3280 +/- ##
===========================================
+ Coverage 82.07% 93.49% +11.42%
===========================================
Files 684 716 +32
Lines 289913 812223 +522310
Branches 8615 0 -8615
===========================================
+ Hits 237933 759358 +521425
- Misses 50082 52865 +2783
+ Partials 1898 0 -1898
|
d6f5450
to
562201b
Compare
562201b
to
b79076a
Compare
I regret that I did not remember to bring this up during the last GAP days. Anyway, I might whip up a PR which does not disable this, just prints a warning message whenever floats starting with a dot are used. That could be used to flush out any related issues in the float package. As I said, i already tried to find issues with this change inside the float package, but apparently just running the test suite is not enough for that (which is a concern of its own). Frankly, the whole state of float support in GAP is a bit depressing to me. Most things are not documented (including whether we support parsing |
b79076a
to
aa51bf4
Compare
aa51bf4
to
d8592ec
Compare
d8592ec
to
f31eb57
Compare
f31eb57
to
f63840f
Compare
f63840f
to
9f9c8b6
Compare
9f9c8b6
to
dddce0b
Compare
dddce0b
to
317a1fa
Compare
Before this patch, writing .0 instead of 0.0 was allowed, as in C, C++, D, Java, Go, Perl, Python and many other languages. This required a hack in the form of an additional entry pointer for our scanner. We now get rid of it, matching languages like Ada, Haskell, OCaml, Rust, Swift.
317a1fa
to
6dc3d5d
Compare
@laurentbartholdi the motivation is discussed at length in this PR (which is marked as "DO NOT MERGE", don't worry at this time). If we ever again think making a bigger and partially breaking release of GAP, this is a candidate for inclusion. |
Before this patch, writing .0 instead of 0.0 was allowed, as in C, C++, D, Java, Julia, Go, Perl, Python and many other languages. This required a hack in the form of an additional entry pointer for our scanner. We now get rid of it, matching languages like Ada, Haskell, OCaml, Rust, Swift.
The main motivation for this is to reduce the API surface of the GAP scanner, and to remove the need for code using it to emulate the reader (or at least substantial parts of it) in order to provide a fully compliant tokenizer for GAP code. This should simplify external implementations of code formatters and other similar code which wants to "parse" GAP code somehow.
Usability should not really be impacted: first off, most floats don't get entered by hand anyway, and secondly, usage of floats in GAP still is a relative rare thing, I expect only few people use it. Of course some package might use float constants starting with a dot somewhere, but so far I have not found any. In any case, code using such constants should be trivial to adapt, and once adapted, the code will of course still work in older GAP releases just fine, too.
Right now, I can only think of two serious arguments against this (which of course just means that my imagination is limited):
sed
, plus a regex).I'd be very much interested to hear what others think about this, esp. @laurentbartholdi.