"<->" as "->" with automatic "is rw"

I like that arguments will be readonly by default. But when I look at my
current code, I see that I would be typing " is rw" quite a lot, which in
my opinion is too long for a thing that occurs very often.

Every such situation in my code is a foreach loop. A thing that in Perl
6 will mostly be used with the pointy sub declaration syntax.

If I'm not mistaken, <-> is still available. It communicates
"bidirectional" and that is more or less the same as read/write access.

I'm proposing

    for zip(@foos, @bars, @xyzzies) <-> $foo, $bar, $xyzzy { ... }
    for %quux.kv <-> $key, $value { ... }

to mean

    for zip(@foos, @bars, @xyzzies) -> $foo is rw, $bar is rw, $xyzzy is rw { ... }
    for %quux.kv -> $key is rw, $value is rw { ... }

Comments, anyone?


Juerd
0
juerd
8/20/2004 8:07:02 PM
perl.perl6.language 6839 articles. 0 followers. Follow

7 Replies
1060 Views

Similar Articles

[PageSpeed] 51

On Fri, Aug 20, 2004 at 10:07:02PM +0200, Juerd wrote:
: I'm proposing
: 
:     for zip(@foos, @bars, @xyzzies) <-> $foo, $bar, $xyzzy { ... }
:     for %quux.kv <-> $key, $value { ... }

That'd probably work on the keys only if the hash was declared to have
object keys.  At least in Perl 5, the key is always a copy.

: to mean
: 
:     for zip(@foos, @bars, @xyzzies) -> $foo is rw, $bar is rw, $xyzzy is rw { ... }
:     for %quux.kv -> $key is rw, $value is rw { ... }
: 
: Comments, anyone?

It's really sick, and cute, and I love it.  Unfortunately I'm not sure
it passes the "Are there already too many ways to declare a sub?" test...

It's vaguely possible I could be persuaded on the basis that

    for zip @a � @b <-> { ($^a,$^b) = ($^b,$^a) }

could be made to work.  But I'm still dubious.  And arguably -> {...}
means the same as sub () {...}, implying there are no arguments.

Larry
0
larry
8/20/2004 8:31:12 PM
On Fri, 20 Aug 2004 13:31:12 -0700, Larry Wall <larry@wall.org> wrote:
> It's vaguely possible I could be persuaded on the basis that
>=20
>     for zip @a =A5 @b <-> { ($^a,$^b) =3D ($^b,$^a) }

Shouldn't that be:

    for zip @a, @b <-> { ... }
              --or--
    for @a =A5 @b <-> { ... }

?

--
matt
0
mddiep
8/20/2004 8:46:33 PM
On Fri, Aug 20, 2004 at 04:46:33PM -0400, Matt Diephouse wrote:
: On Fri, 20 Aug 2004 13:31:12 -0700, Larry Wall <larry@wall.org> wrote:
: > It's vaguely possible I could be persuaded on the basis that
: > 
: >     for zip @a � @b <-> { ($^a,$^b) = ($^b,$^a) }
: 
: Shouldn't that be:
: 
:     for zip @a, @b <-> { ... }
:               --or--
:     for @a � @b <-> { ... }
: 
: ?

Yes, a typo.  Though it's not actually clear yet whether you have to
write zips args with semicolons, which is why I partially switched
to � in midthink.

Larry
0
larry
8/20/2004 8:49:46 PM
On Fri, 20 Aug 2004 13:49:46 -0700, Larry Wall <larry@wall.org> wrote:
> Yes, a typo.  Though it's not actually clear yet whether you have to
> write zips args with semicolons, which is why I partially switched
> to =A5 in midthink.

Just checking. I wondered if you'd introduced a new feature midthink
(and I'd missed it).

--
matt
0
mddiep
8/20/2004 8:56:41 PM
On Fri, 20 Aug 2004, Larry Wall wrote:

> On Fri, Aug 20, 2004 at 10:07:02PM +0200, Juerd wrote:
> : I'm proposing
> :
> :     for zip(@foos, @bars, @xyzzies) <-> $foo, $bar, $xyzzy { ... }
> :     for %quux.kv <-> $key, $value { ... }
>
> That'd probably work on the keys only if the hash was declared to have
> object keys.  At least in Perl 5, the key is always a copy.
>
> : to mean
> :
> :     for zip(@foos, @bars, @xyzzies) -> $foo is rw, $bar is rw, $xyzzy i=
s rw { ... }
> :     for %quux.kv -> $key is rw, $value is rw { ... }
> :
> : Comments, anyone?
>
> It's really sick, and cute, and I love it.  Unfortunately I'm not sure
> it passes the "Are there already too many ways to declare a sub?" test...
>
> It's vaguely possible I could be persuaded on the basis that
>
>     for zip @a =A5 @b <-> { ($^a,$^b) =3D ($^b,$^a) }
>
> could be made to work.  But I'm still dubious.  And arguably -> {...}
> means the same as sub () {...}, implying there are no arguments.


Arguably it already means that.  But if <-> were added, it might be a good
reason to make -> {...} mean -> $_ {...}, using <-> {...} for -> $_ is rw
{...}.  A good way to remove one more special case (maybe offsetting the ex=
tra
way to declare a sub, and sweeten the whole deal).
--=20
Adam Lopresto
http://cec.wustl.edu/~adam/

Yesterday upon the stair
I met a man who wasn't there.
He wasn't there again today --
I think he's from the CIA.
0
adam
8/20/2004 9:17:11 PM
Larry Wall skribis 2004-08-20 13:31 (-0700):
> Unfortunately I'm not sure it passes the "Are there already too many
> ways to declare a sub?" test...

I'm not seeing it as another way. Technically, of course it is
different, but by the user, <-> and -> will probably be seen as one
thing, with one of them being the other's specialized form.

> It's really sick

Sick would be if <- were introduced to make the variable write-only ;)

         W   R
    @foos  -> $foo
    @foos <-> $foo
    @foos <-  $foo

It would be consistent, though...


Juerd
0
juerd
8/21/2004 10:08:01 AM
Juerd <juerd@convolution.nl> writes:

> Sick would be if <- were introduced to make the variable write-only ;)

Sicker still would be if - were introduced to make the variable
neither readable nor writeable.  HTH.HAND.

-- 
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,"ten.thgirb\@badanoj$/ --";$\=$ ;-> ();print$/

0
jonadab
8/22/2004 3:55:36 AM
Reply:

Similar Artilces:

Regular Expression to remove "/", "\", "<", ">" and "="
Can anyone please show me the regular expression to reject a string ("<blue", "right>" etc.) which has the following expression in it: "/", "\", "<", ">" and "="  hi, It may Help u.. it is in Class file u may use this expressin in validation controls also. Regex objReg = new Regex(@"^[^,.?/\~|`;:'<>]*$", RegexOptions.Singleline); Regex objReg = new Regex(@"^[^,][^.][^?][^/][^\][^~|][^`][^;][^:][^'][[^<][^>]$", RegexOptions.IgnoreCase);Thanks &...

What is this for? "<label style=""display:none;"" for=""" & cboFieldType.ClientID.ToString & """>Type</label>"
I'm digging through the code of DNN and I found many ocurrences of this type of code: lblFieldType.Text = "<label style=""display:none;"" for=""" & cboFieldType.ClientID.ToString & """>Type</label>" What is that code for? The label is never displayed and I could not figure out what DDN uses it for. thank you This is for ADA compliance. The guidelines require that form elements have an associated label. This helps the text readers out with identifying the different parts of the form. BruceDynamic...

what's the different from "<page src="">" and "<page codeBehind="">"
what's the different from "<page src="">" and "<page codeBehind="">" Thank YOU how to make session' life longer? Thank You This very question was asked only 5 days ago. Searching the forums would have yielded the answer you require. However, see this thread. Steven BeyRecursion: see Recursion You can set a new value for the Session Timeout in your web.config file. Or, you can do it in a page through this property: Session.Timeout Note that if you choose the second method, the timeout will only be modified on this page,...

Query performance of "=" vs "<" and ">"
Suppose you have a large table (>5 million records) containing 15 columns including a numerical string column called ACTIVITY_DATE which is indexed (nonunique, nonclustered) and a numerical string column called TIMESTAMP which is indexed (nonunique,nonclustered). ACTIVITY_DATE contains a date string ('20081211'); TIMESTAMP also appends a time ('20081211 19:18:03.34923'). Suppose you want to return all events that took place on December 11th and suppose you had to choose between the following queries: - select col1,col2,col3 from TABLE where ACTIVITY_DATE='2...

Query performance of "=" vs "<" and ">"
[This is a repost from ase.general] Suppose you have a large table (>5 million records) containing 15 columns including a numerical string column called ACTIVITY_DATE which is indexed (nonunique, nonclustered) and a numerical string column called TIMESTAMP which is indexed (nonunique,nonclustered). ACTIVITY_DATE contains a date string ('20081211'); TIMESTAMP also appends a time ('20081211 19:18:03.34923'). Suppose you want to return all events that took place on December 11th and suppose you had to choose between the following queries: - select col1,col2,col...

.ALLCOL("%COLUMN%", " ", ", ", ", ")
Do you know anyway for me to exclude a subset of columns returned by this function. We have two columns (rec_user and rec_datetime) which are in all of our tables, but when generating triggers I want automatically generate a script which does not include those two columns but does include all other columns in that table. Bruce I should add that I am using PD 9.0.0.580. Bruce "Bruce Lamb" <lamb.bruce@mayo.edu> wrote in message news:6HgI315nCHA.155@forums.sybase.com... > Do you know anyway for me to exclude a subset of columns returned by this > function. ...

Precedence of "where" ("of", "is", "will")?
Nobody on #perl6 today could answer this one. Is: Str | Int where { $_ } the same as: (Str | Int) where { $_ } or: Str | (Int where { $_ }) ? Followup questions, Mr. President: What kind of operators are "where", "of", "is", and "will"? Is there a reason that S03 doesn't list them? What are their precedence(s)? -- Chip Salzenberg - a.k.a. - <chip@pobox.com> Open Source is not an excuse to write fun code then leave the actual work to others. Chip Salzenberg writes: &...

quotes, quotes, quotes...
I am getting this error and I know what is causing it, but I have no idea how to fix it, any help would be great. The script steps through the /var/log/messages file on a linux server and puts The entries into a mysql database. However when it gets to the 'hlt' line in the messages file it just barfs. The single quotes are freaking it out. I know about quotes but not how to use in this situation. Thanks, Paul Error: May 27 17:53:00 localhost kernel: Checking 'hlt' instruction... OK. <----- doesn't like this in the messages file DBD::mysql::st exec...

Why is "<MyControl ... />" different to "<MyControl ...> </MyControl>"
Hi I have made a CompositeControl and had it working fine. The sequence of events was: Page -> Page_Load(), MyControl -> CreateChildControls(). This was fine because I had to set a certain property in my control during page load before CreateChildControls was called. Anyway.... suddenly it all stopped working and it turned out that the sequence of events changed to MyControl -> CreateChildControls(), Page -> Page_Load(). This caused it to blow up because the property was not set. After a few hours of pulling my hair out and undoing all the recent changes I had made it turns out...

No "Available layouts" to "Add>>" to "Active layouts"
I have US English, Russian and Ukrainian languages in Country/Region & Language. The list of "Available layouts" is empty, any suggestions what to do? Before I removed few packages using YAST, so probably I miss some package? -- magner58 ------------------------------------------------------------------------ > The list of "Available layouts" is empty, any suggestions what to do? i am confused....where are you seeing this "Available layouts"? is that in YaST System > Languages, or ??? -- DenverD (Linux Counter 282315)...

Difference between <%# Bind("") %> and <%# Eval("") %>
Occassionally, I will find myself using Bind and Eval interchangeable.  I am unclea or what is the exact difference.  Can someone shed some light?Thanks,X Friend, it is something like this Data-binding expressions are contained within <%# and %> delimiters and use the Eval and Bind functions. The Eval function is used to define one-way (read-only) binding. The Bind function is used for two-way (updatable) binding. In addition to calling Eval and Bind methods to perform data binding in a data-binding expression, you can call any publicly scoped code within the <%# and %...

"Web Site" versus New "Project" >> "Visual C#" >> "ASP.NET Web Application"?
What is the difference in creating a new "Web Site" versus New "Project" >> "Visual C#" >> "ASP.NET Web Application" ?  When and why should I use one over the other?  Thank you in advance and I look forward to your answers! Web Application Project is an addin to VS. There are a few differences but for the short answer, it uses more of an older 1.1 style for compilation and distribution.   So, I should use create Web Site? There's a detailed comparison here.Basically the difference is web application projects have a physical project file and resemble...

"Florian Ragwitz" <rafl@debian.org>, "Zefram" <zefram@fysh.org>, "Father Chrysostomos" <sprout@cpan.org>,
--0015175884b6a300aa04a8916f03 Content-Type: text/plain; charset=UTF-8 Howdy all. Bit of a slow week, as I didn't have net access for a couple of days. It was awful, and doesn't leave me with that much to report; But on the other hand, it was an awesome week - Midterm passed, the pad stuff got merged, and all the bugs in that started popping out. Fun : ) I'll follow up on that in another mail, so back to last week. With the pad merge, getting our and the error messages with scalar filehandles working done was only a few lines, which makes several TODO tests to pass;...

Bug in composer, HTML: "From " become ">From " ("&gt;From " in source)
Hi One of users of my extension send me a very strange bug report. > I think I may have found a bug. Was composing an email, and I saved it, and when I reopened it, there was the "greater than" character (HTML "&gt") inserted right before a capital F in the text: After tests I found this bug is not related to my extension, but to Thunderbird itself. Here are steeps required to reproduce this bug: 1) Open new HTML mail. 2) Type "From " (characters case and trailing space matters) 3) Press [CTRL+S], save in Drafts. 4) now go to Drafts, and ...

Web resources about - "<->" as "->" with automatic "is rw" - perl.perl6.language

Resources last updated: 12/28/2015 9:01:31 AM