Re: what I meant about hungarian notation

2001-05-14 Thread Michael G Schwern

On Sun, May 13, 2001 at 11:37:01PM -0500, Me wrote:
 Yes. But I'm not sure that:
 
 # ordered
 @array = (1, 2, 3, 5, 8);
 
 # unordered
 %hash = (Fred = 22, Jane = 30);
 
 is more or less typical than:
 
   # unordered:
   @array = ('England', 'France', 'Germany');
 
   # ordered:
   %hash = (Name = 'Ralph',

You're right, the want of an ordered hash is common, but definately
not in the majority (and its quite a bit slower and eats more memory).
There have been numerous proposals for giving various easy ways to
declare the sort order for a hash.  http://dev.perl.org/rfc/124.pod is
one.  The idea of variable attributes is another.

When all the smoke clears, it will be relatively simple to declare an
ordered hash probably on the order of adding a single word to its
declaration.  Whipping up a storm about it is unnecessary.


 11 normal people (perl beginners) have responded
 to this so far.

While there is merit in taking beginners's needs into account, it is
not wise when designing a language to alter features just for
beginners.  As elitist as this may sound, they are beginners and will
advocate short-term solutions.  They don't quite know what works best
in the long run.

Also, I don't equate beginners with normal (perhaps loud).  After
all, beginners don't stay beginners for long.  For every beginner now
there will be one less in a year (either they've gotten better or
they're doing something else).  The only new font of beginners is
brand-new programmers.  Again, they should be taken into account and
the learning curve banked for speed as much as possible, but you don't
design a language around them.

For most of your programming life, you are not a beginner.

Anyhow, this is how you get things like BASIC.

(PS  11 people isn't a statistic, its a night at the pub)


-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl6 Quality Assurance [EMAIL PROTECTED]   Kwalitee Is Job One
Maybe they hooked you up with one of those ass-making magazines.
-- brian d. foy as misheard by Michael G Schwern



Re: Apoc2 - STDIN concerns

2001-05-14 Thread Bart Lateur

On Thu, 10 May 2001 17:15:09 +0100, Simon Cozens wrote:

 What you could do, is treat an iterator as something similar to reading
 a line from a file. Tied filehandles allow something like it in Perl5.

You know, if what you say is true, I'd expect to find a module on CPAN which
turns the exotic 'each' function into the friendly tied filehandle model.
But I don't see one. I think people are less confused by all this than you
imagine. :)

Perhaps it's because the people who are capable of writing such a
module, are the ones who don't need it. But, not everyone is a conway.

There must be some reason why a language like Sather isn't more popular.
I think that iters are part of the problem.

-- 
Bart.



Re: Apoc2 - STDIN concerns

2001-05-14 Thread Simon Cozens

On Mon, May 14, 2001 at 01:25:51PM +0200, Bart Lateur wrote:
 There must be some reason why a language like Sather isn't more popular.
 I think that iters are part of the problem.

That smacks of the Politician's Syllogism:
Something is wrong.
This is something.
Therefore this is wrong.

I think the more immediate problem with Sather is that it's totally obscure.
I'd never heard of it. I'd never read any articles about it. It has no
publicity. If people haven't heard of it, it'll remain unpopular.

Iters or no iters.

-- 
yrlnry I think the real problem here is that he is a university CS
professor and therefore knows very little about programming in the real
world, in any languge.



Re: what I meant about hungarian notation

2001-05-14 Thread Me

 an ordered hash is common

Arrays too.


 not wise ... to alter features just for beginners.

Agreed.


 (PS  11 people isn't a statistic, its a night at the pub)

Your round...


The extra complexity of a separate hash syntax might
be justified for other reasons, but not the ones given.

No storm intended, but I think it is sometimes right
to rebutt errors in current perceived wisdom.

Especially if the error has a significant effect.

This is one of those times.




Re: what I meant about hungarian notation

2001-05-14 Thread Graham Barr

On Mon, May 14, 2001 at 12:32:37PM -0500, Me wrote:
  an ordered hash is common
 
 Arrays too.
 
 
  not wise ... to alter features just for beginners.
 
 Agreed.
 
 
  (PS  11 people isn't a statistic, its a night at the pub)
 
 Your round...
 
 
 The extra complexity of a separate hash syntax might
 be justified for other reasons, but not the ones given.

Hm, OK. What does this access and using what method ?

  $foo = '1.2';
  @bar[$foo];

Does it access the hash element 1.2 or the array element 1 ?

Its not obvious and you cannot depend on what is in $foo, $foo = 1.2
should give identical results. and having to write

  @bar[$foo] or @bar[int $foo]

is worse than what we have now. And solving this by saying that
each variable must be declared to be hash or array does not help
much as it moves the distinction from where it is useful to the
reader to somewhere out of site.

Having different brackets for accessing array or hash actually does
help when reading code. Using the same is just adding unnecessary
complexity

Graham.



Re: what I meant about hungarian notation

2001-05-14 Thread Me

 Hm, OK. What does this access and using what method ?
 
   $foo = '1.2';
   @bar[$foo];

This is an argument against conflating @ and %.

It has nothing to do with using [] instead of {}.

(I accept that the @/% issue is problematic. Otoh,
I don't yet see @/% conflation as being obviously
a bad move in the way you and Larry seem to.)

 Having different brackets for accessing array or hash
 actually does help when reading code. Using the same
 is just adding unnecessary complexity

I can't tell if you mean this as a summary of your
earlier points, in which case please note response
above, or a separate point. If it is a separate point,
you don't say why, so, why?




Re: what I meant about hungarian notation

2001-05-14 Thread Graham Barr

On Mon, May 14, 2001 at 01:56:01PM -0500, Me wrote:
  Hm, OK. What does this access and using what method ?
  
$foo = '1.2';
@bar[$foo];
 
 This is an argument against conflating @ and %.

No it is not.

 It has nothing to do with using [] instead of {}.

Yes it does. I was asking if the above is equivalent to

  $bar[$foo]  or  $bar{$foo}  in todays perl.

  Having different brackets for accessing array or hash
  actually does help when reading code. Using the same
  is just adding unnecessary complexity
 
 I can't tell if you mean this as a summary of your
 earlier points, in which case please note response
 above, or a separate point. If it is a separate point,
 you don't say why, so, why?

I mean exactly what it says. Not using [] instead of {}
actually helps with readability.

Graham.



Re: what I meant about hungarian notation

2001-05-14 Thread Graham Barr

On Mon, May 14, 2001 at 03:23:56PM -0400, Buddha Buck wrote:
 At 08:10 PM 05-14-2001 +0100, Graham Barr wrote:
 On Mon, May 14, 2001 at 01:56:01PM -0500, Me wrote:
Hm, OK. What does this access and using what method ?
   
  $foo = '1.2';
  @bar[$foo];
  
   This is an argument against conflating @ and %.
 
 No it is not.
 
   It has nothing to do with using [] instead of {}.
 
 Yes it does. I was asking if the above is equivalent to
 
$bar[$foo]  or  $bar{$foo}  in todays perl.
 
 What is the meaning of the following four expressions in Perl6?
 
 @bar[$foo]; # A
 %bar{$foo}; # B
 @bar{$foo}; # C
 %bar[$foo]; # D
 
 You seem to be advocating A and B, Me is advocating A and D.
 
 Why is one set better than the other?

You forgot

 $bar[$foo]; # $bar is an array reference
 $bar{$foo}; # $bar is a hash reference

Graham.



Re: what I meant about hungarian notation

2001-05-14 Thread John Porter

Damian Conway wrote [and John Porter reformats]:
  
 @bar[$foo]; # Access element int($foo) of array @bar
 %bar{$foo}; # Access entry $foo of hash %bar
 @bar{$foo}; # Syntax error
 %bar[$foo]; # Syntax error

And why is that superior to:

  @bar[$foo]; # Access element int($foo) of array @bar
  %bar{$foo}; # Syntax error
  @bar{$foo}; # Syntax error
  %bar[$foo]; # Access entry $foo of hash %bar

???

-- 
John Porter




Re: what I meant about hungarian notation

2001-05-14 Thread Damian Conway

When all the smoke clears, it will be relatively simple to declare an
ordered hash probably on the order of adding a single word to its
declaration.  

Yep. In fact, it's now relatively simple in Perl 5.

You just grab the Attribute::Handlers and Tie::SortHash modules and
add a single line to your program:

use Attribute::Handlers autotie = { Sorted = 'Tie::SortHash' };

Then you can write:

my %hash : Sorted;

or:

my %hash : Sorted({}, sub { $hash{$b} cmp $hash{$a}});

etc.

Damian

PS: Casey, if you'd like to make that even easier for users of your 
excellent module, send me some email.



Re: what I meant about hungarian notation

2001-05-14 Thread Graham Barr

On Mon, May 14, 2001 at 03:41:24PM -0400, John Porter wrote:
 Damian Conway wrote [and John Porter reformats]:
   
  @bar[$foo]; # Access element int($foo) of array @bar
  %bar{$foo}; # Access entry $foo of hash %bar
  @bar{$foo}; # Syntax error
  %bar[$foo]; # Syntax error
 
 And why is that superior to:
 
   @bar[$foo]; # Access element int($foo) of array @bar
   %bar{$foo}; # Syntax error
   @bar{$foo}; # Syntax error
   %bar[$foo]; # Access entry $foo of hash %bar

As I said in another mail, consider

  $bar[$foo];
  $bar{$foo};

Graham.



Re: what I meant about hungarian notation

2001-05-14 Thread Me

  @bar[$foo]; # A
  %bar{$foo}; # B
  @bar{$foo}; # C
  %bar[$foo]; # D
  
 You forgot
 
  $bar[$foo]; # $bar is an array reference
  $bar{$foo}; # $bar is a hash reference

I can't argue with that.

My vote is now against conflating [] and {}.

---

Please bear with me just a (hoefully little) longer.

Ok, why not deprecate %foo and always use @
instead and have [] and {} represent two indexing
name spaces?

In perl 6 experiments, and perl 7, you'll have % to
play with.




Re: what I meant about hungarian notation

2001-05-14 Thread John Porter

Graham Barr wrote:
 As I said in another mail, consider
   $bar[$foo];
   $bar{$foo};

But if @bar is known to be one kind of array or
the other, where is the ambiguosity that that is
meant to avoid?

-- 
John Porter




Re: what I meant about hungarian notation

2001-05-14 Thread Graham Barr

On Mon, May 14, 2001 at 03:58:31PM -0400, John Porter wrote:
 Graham Barr wrote:
  As I said in another mail, consider
$bar[$foo];
$bar{$foo};
 
 But if @bar is known to be one kind of array or
 the other, where is the ambiguosity that that is
 meant to avoid?

I did not say it was avoiding ambuguity, I said it helped
with readability when $foo held something like 1.2

But I really think this thread is going no where.

Is there REALLY a benefit in changing things to use only []
or is this change for the sake of change.

And rememeber this is still perl, so why change something unless
it gains extra benefit.

Graham.



Re: what I meant about hungarian notation

2001-05-14 Thread Graham Barr

On Mon, May 14, 2001 at 02:51:08PM -0500, Me wrote:
  survey ? I never saw any survey, 
 
 It was an informal finger-in-the-wind thing I sent to
 a perl beginners list. Nothing special, just a quick
 survey.
 
 http://www.self-reference.com/cgi-bin/perl6plurals.pl

As someone else pointed out (I forget who). But beginners are not
always the best people to ask. Beginner don't stay beginners for
long I think the quote was.

Graham.



Re: what I meant about hungarian notation

2001-05-14 Thread Bart Lateur

On Mon, 14 May 2001 20:38:31 +0100, Graham Barr wrote:

You forgot

 $bar[$foo]; # $bar is an array reference
 $bar{$foo}; # $bar is a hash reference

As to what the combined

$bar[$foo]

would mean: that depends on what $bar contains.

(Aw! That hurt!)

-- 
Bart.



Re: what I meant about hungarian notation

2001-05-14 Thread John Porter

Bart Lateur wrote:
 As to what the combined
   $bar[$foo]
 would mean: that depends on what $bar contains.

I think it would depend on what the declared type
of @bar was (i.e. ordered or associative).

-- 
John Porter




Re: what I meant about hungarian notation

2001-05-14 Thread Me

 As someone else pointed out (I forget who). But beginners are not
 always the best people to ask. Beginner don't stay beginners for
 long I think the quote was.

And as I said before, I agree.

I picked the beginners list as much because it was
active as anything else. They are *somebody* after
all, even if their preferences are not to be taken too
seriously.




Re: what I meant about hungarian notation

2001-05-14 Thread Edward Peschko

On Mon, May 14, 2001 at 10:11:01PM +0200, Bart Lateur wrote:
 On Mon, 14 May 2001 20:38:31 +0100, Graham Barr wrote:
 
 You forgot
 
  $bar[$foo]; # $bar is an array reference
  $bar{$foo}; # $bar is a hash reference
 
 As to what the combined
 
   $bar[$foo]
 
 would mean: that depends on what $bar contains.
 
 (Aw! That hurt!)

yeah, 'that hurt' is right. I like visual clues to tell me what type of variable
something is. And I disagree strongly with trying to steamroller the language's
design paper-flat as much as I disagree with unnecessary ornamentation.

So I'll take my '{}', thank you very much

Ed



Re: what I meant about hungarian notation

2001-05-14 Thread Me

 (i.e. ordered or associative).

A (probably futile, but one has to try) plea for
people to use numbered rather than ordered.

@foo = ['England', 'France', 'Germany'];# unordered
%foo = {First = Fred', Last = 'Bloggs'];  # ordered

(I'd also suggest named instead of the scientific associative.)





Re: what I meant about hungarian notation

2001-05-14 Thread Simon Cozens

On Mon, May 14, 2001 at 08:38:31PM +0100, Graham Barr wrote:
  What is the meaning of the following four expressions in Perl6?
  @bar[$foo];
  %bar{$foo}; 
  @bar{$foo}; 
  %bar[$foo]; 
  $bar[$foo]; 
  $bar{$foo}; 

It's really, really easy. Just stick a - between the variable and
the brace, and you have Perl 5.

@bar[$foo] in Perl 6 is @bar-[$foo] in Perl 5. 
(Which, by magic, turns into what most people refer to as $bar[$foo])

%bar{$foo} in Perl 6 is %bar-{$foo} in Perl 5.
(By the same magic, this is $bar{$foo});

@bar{$foo} in Perl 6 is (almost) @bar-{$foo} in Perl 5. 
Even looking at it, you can tell it makes no sense. (But Perl 5 does magic
on it anyway, so that's not the best example)

%bar[$foo] in Perl 6 is (almost) %bar-[$foo] in Perl 5.
That's similarly nonsensical, but Perl 5 is still magic.

$bar[$foo] in Perl 6 is $bar-[$foo] in Perl 5.

$bar{$foo} in Perl 6 is $bar-{$foo} in Perl 5.

-- 
IDIOCY:
Never Underestimate The Power Of Stupid People In Large Groups

http://www.despair.com



RE: what I meant about hungarian notation

2001-05-14 Thread David Whipp

Edward Peschko wrote:
  As to what the combined
 
  $bar[$foo]
 
  would mean: that depends on what $bar contains.
 

 I like visual clues to tell me
 what type of variable
 something is. And I disagree strongly with trying to
 steamroller the language's
 design paper-flat as much as I disagree with unnecessary
 ornamentation.

 So I'll take my '{}', thank you very much


But you are assuming thre are only 2 types of indexing scheme for
collections to which $bar might be a reference. In the OO world, I can
define all sorts of wierd things, some of which may be useful. Am I forced
to write $bar.index($foo) for anything other than hashes and arrays?

Dave.
--
Dave Whipp, Senior Verification Engineer,
Fast-Chip inc., 950 Kifer Rd, Sunnyvale, CA. 94086
tel: 408 523 8071; http://www.fast-chip.com
Opinions my own; statements of fact may be in error.




RE: Apoc2 - STDIN concerns

2001-05-14 Thread David Grove

 On Mon, May 14, 2001 at 01:25:51PM +0200, Bart Lateur wrote:
  There must be some reason why a language like Sather isn't more popular.
  I think that iters are part of the problem.

 That smacks of the Politician's Syllogism:
 Something is wrong.
 This is something.
 Therefore this is wrong.

 I think the more immediate problem with Sather is that it's
 totally obscure.
 I'd never heard of it. I'd never read any articles about it. It has no
 publicity. If people haven't heard of it, it'll remain unpopular.

 Iters or no iters.

Naw, they simply haven't gotten into the rage of Perlbashing, which seems to
be how Python, PHP, and Ruby have made any headway. C# is going there too,
but Microsoft makes it too obvious (nobody of any dignified talent reads
about MS technology without a salt shaker handy.)

p





Re: what I meant about hungarian notation

2001-05-14 Thread John Porter

Simon Cozens wrote:
 It's really, really easy. Just stick a - between the variable and
 the brace, and you have Perl 5.

Pardon my indelicacy, but - Screw how it looks in Perl5.
We can make it mean anything, and appear anyhow we want.
IOW, what makes sense in Perl6 isn't defined by how
we were constrained TDI in Perl5.

-- 
John Porter




Re: what I meant about hungarian notation

2001-05-14 Thread Simon Cozens

On Mon, May 14, 2001 at 04:50:17PM -0400, John Porter wrote:
 Pardon my indelicacy, but - Screw how it looks in Perl5.

I'm not telling you how it *looks* in Perl 5, I'm telling you (in Perl 5
terms) what it will *mean*.

-- 
Use an accordion.  Go to jail.
-- KFOG, San Francisco



Re: what I meant about hungarian notation

2001-05-14 Thread John Porter

Simon Cozens wrote:
 I'm not telling you how it *looks* in Perl 5, I'm telling you (in Perl 5
 terms) what it will *mean*.

Fine, you're using perl5 as pseudocode.
I could do that too.  But it has no bearing on the
desirability of anyone's proposed perl6 syntax or
semantics.

-- 
John Porter




RE: what I meant about hungarian notation

2001-05-14 Thread David Grove

 On Mon, May 14, 2001 at 04:50:17PM -0400, John Porter wrote:
  Pardon my indelicacy, but - Screw how it looks in Perl5.
 
 I'm not telling you how it *looks* in Perl 5, I'm telling you (in Perl 5
 terms) what it will *mean*.

nice save

p





A summary: %, @, [], {}

2001-05-14 Thread Me

I will read replies, and respond to off list emails,
but I will refrain from posting to the list on this topic
for at least one week.

If you have nothing new to add, then please don't post.



Suggestion: pseudohash.

%foo{Fred} = 'Bloggs';
$bar = %bar[1];# $bar is 'Bloggs'



Suggestion: deprecate %.

   {} and [] act as named and numbered indices.

   The benefit is saving % for alternative/future perl use.

   One cost is the strangeness of @foo being, effectively,
   two variables. I believe this is a strangeness that would
   quickly dissipate, but that's just a guess.



Suggestion: deprecate {}.

   The benefit is saving {} for alternative/future perl use,
   and the fact that beginners prefer [] as the subscript
   parens for both arrays and hashes by a more than 2
   to 1 margin.
 
   One cost is that:

   $foo[$bar]

   would be syntactically ambiguous. The compiler
   would know enough to deal, but humans would not.



Suggestion: deprecate both % and {}.

   Benefits are both of the above.

   Costs are numerous and deep.