EnumStr necessary for MAIN handling (was Fwd: [rakudo/rakudo] `MAIN`: `Str` arguments do not accept `True` or `False` (#2794))
[email protected] (Trey Ethan Harris) Mon, 25 Mar 2019 14:48:45 -0400
| Newsgroups | perl.perl6.language |
|---|---|
| Message-ID | <CALKJ+Et8sjqj2z2Z8NxYEPsaUPTSVx1xc+P-frWphQazzbsRAQ@mail.gmail.com> |
--000000000000214bc90584efa878 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable If one uses MAIN with arguments, one simply cannot get strings like "Bool::True" and "True" from the command line into the same argument, regardless of whether one uses no type constraint, a Str, a Str(), or a slurpy. See the quote below from rakudo #2794 <https://github.com/rakudo/rakudo/issues/2794> for an example. I think a built-in EnumStr Perl 6 type is necessary to fix this=E2=80=94tho= ugh it's arguable that since CLI's are, for the most part, string-native, an argument type-constrained to Str on MAIN should get absolutely anything the shell hands it untouched. Are there any other candidate types MAIN's parser reads that don't have allomorphic counterparts, or will EnumStr fix the issue entirely? Trey ---------- Forwarded message --------- From: Trey Harris <[email protected]> Date: Mon, Mar 25, 2019 at 14:38 Subject: Re: [rakudo/rakudo] `MAIN`: `Str` arguments do not accept `True` or `False` (#2794) To: rakudo/rakudo <[email protected]> I think an 'EnumStr' is a requirement, actually, after considering this example: % ./cat-p6 *@*ARGS is ["cat-p6"]=3D=3D=3D cat-p6 =3D=3D=3D#!/usr/bin/env pe= rl6 unit sub MAIN(*@files); say '@*ARGS is ', @*ARGS.perl; for @files -> $f { say "=3D=3D=3D $f =3D=3D=3D"; put $f.IO.lines.join("\n= ");} % for file in 42 hi True Bool::True; dofor> echo "This is $file" > $filefor> done % ls42 Bool::True True cat-p6 hi % ./cat-p6 *@*ARGS is ["42", "Bool::True", "True", "cat-p6", "hi"]=3D=3D=3D 42 =3D=3D=3DThis is 42=3D=3D=3D True =3D=3D=3DThis is True=3D=3D=3D True = =3D=3D=3DThis is True=3D=3D=3D cat-p6 =3D=3D=3D#!/usr/bin/env perl6 unit sub MAIN(*@files); say '@*ARGS is ', @*ARGS.perl; for @files -> $f { say "=3D=3D=3D $f =3D=3D=3D"; put $f.IO.lines.join("\n= ");}=3D=3D=3D hi =3D=3D=3DThis is hi Without taking over @*ARG handling, it's impossible to access the file named "Bool::True". That can't be right. =E2=80=94 You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <https://github.com/rakudo/rakudo/issues/2794#issuecomment-476326725>, or m= ute the thread <https://github.com/notifications/unsubscribe-auth/AAF-Z2fX2ObnpCh9LaJ_0pP0= YbHYYjQFks5vaRe9gaJpZM4cF0i0> . --000000000000214bc90584efa878 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div dir=3D"auto"><p style=3D"box-sizing:border-box;margi= n-bottom:16px;color:rgb(51,51,51);font-family:"Helvetica Neue",He= lvetica,"Segoe UI",Arial,freesans,sans-serif;margin-top:0px!impor= tant">If one uses=C2=A0<code style=3D"box-sizing:border-box;font-family:Con= solas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6000= 00381469727px;font-stretch:normal;line-height:normal;padding:0.2em 0px;marg= in:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;bo= rder-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left= -radius:3px">MAIN</code>=C2=A0with arguments, one simply cannot get strings= like=C2=A0<code style=3D"box-sizing:border-box;font-family:Consolas,"= Liberation Mono",Menlo,Courier,monospace;font-size:13.600000381469727p= x;font-stretch:normal;line-height:normal;padding:0.2em 0px;margin:0px;backg= round-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-rig= ht-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px"= >"Bool::True"</code>=C2=A0and=C2=A0<code style=3D"box-sizing:bord= er-box;font-family:Consolas,"Liberation Mono",Menlo,Courier,monos= pace;font-size:13.600000381469727px;font-stretch:normal;line-height:normal;= padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-= top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:= 3px;border-bottom-left-radius:3px">"True"</code>=C2=A0from the co= mmand line into the same argument, regardless of whether one uses no type c= onstraint, a=C2=A0<code style=3D"box-sizing:border-box;font-family:Consolas= ,"Liberation Mono",Menlo,Courier,monospace;font-size:13.600000381= 469727px;font-stretch:normal;line-height:normal;padding:0.2em 0px;margin:0p= x;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-= top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radi= us:3px">Str</code>, a=C2=A0<code style=3D"box-sizing:border-box;font-family= :Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.= 600000381469727px;font-stretch:normal;line-height:normal;padding:0.2em 0px;= margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3p= x;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-= left-radius:3px">Str()</code>, or a slurpy. See the quote below from=C2=A0<= a href=3D"https://github.com/rakudo/rakudo/issues/2794" style=3D"box-sizing= :border-box;background-color:transparent;word-wrap:break-word;word-break:br= eak-all;color:rgb(65,131,196);text-decoration:none">rakudo #2794</a>=C2=A0f= or an example.</p><p style=3D"box-sizing:border-box;margin-top:0px;margin-b= ottom:16px;color:rgb(51,51,51);font-family:"Helvetica Neue",Helve= tica,"Segoe UI",Arial,freesans,sans-serif">I think a built-in=C2= =A0<code style=3D"box-sizing:border-box;font-family:Consolas,"Liberati= on Mono",Menlo,Courier,monospace;font-size:13.600000381469727px;font-s= tretch:normal;line-height:normal;padding:0.2em 0px;margin:0px;background-co= lor:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radiu= s:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">EnumStr= </code>=C2=A0Perl 6 type is necessary to fix this=E2=80=94though it's a= rguable that since CLI's are, for the most part, string-native, an argu= ment type-constrained to=C2=A0<code style=3D"box-sizing:border-box;font-fam= ily:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:= 13.600000381469727px;font-stretch:normal;line-height:normal;padding:0.2em 0= px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius= :3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bott= om-left-radius:3px">Str</code>=C2=A0on=C2=A0<code style=3D"box-sizing:borde= r-box;font-family:Consolas,"Liberation Mono",Menlo,Courier,monosp= ace;font-size:13.600000381469727px;font-stretch:normal;line-height:normal;p= adding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-t= op-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3= px;border-bottom-left-radius:3px">MAIN</code>=C2=A0should get absolutely an= ything the shell hands it untouched.</p><p style=3D"box-sizing:border-box;m= argin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:"Helv= etica Neue",Helvetica,"Segoe UI",Arial,freesans,sans-serif">= Are there any other candidate types=C2=A0<code style=3D"box-sizing:border-b= ox;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace= ;font-size:13.600000381469727px;font-stretch:normal;line-height:normal;padd= ing:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-= left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;= border-bottom-left-radius:3px">MAIN</code>'s parser reads that don'= t have allomorphic counterparts, or will=C2=A0<code style=3D"box-sizing:bor= der-box;font-family:Consolas,"Liberation Mono",Menlo,Courier,mono= space;font-size:13.600000381469727px;font-stretch:normal;line-height:normal= ;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border= -top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius= :3px;border-bottom-left-radius:3px">EnumStr</code>=C2=A0fix the issue entir= ely?</p><p style=3D"box-sizing:border-box;margin-top:0px;margin-bottom:16px= ;color:rgb(51,51,51);font-family:"Helvetica Neue",Helvetica,"= ;Segoe UI",Arial,freesans,sans-serif">Trey</p></div></div><div dir=3D"= auto"><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">= ---------- Forwarded message ---------<br>From: <strong class=3D"gmail_send= ername" dir=3D"auto">Trey Harris</strong> <span dir=3D"ltr"><<a href=3D"= mailto:[email protected]" target=3D"_blank">[email protected]= </a>></span><br>Date: Mon, Mar 25, 2019 at 14:38<br>Subject: Re: [rakudo= /rakudo] `MAIN`: `Str` arguments do not accept `True` or `False` (#2794)<br= >To: rakudo/rakudo <<a href=3D"mailto:[email protected]" target= =3D"_blank">[email protected]</a>><br></div><br><p>I think an &#= 39;EnumStr' is a requirement, actually, after considering this example:= </p> <div class=3D"m_2033308962394518632m_-4848503312443000882highlight m_203330= 8962394518632m_-4848503312443000882highlight-text-shell-session"><pre>% <sp= an class=3D"m_2033308962394518632m_-4848503312443000882pl-s1">./cat-p6 <spa= n class=3D"m_2033308962394518632m_-4848503312443000882pl-k">*</span></span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">@*ARGS is = ["cat-p6"]</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">=3D=3D=3D = cat-p6 =3D=3D=3D</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">#!/usr/bin= /env perl6</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">unit sub M= AIN(*@files);</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">say '@= *ARGS is ', @*ARGS.perl;</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">for @files= -> $f {</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1"> say &quo= t;=3D=3D=3D $f =3D=3D=3D";</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1"> put $f.I= O.lines.join("\n");</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">}</span> % <span class=3D"m_2033308962394518632m_-4848503312443000882pl-s1"><span cl= ass=3D"m_2033308962394518632m_-4848503312443000882pl-k">for</span> <span cl= ass=3D"m_2033308962394518632m_-4848503312443000882pl-smi">file</span> <span= class=3D"m_2033308962394518632m_-4848503312443000882pl-k">in</span> 42 hi = True Bool::True<span class=3D"m_2033308962394518632m_-4848503312443000882pl= -k">;</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-k= ">do</span></span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">for> ec= ho "This is $file" > $file</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">for> do= ne</span> % <span class=3D"m_2033308962394518632m_-4848503312443000882pl-s1">ls</span= > <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">42 Bool::= True True cat-p6 hi</span> % <span class=3D"m_2033308962394518632m_-4848503312443000882pl-s1">./cat-p6= <span class=3D"m_2033308962394518632m_-4848503312443000882pl-k">*</span></= span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">@*ARGS is = ["42", "Bool::True", "True", "cat-p6&quo= t;, "hi"]</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">=3D=3D=3D = 42 =3D=3D=3D</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">This is 42= </span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">=3D=3D=3D = True =3D=3D=3D</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">This is Tr= ue</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">=3D=3D=3D = True =3D=3D=3D</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">This is Tr= ue</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">=3D=3D=3D = cat-p6 =3D=3D=3D</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">#!/usr/bin= /env perl6</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">unit sub M= AIN(*@files);</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">say '@= *ARGS is ', @*ARGS.perl;</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">for @files= -> $f {</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1"> say &quo= t;=3D=3D=3D $f =3D=3D=3D";</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1"> put $f.I= O.lines.join("\n");</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">}</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">=3D=3D=3D = hi =3D=3D=3D</span> <span class=3D"m_2033308962394518632m_-4848503312443000882pl-c1">This is hi= </span></pre></div> <p>Without taking over <code>@*ARG</code> handling, it's impossible to = access the file named <code>"Bool::True"</code>. That can't b= e right.</p> <p style=3D"font-size:small;color:#666">=E2=80=94<br>You are receiving this= because you are subscribed to this thread.<br>Reply to this email directly= , <a href=3D"https://github.com/rakudo/rakudo/issues/2794#issuecomment-4763= 26725" target=3D"_blank">view it on GitHub</a>, or <a href=3D"https://githu= b.com/notifications/unsubscribe-auth/AAF-Z2fX2ObnpCh9LaJ_0pP0YbHYYjQFks5vaR= e9gaJpZM4cF0i0" target=3D"_blank">mute the thread</a>.<img src=3D"https://g= ithub.com/notifications/beacon/AAF-Z84iuRLY-_jsN6yXlWQSbcGVGe88ks5vaRe9gaJp= ZM4cF0i0.gif" height=3D"1" width=3D"1" alt=3D""></p> </div></div> --000000000000214bc90584efa878--