[prev in list] [next in list] [prev in thread] [next in thread] 

List:       perl6-language
Subject:    EnumStr necessary for MAIN handling (was Fwd: [rakudo/rakudo] `MAIN`: `Str` arguments do not accept 
From:       Trey Ethan Harris <treyharris () gmail ! com>
Date:       2019-03-25 18:48:45
Message-ID: CALKJ+Et8sjqj2z2Z8NxYEPsaUPTSVx1xc+P-frWphQazzbsRAQ () mail ! gmail ! com
[Download RAW message or body]

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—though 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 <notifications@github.com>
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 <rakudo@noreply.github.com>

I think an 'EnumStr' is a requirement, actually, after considering this
example:

% ./cat-p6 *@*ARGS is ["cat-p6"]=== cat-p6 ===#!/usr/bin/env perl6
unit sub MAIN(*@files);
say '@*ARGS is ', @*ARGS.perl;
for @files -> $f {  say "=== $f ===";  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"]===
42 ===This is 42=== True ===This is True=== True ===This is True===
cat-p6 ===#!/usr/bin/env perl6
unit sub MAIN(*@files);
say '@*ARGS is ', @*ARGS.perl;
for @files -> $f {  say "=== $f ===";  put $f.IO.lines.join("\n");}===
hi ===This is hi

Without taking over @*ARG handling, it's impossible to access the file
named "Bool::True". That can't be right.

—
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 mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAF-Z2fX2ObnpCh9LaJ_0pP0YbHYYjQFks5vaRe9gaJpZM4cF0i0>
.

[Attachment #3 (text/html)]

<div dir="auto"><div dir="auto"><p \
style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:&quot;Helvetica \
Neue&quot;,Helvetica,&quot;Segoe \
UI&quot;,Arial,freesans,sans-serif;margin-top:0px!important">If one uses  <code \
style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">MAIN</code> \
with arguments, one simply cannot get strings like  <code \
style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">&quot;Bool::True&quot;</code> \
and  <code style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">&quot;True&quot;</code> \
from the command line into the same argument, regardless of whether one uses no type \
constraint, a  <code \
style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Str</code>, \
a  <code style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Str()</code>, \
or a slurpy. See the quote below from  <a \
href="https://github.com/rakudo/rakudo/issues/2794" \
style="box-sizing:border-box;background-color:transparent;word-wrap:break-word;word-break:break-all;color:rgb(65,131,196);text-decoration:none">rakudo \
#2794</a>  for an example.</p><p \
style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&quot;Helvetica \
Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif">I think a \
built-in  <code style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">EnumStr</code> \
Perl 6 type is necessary to fix this—though it&#39;s arguable that since CLI&#39;s \
are, for the most part, string-native, an argument type-constrained to  <code \
style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">Str</code> \
on  <code style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">MAIN</code> \
should get absolutely anything the shell hands it untouched.</p><p \
style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&quot;Helvetica \
Neue&quot;,Helvetica,&quot;Segoe UI&quot;,Arial,freesans,sans-serif">Are there any \
other candidate types  <code \
style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">MAIN</code>&#39;s \
parser reads that don&#39;t have allomorphic counterparts, or will  <code \
style="box-sizing:border-box;font-family:Consolas,&quot;Liberation \
Mono&quot;,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:3px;borde \
r-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px">EnumStr</code> \
fix the issue entirely?</p><p \
style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:&quot;Helvetica \
Neue&quot;,Helvetica,&quot;Segoe \
UI&quot;,Arial,freesans,sans-serif">Trey</p></div></div><div dir="auto"><br><div \
class="gmail_quote"><div dir="ltr" class="gmail_attr">---------- Forwarded message \
---------<br>From: <strong class="gmail_sendername" dir="auto">Trey Harris</strong> \
<span dir="ltr">&lt;<a href="mailto:notifications@github.com" \
target="_blank">notifications@github.com</a>&gt;</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 &lt;<a href="mailto:rakudo@noreply.github.com" \
target="_blank">rakudo@noreply.github.com</a>&gt;<br></div><br><p>I think an \
&#39;EnumStr&#39; is a requirement, actually, after considering this example:</p> \
<div class="m_2033308962394518632m_-4848503312443000882highlight \
m_2033308962394518632m_-4848503312443000882highlight-text-shell-session"><pre>% <span \
class="m_2033308962394518632m_-4848503312443000882pl-s1">./cat-p6 <span \
class="m_2033308962394518632m_-4848503312443000882pl-k">*</span></span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">@*ARGS is \
[&quot;cat-p6&quot;]</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">=== cat-p6 ===</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">#!/usr/bin/env perl6</span>

<span class="m_2033308962394518632m_-4848503312443000882pl-c1">unit sub \
MAIN(*@files);</span>

<span class="m_2033308962394518632m_-4848503312443000882pl-c1">say &#39;@*ARGS is \
&#39;, @*ARGS.perl;</span>

<span class="m_2033308962394518632m_-4848503312443000882pl-c1">for @files -&gt; $f \
{</span> <span class="m_2033308962394518632m_-4848503312443000882pl-c1">  say \
&quot;=== $f ===&quot;;</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">  put \
$f.IO.lines.join(&quot;\n&quot;);</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">}</span> % <span \
class="m_2033308962394518632m_-4848503312443000882pl-s1"><span \
class="m_2033308962394518632m_-4848503312443000882pl-k">for</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-smi">file</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-k">in</span> 42 hi True \
Bool::True<span class="m_2033308962394518632m_-4848503312443000882pl-k">;</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-k">do</span></span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">for&gt; echo &quot;This is \
$file&quot; &gt; $file</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">for&gt; done</span> % <span \
class="m_2033308962394518632m_-4848503312443000882pl-s1">ls</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">42  Bool::True  True  cat-p6 \
hi</span> % <span class="m_2033308962394518632m_-4848503312443000882pl-s1">./cat-p6 \
<span class="m_2033308962394518632m_-4848503312443000882pl-k">*</span></span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">@*ARGS is [&quot;42&quot;, \
&quot;Bool::True&quot;, &quot;True&quot;, &quot;cat-p6&quot;, &quot;hi&quot;]</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-c1">=== 42 ===</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-c1">This is 42</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-c1">=== True ===</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-c1">This is True</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-c1">=== True ===</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-c1">This is True</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-c1">=== cat-p6 ===</span> \
<span class="m_2033308962394518632m_-4848503312443000882pl-c1">#!/usr/bin/env \
perl6</span>

<span class="m_2033308962394518632m_-4848503312443000882pl-c1">unit sub \
MAIN(*@files);</span>

<span class="m_2033308962394518632m_-4848503312443000882pl-c1">say &#39;@*ARGS is \
&#39;, @*ARGS.perl;</span>

<span class="m_2033308962394518632m_-4848503312443000882pl-c1">for @files -&gt; $f \
{</span> <span class="m_2033308962394518632m_-4848503312443000882pl-c1">  say \
&quot;=== $f ===&quot;;</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">  put \
$f.IO.lines.join(&quot;\n&quot;);</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">}</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">=== hi ===</span> <span \
class="m_2033308962394518632m_-4848503312443000882pl-c1">This is \
hi</span></pre></div> <p>Without taking over <code>@*ARG</code> handling, it&#39;s \
impossible to access the file named <code>&quot;Bool::True&quot;</code>. That \
can&#39;t be right.</p>

<p style="font-size:small;color:#666">—<br>You are receiving this because you are \
subscribed to this thread.<br>Reply to this email directly, <a \
href="https://github.com/rakudo/rakudo/issues/2794#issuecomment-476326725" \
target="_blank">view it on GitHub</a>, or <a \
href="https://github.com/notifications/unsubscribe-auth/AAF-Z2fX2ObnpCh9LaJ_0pP0YbHYYjQFks5vaRe9gaJpZM4cF0i0" \
target="_blank">mute the thread</a>.<img \
src="https://github.com/notifications/beacon/AAF-Z84iuRLY-_jsN6yXlWQSbcGVGe88ks5vaRe9gaJpZM4cF0i0.gif" \
height="1" width="1" alt=""></p>

</div></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic