Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Quick question: parens vs subroutine parameter
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Larry Wall  
View profile  
 More options Apr 20 2005, 4:30 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Wed, 20 Apr 2005 13:30:38 -0700
Local: Wed, Apr 20 2005 4:30 pm
Subject: Re: Quick question: parens vs subroutine parameter
On Wed, Apr 20, 2005 at 10:23:14PM +0200, Juerd wrote:

: Autrijus Tang skribis 2005-04-21  4:19 (+0800):
: > So, following up on the Parens handling, are these two equivalent?
: >     # Assuming &is has the parameter signature (Str, Str, Str)
: >     is((1,2), (3,4), "hey");
: >     is([1,2], [3,4], "hey");
:
: I think so.
:
: > What happens if &is is of type (Any, Any, Str)?
:
: Same thing, as the inner comma is still in scalar context.
:
: However, with list context, I expect things to flatten, so with a
: signature of *@_, it puts 5 elements in @_.

That's all correct.

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juerd  
View profile  
 More options Apr 20 2005, 4:23 pm
Newsgroups: perl.perl6.language
From: ju...@convolution.nl (Juerd)
Date: Wed, 20 Apr 2005 22:23:14 +0200
Local: Wed, Apr 20 2005 4:23 pm
Subject: Re: Quick question: parens vs subroutine parameter
Autrijus Tang skribis 2005-04-21  4:19 (+0800):

> So, following up on the Parens handling, are these two equivalent?
>     # Assuming &is has the parameter signature (Str, Str, Str)
>     is((1,2), (3,4), "hey");
>     is([1,2], [3,4], "hey");

I think so.

> What happens if &is is of type (Any, Any, Str)?

Same thing, as the inner comma is still in scalar context.

However, with list context, I expect things to flatten, so with a
signature of *@_, it puts 5 elements in @_.

Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html
http://convolution.nl/gajigu_juerd_n.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Autrijus Tang  
View profile  
 More options Apr 20 2005, 4:19 pm
Newsgroups: perl.perl6.language
From: autri...@autrijus.org (Autrijus Tang)
Date: Thu, 21 Apr 2005 04:19:51 +0800
Local: Wed, Apr 20 2005 4:19 pm
Subject: Quick question: parens vs subroutine parameter

So, following up on the Parens handling, are these two equivalent?

    # Assuming &is has the parameter signature (Str, Str, Str)
    is((1,2), (3,4), "hey");
    is([1,2], [3,4], "hey");

What happens if &is is of type (Any, Any, Str)?

Thanks,
/Autrijus/

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Juerd  
View profile  
 More options Apr 20 2005, 5:28 pm
Newsgroups: perl.perl6.language
From: ju...@convolution.nl (Juerd)
Date: Wed, 20 Apr 2005 23:28:23 +0200
Local: Wed, Apr 20 2005 5:28 pm
Subject: Re: Quick question: parens vs subroutine parameter
Autrijus asked me to summarize here what I said on IRC #perl6, and ask
Larry for another "that's all correct".

I've rephrased everything as facts/assumptions.

Array context, as provided by a signature of "Array $foo", is still
a form of scalar context, even though Array.isa(List).

    Array is a class here.

    Classes when used for context expect objects.

    Objects are references.

    Array implies ref.

    The main contexts, void, scalar and list, have nothing to do with
    types.

    Scalar context can expect a certain type of value, for example, an
    Array or a Dog.

    List context can also expect a certain type of values for its
    elements.

Somewhere during our conversation, I suggested renaming scalar and list
context to singular and plural context, to avoid all the confusion.

Void context still exists and is not a form of singular or plural
context. Perhaps this should be called nullar context, although void
context works equally well for me and is not confusing because we have
no Void type.

When we really want a scalar (the thing itself), we call that Any
context or Scalar context, both forms of singular context (formerly
called scalar context).

What exactly is the difference between Scalar and Any?

Juerd
--
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html
http://convolution.nl/gajigu_juerd_n.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile  
 More options Apr 20 2005, 9:26 pm
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Wed, 20 Apr 2005 18:26:08 -0700
Local: Wed, Apr 20 2005 9:26 pm
Subject: Re: Quick question: parens vs subroutine parameter
On Wed, Apr 20, 2005 at 11:28:23PM +0200, Juerd wrote:

: Autrijus asked me to summarize here what I said on IRC #perl6, and ask
: Larry for another "that's all correct".
:
: I've rephrased everything as facts/assumptions.
:
: Array context, as provided by a signature of "Array $foo", is still
: a form of scalar context, even though Array.isa(List).

I don't think Array.isa(List).  I think List.isa(Array of Generator),
and Array.maybehasa(List) stored under it's .specs property for generating
more values of the Array if you run off the end of the existing elements.

:     Array is a class here.

Yes.

:     Classes when used for context expect objects.

If by "context" you mean variable declaration, then yes.

:     Objects are references.

Objects are blessed referents, just as in Perl 5.  It's just that most
such referents are an opaque type now.  I think what you're trying
to say here is that Real Objects™ are never value types, which is true.
Objects are always accessed through references, as in Perl 5.

:     Array implies ref.

