human nature of perl (new operators etc)

I

I H H

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;
 
J

James Willmore

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
 
A

Arndt Jonasson

I H H said:
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?
 
T

Tore Aursand

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. :)
 
C

ctcgag

I H H said:
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.

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
 
B

Ben Morrow

Quoth "I H H said:
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
 
P

Peter Wyzl

..snip.


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....

:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,269
Messages
2,571,100
Members
48,773
Latest member
Kaybee

Latest Threads

Top