How to restrict who may read my entries?
adverbial form of Pairs notation question
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > Perl web-programming > adverbial form of Pairs notation question 9 September 2008 19:32:41

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

adverbial form of Pairs notation question

Илья 9 September 2008 19:32:41
 Hello there,
what :foo<> should exactly produce?
At first I was expecting:
foo => ""
but in Rakudo:
foo => []
and it looks like the right thing on the other hand.

(I have started this topic in the November mail list
http://groups.googl­e.com/group/november­-wiki/browse_thread/­thread/939216e836f69­baa
)

Thank you.

Ilya
Vladivostok.pm
Add comment
Brandon S. Allbery KF8NH 6 September 2008 22:09:29 permanent link ]
 On 2008 Sep 6, at 13:57, Larry Wall wrote:
But basically I think NIL is a mild form of failure anyway, so it's
fine with me if () is a form of failure that is smart enough to be

I'm thinking () is the non-scalar (list, array, capture, maybe hash)
version of undef, which acts like a value unless you have warnings
turned on; and undef is managed as a kind of unthrown exception
already, thus so should ().

--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu­
electrical and computer engineering, carnegie mellon university KF8NH


Add comment
Damian Conway 8 September 2008 13:56:33 permanent link ]
 
On Sat, Sep 06, 2008 at 07:06:30PM +1100, Илья wrote:
: Hello there,
: what :foo<> should exactly produce?
: At first I was expecting:
: foo => ""
: but in Rakudo:
: foo => []
: and it looks like the right thing on the other hand.

At YAPC::EU I pointed out to Larry that we have an adverbial form that
defaults to true:

:foo

and one that defaults to false:

:!foo

but none that defaults to undef.

After rejecting my very reasonable suggestion of:

: foo

(;-)­ Larry then proposed that:

:foo()

should be identical to:

:foo(undef)

I mention this merely to point out that Larry's response in this thread seems
to revise that proposition somewhat, and I would like to suggest that, if
:foo() is now to mean something more sophisticated that :foo(undef), then we
should still find a "cheap" way of building adverbs with undef values.

Damian
Add comment
TSa 8 September 2008 19:02:41 permanent link ]
 HaloO,

Brandon S. Allbery KF8NH wrote:
On 2008 Sep 6, at 13:57, Larry Wall wrote:
But basically I think NIL is a mild form of failure anyway, so it's
fine with me if () is a form of failure that is smart enough to be
I'm thinking () is the non-scalar (list, array, capture, maybe hash)
version of undef, which acts like a value unless you have warnings
turned on; and undef is managed as a kind of unthrown exception already,
thus so should ().

I would strongly object to both of these statements on the footing that
~() eq '' and +() == 0 are the images of the neutral element of List in
two homomorphisms mapping the List type to Str and Int respectively. And
I believe we agree that neither '' nor 0 are forms of undef, right? Note
that there is no monoid of objects because there is no generic binary
operation on objects that corresponds to tilde, comma or plus.

To me undef means "outside of type" but () is definitely a list. It is
producing undef when indexed just as (1,2,3)[3] does where no one argues
that (1,2,3) is an undefined list of length 4 or some such.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
Mark J. Reed 8 September 2008 19:35:57 permanent link ]
 On Mon, Sep 8, 2008 at 11:08 AM, TSa <Thomas.Sandlass@vt­s-systems.de> wrote:
Sorry, what am I missing that I see no problem with List
always itemizing to an Array?

A List *does* always itemize to an Array. But parens do not a List
make; the discontinuity mentioned is syntactic.

(1,2,3) # (or longer) List
(1,2) # List
(1) # Item
() # ?

If () goes back to a List, then there's a double discontinuity in the
way parenthesized expressions are parsed.

On the other hand, there's just that sort of double discontinuity in
English pluralization, where we say "2 (or more) items", then "1
item", but then "no items". So perhaps it's justifiable in Perl6 as
well.

--
Mark J. Reed <markjreed@gmail.co­m>
Add comment
TSa 8 September 2008 19:36:54 permanent link ]
 HaloO,

Damian Conway wrote:
At YAPC::EU I pointed out to Larry that we have an adverbial form that
defaults to true:
:foo

For orthogonality and clarity purposes this could also be written

:?­foo


and one that defaults to false:
:!foo
but none that defaults to undef.
After rejecting my very reasonable suggestion of:
: foo
(;-)­ Larry then proposed that:
:foo()
should be identical to:
:foo(undef)

Yeah, but I think that the arrow form should then be

foo => undef

and not

foo => ()

because () should be a defined value that booleanizes to False,
numifies to 0 and stringifies to ''.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
TSa 8 September 2008 20:01:13 permanent link ]
 HaloO,

Mark J. Reed wrote:
On Mon, Sep 8, 2008 at 11:08 AM, TSa <Thomas.Sandlass@vt­s-systems.de> wrote:
Sorry, what am I missing that I see no problem with List
always itemizing to an Array?
A List *does* always itemize to an Array. But parens do not a List
make; the discontinuity mentioned is syntactic.
(1,2,3) # (or longer) List
(1,2) # List
(1) # Item
() # ?
If () goes back to a List, then there's a double discontinuity in the
way parenthesized expressions are parsed.

Ahh, I see. Thanks for the hint. It's actually comma that builds lists.
So we could go with () for undef and require (1,) and (,) for the single
element and empty list respectively. But then +(1,2,3,()) == 4.