Yes, though people don't have to realize that when they say @foo[$bar].

:     The main contexts, void, scalar and list, have nothing to do with
:     types.

That's a slight overstatement, but mostly true.

:     Scalar context can expect a certain type of value, for example, an
:     Array or a Dog.

Yes.

:     List context can also expect a certain type of values for its
:     elements.

Right.

: Somewhere during our conversation, I suggested renaming scalar and list
: context to singular and plural context, to avoid all the confusion.

I often talk about them in those terms, but I'd hate to have to type
"singular" instead of "scalar" or "plural" instead of "list" all the time.

: Void context still exists and is not a form of singular or plural
: context. Perhaps this should be called nullar context, although void
: context works equally well for me and is not confusing because we have
: no Void type.

So let's get just rid of Scalar and List types.

: When we really want a scalar (the thing itself), we call that Any
: context or Scalar context, both forms of singular context (formerly
: called scalar context).
:
: What exactly is the difference between Scalar and Any?

Isn't any, that I can tell.  So maybe we settle on Any for the type
and scalar() for the function/concept.  It'd be nice if we could
unify those somehow, but any() is taken.  Maybe Item/item().

Likewise, there's really no such thing as a List.  The basic list types
are actually Eager and Lazy, and an Array conveniently contains one of each.

Larry


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
"TSa (Thomas Sandlaß)"  
View profile  
 More options May 13 2005, 1:13 pm
Newsgroups: perl.perl6.language
From: Thomas.Sandl...@orthogon.com ("TSa (Thomas Sandlaß)")
Date: Fri, 13 May 2005 19:13:53 +0200
Local: Fri, May 13 2005 1:13 pm
Subject: Re: Quick question: parens vs subroutine parameter

Larry Wall wrote:
> : Void context still exists and is not a form of singular or plural
> : context. Perhaps this should be called nullar context, although void
> : context works equally well for me and is not confusing because we have
> : no Void type.

Nice, without Void we don't need the double headed
pseudo type lattice needed if we were to distinguish
subs that return no usefull---that is Any---value
from the ones that return no value at all.

> So let's get just rid of Scalar and List types.

How does that go with the distinction between the container
and content type/class? Are all variables then implemented
with Parrot level refs/pointers/PMCs and there is no need for
a single element container class? Actually I would appreciate
this.

With the idea of the Perl6 type system having a type lattice
and | meaning LUB (lowest upper bound) the apex of which would
be Any.

::Any ::= Str | Num | Ref of Any | Array of Any | Hash of Any | ...

The ... is dynamically updated whenever a new toplevel type
is added: Any ::= Any | TheNewType.

How do we name the bottom Type? None? All? The latter would
nicely relate it to the & as the GLB (greatest lower bound).
But OTOH, None feels more natural and is e.g. used by the
Cecil folks as well.

> : When we really want a scalar (the thing itself), we call that Any
> : context or Scalar context, both forms of singular context (formerly
> : called scalar context).

BTW, context is not meaningfull at runtime but only defines what
code the compiler generates? E.g. list context would be compiled
to some code that gathers the values from the involved expressions,
subs and constants---into what? An Array?

> : What exactly is the difference between Scalar and Any?
> Isn't any, that I can tell.  So maybe we settle on Any for the type
> and scalar() for the function/concept.
>  It'd be nice if we could
> unify those somehow, but any() is taken.  Maybe Item/item().

Just ideas from me for:
   no value: void, zero
  one value: mono, unary
   >1 value: poly, many
--
TSa (Thomas Sandlaß)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "The Void type" by Rod Adams
Rod Adams  
View profile  
 More options May 13 2005, 8:31 pm
Newsgroups: perl.perl6.language
From: r...@rodadams.net (Rod Adams)
Date: Fri, 13 May 2005 19:31:23 -0500
Local: Fri, May 13 2005 8:31 pm
Subject: Re: The Void type

Can't we just say :

    Void =:= none(Any)

and get Void for near free?

-- Rod Adams


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Autrijus Tang  
View profile  
 More options May 13 2005, 8:20 pm
Newsgroups: perl.perl6.language
From: autri...@autrijus.org (Autrijus Tang)
Date: Sat, 14 May 2005 08:20:06 +0800
Local: Fri, May 13 2005 8:20 pm
Subject: The Void type

On Fri, May 13, 2005 at 07:13:53PM +0200, "TSa (Thomas Sandlaß)" wrote:
> Larry Wall wrote:
> >: Void context still exists and is not a form of singular or plural
> >: context. Perhaps this should be called nullar context, although void
> >: context works equally well for me and is not confusing because we have
> >: no Void type.

> Nice, without Void we don't need the double headed
> pseudo type lattice needed if we were to distinguish
> subs that return no usefull---that is Any---value
> from the ones that return no value at all.

Hrm.  So if I have a sub that does nothing:

    sub Foo { }

Is it illegal to say this?

    sub Foo returns Void { }

What about:

    sub Foo returns :() { }

Or do I really need to convert it to this?

    sub Foo returns Any { }

Thanks,
/Autrijus/

  application_pgp-signature_part
< 1K Download

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »