Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > human nature of perl (new operators etc)

Reply
Thread Tools

human nature of perl (new operators etc)

 
 
I H H
Guest
Posts: n/a
 
      11-11-2004
Hello,

perl's syntax is what it is (as I undertood correctly) because it was
supposed to be like human languages.
Meaning a word or a phrase has context bind meaning. If context changes, the
meaning changes too.
Should there be more human nature properties in perl?

Could these be useful? At least might make scripting even more faster.

Division operator in string context would be like 'split':

@cols=split(/$expression/,$line); <=> @cols=$line/$expression;

---
open(F,$file);
@lines=<F>;
close(F);

<=>

@lines<$file>\o /\n;

---
if($x>$y){do_something $arr[$x];} <=> $arr[(if($x>$y))] cond returning
values that fill it.


---

anyone else having crazy ideas like these?


 
Reply With Quote
 
 
 
 
James Willmore
Guest
Posts: n/a
 
      11-11-2004
On Thu, 11 Nov 2004 10:37:10 +0000, I H H wrote:

> perl's syntax is what it is (as I undertood correctly) because it was
> supposed to be like human languages.
> Meaning a word or a phrase has context bind meaning. If context changes, the
> meaning changes too.
> Should there be more human nature properties in perl?


perl has enough ways to do it ... maybe *too* many ways. It gets to a
point that one has to say "enough is enough".

> Could these be useful? At least might make scripting even more faster.
>
> Division operator in string context would be like 'split':

<snip>

IMHO, 'split' works fine the way it is. "If it ain't broke, don't fix it"

> anyone else having crazy ideas like these?


Yes, but I keep these ideas to myself ... people already think I'm crazy
and I don't want to give them any more ammunition

In all seriousness ... if you want to experiment with "wild and crazy"
ways to do it, you could develop your own class(es) and see how much
effort goes into doing it different ways. For example: you could write
your own class to overload the '<=>' (or some other) operator to do what
you propose.

HTH

Jim

 
Reply With Quote
 
 
 
 
Arndt Jonasson
Guest
Posts: n/a
 
      11-11-2004

"I H H" <(E-Mail Removed)> writes:
> Could these be useful? At least might make scripting even more faster.
>
> Division operator in string context would be like 'split':
>
> @cols=split(/$expression/,$line); <=> @cols=$line/$expression;


But wouldn't you still want "424242" / "42" to produce 10101?
 
Reply With Quote
 
Tore Aursand
Guest
Posts: n/a
 
      11-11-2004
On Thu, 11 Nov 2004 10:37:10 +0000, I H H wrote:
> Division operator in string context would be like 'split':
>
> @cols=split(/$expression/,$line); <=> @cols=$line/$expression;


That would fail when you need to evaluate this expression, for instance;

"100" / "10"

Do you want to split on '10', or do you want to divide by ten? I think
'split()' is nice as it is.

> open(F,$file);
> @lines=<F>;
> close(F);
>
> <=>
>
> @lines<$file>\o /\n;


You could always have a "Misc" module in hand, as I do;

my @lines = read_file( $file );

One other approach is to write a filter (using one of the Filter modules)
to do what you want.

> anyone else having crazy ideas like these?


All the time, but I tend to keep them for myself. I don't want one those
white, long-sleeved shirts.


--
Tore Aursand <(E-Mail Removed)>
"To cease smoking is the easiset thing I ever did. I ought to know,
I've done it a thousand times." (Mark Twain)
 
Reply With Quote
 
ctcgag@hotmail.com
Guest
Posts: n/a
 
      11-11-2004
"I H H" <(E-Mail Removed)> wrote:
> Hello,
>
> perl's syntax is what it is (as I undertood correctly) because it was
> supposed to be like human languages.
> Meaning a word or a phrase has context bind meaning. If context changes,
> the meaning changes too.
> Should there be more human nature properties in perl?
>
> Could these be useful? At least might make scripting even more faster.
>
> Division operator in string context would be like 'split':


To the small extent that there is such a thing as "string context"
in Perl, that context is provided by the operator. The operator
can't be both dependent on and the source of this "context".



>
> @cols=split(/$expression/,$line); <=> @cols=$line/$expression;
>
> ---
> open(F,$file);
> @lines=<F>;
> close(F);
>
> <=>
>
> @lines<$file>\o /\n;


I'm not sure I understand what you are getting at here.

> ---
> if($x>$y){do_something $arr[$x];} <=> $arr[(if($x>$y))] cond returning
> values that fill it.


I've thought there should be some kind of defined_and or exists_and.

It would short-circuit and return undef if not
defined or exists, and would evaluate to the value of its argument
otherwise.

if (exists $h{$j}{$k}{L}{M}{$n}{$o}{P} and
$h{$j}{$k}{L}{M}{$n}{$o}{P}==7)...

if (exists_and $h{$j}{$k}{L}{M}{$n}{$o}{P} ==7 ) ...

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
Ben Morrow
Guest
Posts: n/a
 
      11-11-2004

Quoth "I H H" <(E-Mail Removed)>:
> Hello,
>
> perl's syntax is what it is (as I undertood correctly) because it was
> supposed to be like human languages.
> Meaning a word or a phrase has context bind meaning. If context changes, the
> meaning changes too.
> Should there be more human nature properties in perl?
>
> Could these be useful? At least might make scripting even more faster.
>
> Division operator in string context would be like 'split':


Larry has a rule-of-thumb for language design: either have polymorphic
operators or polymorphic values. Trying to have both leads to insoluble
ambiguities, where you can't tell what a given operation will actually
do. Consider if Perl had only one ==, which did for both strings and
numbers: which comparison would

$a = "a";
$b = 2;
$a == b;

perform, and how would you choose the other?

Ben

--
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based
on the strictest morality. [Samuel Butler, paraphrased] http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Peter Wyzl
Guest
Posts: n/a
 
      11-12-2004
<(E-Mail Removed)> wrote in message
news:20041111171442.799$(E-Mail Removed)...
> "I H H" <(E-Mail Removed)> wrote:


..snip.

>> ---
>> open(F,$file);
>> @lines=<F>;
>> close(F);
>>
>> <=>
>>
>> @lines<$file>\o /\n;

>
> I'm not sure I understand what you are getting at here.


I think he meant that the <> operator could have a modifier '\o' which
automatically handled the open and close part of the standard file read,
with an optional argument which specified the default value for $/

I think....



--
Wyzelli
print 'Therefore, I am';


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unpredictable nature of increment operators bintom C++ 10 05-11-2008 04:19 PM
Human nature - don't touch that button! Peter NZ Computing 2 12-18-2005 10:05 AM
perl bug File::Basename and Perl's nature Xah Lee Ruby 13 01-27-2004 08:20 AM
perl bug File::Basename and Perl's nature Xah Lee Python 14 01-27-2004 08:20 AM
WWW: Win A Copy Of Two Weeks Notice and Human Nature. Chris Marin DVD Video 0 08-07-2003 08:58 PM



Advertisments