tneff@bfmny0.UU.NET (Tom Neff) (02/23/90)
Why not allow the inverse of the usage @array = <FILE>; which fills @array with all the lines from the open stream <FILE>, and allow <FILE> = @array; which would write all the elements of @array to the open stream <FILE>. You can do this now with print and foreach or join, but the symmetry would still be nice.
tchrist@convex.COM (Tom Christiansen) (02/23/90)
In article <15193@bfmny0.UU.NET> tneff@bfmny0.UU.NET (Tom Neff) writes: >You can do this now with print and foreach or join, but the symmetry >would still be nice. You don't need foreach or join; this does it: print FILE @array; but I agree that the symmetry is esthetically appealing to have <FILE> be an lvalue. I just don't think it's particularly neccesary, just as @array += 3; is nice (and I don't even know APL :-) but also unnecessary since you can always use: grep($_ += 3, @array); --tom -- Tom Christiansen {uunet,uiucdcs,sun}!convex!tchrist Convex Computer Corporation tchrist@convex.COM "EMACS belongs in <sys/errno.h>: Editor too big!"
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/23/90)
Against all the (valid) arguments of symmetry and aesthetic appeal stands a simple readability issue: you can currently glance at a program and find where the lines are read in. Having <> as an output symbol would militate against this. Besides, any cosmologist will tell you that life would be awfully boring without spontaneous symmetry breaking. Larry
merlyn@iwarp.intel.com (Randal Schwartz) (02/24/90)
In article <15193@bfmny0.UU.NET>, tneff@bfmny0 (Tom Neff) writes: | Why not allow the inverse of the usage | | @array = <FILE>; | | which fills @array with all the lines from the open stream <FILE>, | and allow | | <FILE> = @array; | | which would write all the elements of @array to the open stream <FILE>. | You can do this now with print and foreach or join, but the symmetry | would still be nice. yeah, yeah, and then you could say: <FILE1> = <FILE2> to copy a file! Nifty! Just kidding. What I really meant to say is that this is starting to look like creaping featurism. I vote no, especially if it'll delay "Patch 9 from outer space". I mean, what's wrong with: print FILE @array; and print FILE1 <FILE2>; for both of those? Nothing! What *I'd* really like is a call like `cat file` that gives me the whole file in one fell swoop without having to start a process. I'd also like to capture the output of "write" into a string so I could do further processing, rather than having to write it to a temp file (yeah, I came up with a need for this the other day, but worked around it instead). But what I'd *really* like is Patch 9. :-) format STDOUT = @<<< @<<<<<< @<<< @<<<<<, $Just, $another, $Perl, $hacker . for("Just","another","Perl","hacker"){eval"\$$_=\$_;";};write; -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/
tneff@bfmny0.UU.NET (Tom Neff) (02/24/90)
Just for the record, if I toss something out for discussion right now it's NOT because I want it to go in Patch 9! Like everyone else, I await that patch with no further embellishment (and eagerly!). ------------------- Now, how about easy array inserts and deletes via slice operations? push(@array[1..$n], $elt1, $elt2...); and $elt = pop(@array[1..$n]);
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (02/25/90)
In article <15202@bfmny0.UU.NET> tneff@bfmny0.UU.NET (Tom Neff) writes:
: Just for the record, if I toss something out for discussion right now
: it's NOT because I want it to go in Patch 9! Like everyone else, I
: await that patch with no further embellishment (and eagerly!).
The problem is that it takes 4-5 contiguous hours to put a patch together
and test it, and the usual embellishment only takes an hour or so to add.
: Now, how about easy array inserts and deletes via slice operations?
:
: push(@array[1..$n], $elt1, $elt2...);
: and
: $elt = pop(@array[1..$n]);
It's kindof weird to use array slices for that, since you have to supply
useless information. And the semantics of slices are that they are
equivalent to a list of individual scalars, which I don't want to change.
What we need is some equivalent to the substr() function when used as an
lvalue--if the thing you assign is the same length, it changes in place;
if it's longer, the array grows, and if it's shorter, the array shrinks.
Assignment to a slice would be a reasonable syntax, but that already means
something different, alas. And what would
$elt = pop(@array[1,8,4])
mean?
Perhaps
subary(@array, $n, 0) = ($elt1, $elt2, ...); # your push
$elt = $array[$n]; # your pop
subary(@array, $n, 1) = ();
Open to suggestions.
Larry