On Tue, Feb 15, 2005 at 05:49:44PM -0600, Rod Adams wrote:
> Damian Conway wrote:
> >
> >That would be disturbing if that's what happened.
> >C<say @what> is just a shorthand for C<print @what, "\n">.
> >So saying a junction is the same as printing it, which is a run-time 
> >error.
> 
> Could easily be achieved with a single layer of encapsulation?
> 
> perl6 -e "$x = 'cat'|'dog'; say1 $x; sub say1 ($x) {say $x}"
> 
> Or is the consensus that that's somehow not disturbing, and direct calls 
> are disturbing.

Here are some options in the absence of other syntactic modulation:
* No it's not disturbing nor is it surprising. You've written a routine
  that's not Junction-aware and you've given it a Junction thus
  triggering the autothreading behavior.
* As per Larry's earlier email, perhaps the assignment generates an
  error because you haven't asked for your mind to be warped that way.
* In my view of autothreading as a dangerous default, you get an error
  because C<say1()> isn't autothreaded and C<$x> parameter to C<say1()>
  is a Junction. Passing a Junction to C<say()> generates an error. 

You get the same behavior as that last one if the Any type is consistent
with the Junction type (which no one has yet commented on but makes
sense to me).  That would mean autothreading only happens on routines
with explicitly typed non-Junctionish parameters.

> If what you're saying is true, then feeding a junction into DBI for a
> "insert" statement, since the output proper is encapsulated, would
> create multiple new records in the database? I'm back to being very
> disturbed.

You're also making some assumptions that may not be true.  Using
existing DBI with perl6 should cause DBI to run with perl5 semantics
thus triggering an error if passed a Junction.  A perl6 DBI would
be written such that Junctions can't be put in places that don't want
them (at least that's how *I* would do it). 

For the case where a junction is stringified, I would imagine that the
Junction's C<str> or C<repr> (ala python) method gets called and it does
something appropriate.

Those are my assumptions.

> Patrick R. Michaud wrote:
> >OTOH, what happens with...?
> >
> >   sub nofun($x is rw) {
> >       $x += 2;
> >   }
> >
> >   $y = 3 | 4;
> >   nofun($y);

That's either an error ("Can't modify constant") or the same as 5|6.
The former makes the most sense to me at the moment.

-Scott
-- 
Jonathan Scott Duff
[EMAIL PROTECTED]

Reply via email to