On the other hand, there's just that sort of double discontinuity in
English pluralization, where we say "2 (or more) items", then "1
item", but then "no items". So perhaps it's justifiable in Perl6 as
well.

I would also opt for () meaning empty list as a *defined* value. Pairs
that shall receive the empty list as value could be abbreviated from
:foo(()) to :foo(,). As long as the distinction between Array and List
doesn't matter one can also say :foo[], of course.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
Jon Lang 8 September 2008 21:29:03 permanent link ]
 TSa wrote:
Ahh, I see. Thanks for the hint. It's actually comma that builds lists.
So we could go with () for undef and require (1,) and (,) for the single
element and empty list respectively. But then +(1,2,3,()) == 4.

Actually, note that both infix:<,> and circumfix:<[ ]> can be used to
build lists; so [1] and [] can be used to construct single-element and
empty lists, respectively.

On the other hand, there's just that sort of double discontinuity in
English pluralization, where we say "2 (or more) items", then "1
item", but then "no items". So perhaps it's justifiable in Perl6 as
well.
I would also opt for () meaning empty list as a *defined* value. Pairs
that shall receive the empty list as value could be abbreviated from
:foo(()) to :foo(,). As long as the distinction between Array and List
doesn't matter one can also say :foo[], of course.

Personally, I'd like to see '()' capture the concept of "nothing" in
the same way that '*' captures the concept of "whatever". There _may_
even be justification for differentiating between this and "something
that is undefined" (which 'undef' covers). Or not; I'm not sure of
the intricacies of this. One possibility might be that '1, 2, undef'
results in a three-item list '[1, 2, undef]', whereas '1, 2, ()'
results in a two-item list '[1, 2]' - but that may be a can of worms
that we don't want to open.

--
Jonathan "Dataweaver" Lang
Add comment
Mark J. Reed 8 September 2008 21:46:48 permanent link ]
 On Mon, Sep 8, 2008 at 1:29 PM, Jon Lang <dataweaver@gmail.c­om> wrote:
TSa wrote:
Ahh, I see. Thanks for the hint. It's actually comma that builds lists.
So we could go with () for undef and require (1,) and (,) for the single
element and empty list respectively. But then +(1,2,3,()) == 4.
Actually, note that both infix:<,> and circumfix:<[ ]> can be used to
build lists; so [1] and [] can be used to construct single-element and
empty lists, respectively.

It may be worth noting here that in Python, (1) is a scalar integer
value and (1,) is a tuple of length 1, but the empty tuple is
represented by commaless (). Thus len(()) is 0, len((,)) is a syntax
error, len((1,)) is 1, and len((1)) is a type error.

Also, all three of the empty tuple (), the empty list [], and the nil
value None are distinct from each other.

--
Mark J. Reed <markjreed@gmail.co­m>
Add comment
TSa 9 September 2008 19:32:41 permanent link ]
 HaloO,

Jon Lang wrote:
Actually, note that both infix:<,> and circumfix:<[ ]> can be used to
build lists; so [1] and [] can be used to construct single-element and
empty lists, respectively.

I doubt that. Actually, circumfix:<[ ]> builds arrays. And note that
there's no infix operator that concatenates arrays. '[1,2],[3,4]' is
a two element list. The closest you can get is '[1,2].push: [3,4]'
which preserves the identity of the first array whereas the lists
in infix<,> behave like values. I.e. the concatenated list has got
a new identity, not that of the left list.


Personally, I'd like to see '()' capture the concept of "nothing" in
the same way that '*' captures the concept of "whatever". There _may_
even be justification for differentiating between this and "something
that is undefined" (which 'undef' covers). Or not; I'm not sure of
the intricacies of this. One possibility might be that '1, 2, undef'
results in a three-item list '[1, 2, undef]', whereas '1, 2, ()'
results in a two-item list '[1, 2]' - but that may be a can of worms
that we don't want to open.

I see no can of worms. A *defined* () as "nothing" is just as well
defined as 0 is for addition of numbers or '' for string concatenation.
The thing that Larry's line of thought leads to is that

my $a = () // (1,2);

means that $x receives (1,2) not the "nothing" object. The question
that arises when comparing () to * is how polymorph () is:

my $b = 3 + (); # $b == 3?
my $c = 'ab' ~ (); # $c eq 'ab'?
my $d = 1,2 , (); # $d === (1,2)
my $e = 3 * (); # $e == 0?
my $f = 3 ** (); # $f == 1?
my $g = () ?? 1 !! 2; # $g == 2?
my $h; # $h === ()? scalar defaults to nothing

Do the Nothing and Whatever have unique IDs?

my %h;
%h{()} = "Nothing";
%h{*} = "Whatever";
%h{*+3} = "Whatever plus three";

I guess for hashes there is no slicing implied by the latter two cases,
so these would use the .WHICH to build the index.


Regards, TSa.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12 -- Srinivasa Ramanujan
Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > Perl web-programming > adverbial form of Pairs notation question 9 September 2008 19:32:41

see also:
AW: AW: Problem with identical object…
AW: Blanklines in zms 2.9 html-source
How to input the special character Оґ…
пройди тесты:
see also:
Free video converter with Two real-time…
Run Fatboy Run Movie Review, A son? Did…
Super DVD ripper upgrade to free Rip…

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .