Re: smelly code in input.c

Iavor Diatchki <[email protected]> Mon, 14 Jun 2021 08:13:24 -0700
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <CAGK9nuqNtFxKShRf7Ku=izoiiWjmFkSMswp7okPMxaQCFmSLcw@mail.gmail.com>
--===============1796213274045647837==
Content-Type: multipart/alternative; boundary="0000000000002857c005c4bb4dc3"

--0000000000002857c005c4bb4dc3
Content-Type: text/plain; charset="UTF-8"

Hi,

I don't not know that code either, but looking at the comments and the
surrounding code, my guess is that the 2nd `c0` should be `c1`,
and it is checking for something like `.` followed by either a lower case
or upper case or symbol operator.

-Iavor



On Mon, Jun 14, 2021 at 3:48 AM Anthony Clayden <[email protected]>
wrote:

> (I can't say for sure I have a bug, because I don't grok the code well
> enough to figure out how to make something go wrong, but ...)
>
> In /src/input.c line 1714
> https://github.com/FranklinChen/hugs98-plus-Sep2006/blob/master/src/input.c#L1714
> ,
>
> >     if (c0=='.' && isIn(c0,(SMALL|LARGE|SYMBOL))) {
>
> It looks wrong to be testing `c0` twice, that test will always come out
> False. (Or if '.' counts as a SYMBOL, then always True.) I guess the second
> test should be lookahead `isIn(c1, ...)`. That follows the code pattern
> nearby above line 1688, and especially 1698.
>
> I think it'll mean the compiler won't handle multi-qualified names like
> `Mod1.Sub2.Subsub3.Foo`. Whereas `Prelude.True` (just a single qualifier)
> is ok.
>
> Can anyone confirm my suspicion and/or suggest a definitive test?
>
> (Reason for asking: I'm trying to persuade Hugs to differentiate
> tight-binding dot as an operator vs space-surrounded dot as function
> composition. In particular so I can write `record.label` as field access.
> I'd also like to write `record.#label` as a TRex field access.)
>
> AntC
>
>
>
>
> _______________________________________________
> Hugs-Bugs mailing list
> [email protected]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/hugs-bugs

--0000000000002857c005c4bb4dc3
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi,<div><br></div><div>I don&#39;t not know that code eith=
er, but looking at the comments and the surrounding code, my guess is that =
the 2nd `c0` should be `c1`,</div><div>and it is checking for something lik=
e `.` followed by either a lower case or upper case or symbol=C2=A0operator=
.<br></div><div><br></div><div>-Iavor</div><div><br></div><div><br></div></=
div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">On=
 Mon, Jun 14, 2021 at 3:48 AM Anthony Clayden &lt;<a href=3D"mailto:anthony=
[email protected]">[email protected]</a>&gt; wrote:<br></div><=
blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l=
eft:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div clas=
s=3D"gmail_quote"><div dir=3D"ltr">(I can&#39;t say for sure I have a bug, =
because I don&#39;t grok the code well enough to figure out how to make som=
ething go wrong, but ...)<div><br></div><div>In /src/input.c line 1714=C2=
=A0<a href=3D"https://github.com/FranklinChen/hugs98-plus-Sep2006/blob/mast=
er/src/input.c#L1714" target=3D"_blank">https://github.com/FranklinChen/hug=
s98-plus-Sep2006/blob/master/src/input.c#L1714</a>,</div><div><br></div><di=
v>&gt;=C2=A0 =C2=A0=C2=A0<span style=3D"color:rgb(36,41,46);font-family:ui-=
monospace,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Liberation Mono=
&quot;,Menlo,monospace;font-size:12px;white-space:pre-wrap;background-color=
:rgb(255,251,221)">   </span><span style=3D"box-sizing:border-box;font-fami=
ly:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Liberatio=
n Mono&quot;,Menlo,monospace;font-size:12px;white-space:pre-wrap">if</span>=
<span style=3D"color:rgb(36,41,46);font-family:ui-monospace,SFMono-Regular,=
&quot;SF Mono&quot;,Consolas,&quot;Liberation Mono&quot;,Menlo,monospace;fo=
nt-size:12px;white-space:pre-wrap;background-color:rgb(255,251,221)"> (c0=
=3D=3D</span><span style=3D"box-sizing:border-box;font-family:ui-monospace,=
SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Liberation Mono&quot;,Men=
lo,monospace;font-size:12px;white-space:pre-wrap"><span style=3D"box-sizing=
:border-box">&#39;</span>.<span style=3D"box-sizing:border-box">&#39;</span=
></span><span style=3D"color:rgb(36,41,46);font-family:ui-monospace,SFMono-=
Regular,&quot;SF Mono&quot;,Consolas,&quot;Liberation Mono&quot;,Menlo,mono=
space;font-size:12px;white-space:pre-wrap;background-color:rgb(255,251,221)=
"> &amp;&amp; </span><span style=3D"box-sizing:border-box;font-family:ui-mo=
nospace,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Liberation Mono&q=
uot;,Menlo,monospace;font-size:12px;white-space:pre-wrap">isIn</span><span =
style=3D"color:rgb(36,41,46);font-family:ui-monospace,SFMono-Regular,&quot;=
SF Mono&quot;,Consolas,&quot;Liberation Mono&quot;,Menlo,monospace;font-siz=
e:12px;white-space:pre-wrap;background-color:rgb(255,251,221)">(c0,(SMALL|L=
ARGE|SYMBOL))) {</span></div><div><span style=3D"color:rgb(36,41,46);font-f=
amily:ui-monospace,SFMono-Regular,&quot;SF Mono&quot;,Consolas,&quot;Libera=
tion Mono&quot;,Menlo,monospace;font-size:12px;white-space:pre-wrap;backgro=
und-color:rgb(255,251,221)"><br></span></div><div><span style=3D"font-famil=
y:Arial,Helvetica,sans-serif">It looks wrong to be testing `c0` twice, that=
 test will always come out False. (Or if &#39;.&#39; counts as a SYMBOL, th=
en always True.) I guess the second test should be lookahead `isIn(c1, ...)=
`. That follows=C2=A0the code pattern nearby above line 1688, and especiall=
y 1698.</span></div><div><span style=3D"font-family:Arial,Helvetica,sans-se=
rif"><br></span></div><div><span style=3D"font-family:Arial,Helvetica,sans-=
serif">I think it&#39;ll mean the compiler won&#39;t handle multi-qualified=
 names like `Mod1.Sub2.Subsub3.Foo`. Whereas `Prelude.True` (just a single =
qualifier) is ok.</span></div><div><span style=3D"font-family:Arial,Helveti=
ca,sans-serif"><br></span></div><div><span style=3D"font-family:Arial,Helve=
tica,sans-serif">Can anyone confirm my suspicion and/or suggest a definitiv=
e test?</span></div><div><span style=3D"font-family:Arial,Helvetica,sans-se=
rif"><br></span></div><div><span style=3D"font-family:Arial,Helvetica,sans-=
serif">(Reason for asking: I&#39;m trying to persuade Hugs to differentiate=
 tight-binding dot as an operator vs space-surrounded dot as function compo=
sition. In particular so I can write `record.label` as field access. I&#39;=
d also like to write `record.#label` as a TRex field access.)</span></div><=
div><span style=3D"font-family:Arial,Helvetica,sans-serif"><br></span></div=
><div><span style=3D"font-family:Arial,Helvetica,sans-serif">AntC</span></d=
iv><div><span style=3D"font-family:Arial,Helvetica,sans-serif"><br></span><=
/div><div><span style=3D"font-family:Arial,Helvetica,sans-serif"><br></span=
></div><div><span style=3D"font-family:Arial,Helvetica,sans-serif"><br></sp=
an></div><div><br></div></div>
</div></div>
_______________________________________________<br>
Hugs-Bugs mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Hugs-Bugs@haskel=
l.org</a><br>
<a href=3D"http://mail.haskell.org/cgi-bin/mailman/listinfo/hugs-bugs" rel=
=3D"noreferrer" target=3D"_blank">http://mail.haskell.org/cgi-bin/mailman/l=
istinfo/hugs-bugs</a></blockquote></div>

--0000000000002857c005c4bb4dc3--

--===============1796213274045647837==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KSHVncy1CdWdz
IG1haWxpbmcgbGlzdApIdWdzLUJ1Z3NAaGFza2VsbC5vcmcKaHR0cDovL21haWwuaGFza2VsbC5v
cmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL2h1Z3MtYnVncw==

--===============1796213274045647837==--