develooper Front page | perl.perl6.language | Postings from September 2005

Re: Stringification, numification, and booleanification of pairs

Thread Previous | Thread Next
From:
TSa
Date:
September 23, 2005 10:11
Subject:
Re: Stringification, numification, and booleanification of pairs
Message ID:
4334373C.3040903@orthogon.com
Halo,

someone has switched off my echo ;)

Juerd wrote:
> TSa skribis 2005-09-23 15:42 (+0200):
> 
>>  1) the circumfix operator " " has an arity >= 1
> 
> 
> I think it's parsed, not having specific arity.

Of course it's parsed, how else should it reach the semantic analyzer?
And I don't consider (arity >= 1) as a very specific constraint :)
Actually the subtyping rules should distinguish between optional and
required arity with the latter beeing more specific. But I've no idea
what distance quantification they should have such that e.g. 5 optionals
are outperformed by one required or whatever.


>>  We have:  "foo" ~ $bar
>>  I see: a juxtaposition of two operators and an item,
>>         all three separated by whitespace
> 
> 
> I can only hope you mean two items and one operator.

So, at last there is hope somewhere. But I fear I'm hopelessly
drowned in my own misconceptions and really meant two ops and an
item. But I hope---ahh hope again---that the optimizer boils down
the "foo" invocation to 'foo' at compile time. Which immediately
raises the question whether I consider ' ' as an operator or not :)
Do you?

OTOH, I think we agree that a "foo $bar" is parametric with respect
to $bar and as such requires some code to evaluate it? The same applies
to matches /foo.*/ which are backed by some code that is build from
the text between the //. And how is this creation process of a match
closure parameterizable other then giving the resulting code a parameter
from which a new closure is created at runtime? And why is this not the
case for string interpolation? To a certain extent I see these two
closure manipulations as inverse operations. Interpolation creates
strings while matching analyzes them. But they don't guarranty mutual
round-trip invariance.

So the only thing that the language specification has to define in|for
my eyes is a level of unspecificity that the return value of " "
shouldn't exceed. In other words it's forced to return a Str and
nothing less specific like a Value or an Item. And then my mind
transforms the "foo" ~ $bar perception of my eyes into the mental
typing Str ~ Item.


Just ranting again a bit of my difficulties of integrating junctions
into my mental picture. How many times do you expect foo and ~ in

   "{foo}" ~ $bar

beeing called? Consider ($bar = 42) versus ($bar = any(1,2,3)).

In the latter case we expect the junctive value to contain something
like any( "{foo}" ~ 1, "{foo}" ~ 2, "{foo}" ~ 3 ), right? That might
interpolate "{foo}" once and call infix ~ three times, but what if
foo shall count the number of invocations of ~ on Ints? Not to mention
that the possibility of a junction in $bar means that it becomes a
potential postfix meta operator that swallows ~ and after analyzing
it as an infix operator reaches out---at runtime fully dynamic---and
pulls in the return value of "{foo}" three times, or perhaps calculates
it three times.
-- 
$TSa.greeting := "HaloO"; # mind the echo!

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About