Re: Reduce [was: Re: Random items (old p5p issues)]
hi, Why not some sort of functionality like LISP/Prolog i.e. working with lists. ("a",@x,"b",%y) - the list head ("a",@x,"b",%y) # "a" head(tile("a",@x,"b",%y)) #@x head(head(tile("a",@x,"b",%y))) #$x[0] head(tile(tile("a",@x,"b",%y))) #"b" if you like it then "splice" etc... can this be done in the moment ?? I think moto of the Perl6, should be "Steal with Style" :") > On Tue, Aug 01, 2000 at 10:27:08PM +0300, Ariel Scolnicov wrote: > >multimap operation list-of-lists # uurgh. > > This made me think of something else that came up in a discussion with Larry > after the conference. > > The discussion started off with the ability to do > > for ($a,$b) (@list) { ... } > > and go through the list in steps of two, or whatever the number of vars were. > > But then went onto interators and something like > > @list = interleave(@a,@b,@c); > > which would interleave the lists given, and > > foreach ($a,$b,$c) (interleave(@a,@b,@c)) > > which would iterate around all lists at the same time, but without flattening > the list. Maybe through some kind of hierarchy of iterators or something > > Graham. > > I really should get all these ideas into an RFC.
Re: Contexts [was:Reduce[Re:]]
> ...and have some_func know it is being called in an iterator context > and be able to create it's own iterator. foldr could then be > done as... I think may have not only list,scalar,iterator context. But some way to define CONTEXT itself, I don't have idea how ? array context, boolean context , hash context f.e. @a == @b #compare all elements %x == %c #compare all key/value pairs of the hash %c = %b# copy only those key/value pair that exist in both hashes = iVAN [EMAIL PROTECTED] =
this can be interesting (Clue)
http://mini.net/pub/ts2/minotaur.html
Re: Contexts [was:Reduce[Re:]]
right err, I just wanted to illustrate the idea for CONTEXT's in same way, didn't find the right examples though... If we have more contexts any operator/s will be interpreted in numerous ways, so the possible combinations grow i.e. we come close the the natural language. On the other hand the complexity grows too, but if there is defaults ( i.e. how people expect to work ) we can drop down the complexity. > > > ...and have some_func know it is being called in an iterator context > > > and be able to create it's own iterator. foldr could then be > > > done as... > > > > I think may have not only list,scalar,iterator context. But some way to > > define CONTEXT itself, I don't have idea how ? > > array context, boolean context , hash context f.e. > > > > @a == @b #compare all elements > > What happens when you want the current value of @a == @b? > > > %x == %c #compare all key/value pairs of the hash > > %c = %b# copy only those key/value pair that exist in both hashes > > Err... changing = to have a meaning other than assignment seems to me > to be somewhat foolhardy. *Especially* as the example you cite is > already meaningful and useful.
DOCS
hi, As the news that the Perl will be rewriten comes... me and I think many others non core coders decided that they can help with something but most of the people like me doesn't have the knowledge of the current PERL5.6, why we may need this ?! 'cause Perl6 is 2 years from "here" and we will not have alpha version sooner -> then what to do to help ?! HmmmLet see how it works now and experiment with the current Perl my ideas but there is a lack of information/docs about it... so I'm in circle give us more than perlguts and perlapi, they are not enought . One good Idea was PERLHACKTUT posted on the perl5portes list meanwhile is there new version of it?... I can make a list of wishes for the docs if you want :") Another benefit will be that we will have something to compare with... Perl 5.(7/8) will be our field test for Perl 6.0 Thanx for your time = iVAN [EMAIL PROTECTED] =
what will be in Perl6 ?
http://www.oreillynet.com/pub/a/linux/rt/07282000/transcript.html
Re: println() ... printbr()
> I actually saw this in the newsgroups and thought it was a neat idea. What > about >println $textvar; > instead of >print "$textvar\n"; > Ever so much easier to read and write, prints the arg and appends \n. ]- I thought 'bout this too, but I think it is not general enought..Why ? we shall then add this too : printbr "text"; i.e. print "text"; OR printtd, printtr print "text"; and many other like this !!! current way for many prints operators is : $old = $\; $\ = "\n"; print ... print ... print ... $ =$old; OR { local $\ = "\n"; print ... print ... print ... } There shall be easier way in Perl6 for doing this ... I too get really tired of these "\n" and 's at the end ALSO ... print @array; must work like this : foraeach (@array) { print "$_\n"}; foraeach (@array) { print "$_"}; not like at the moment : foraeach (@array) { print $_}; = iVAN [EMAIL PROTECTED] =
Re: RFC 90 (v1) Builtins: zip() and unzip()
Subject: RFC 90 (v1) Builtins: zip() and unzip() I just don't like the name zip(), unzip() - shold be saved for something that will really do commpression. Variants : combine I like merge too.. As of this it will be good if there some sort of compression internally by the perl, say for the data structures... I'm not sure how easly this can be done, but this will big win especialy when worknig on big text files or arrays (RLE is enought in most cases). everyone knows the BLOATED https's under mod_perl. For example Interbase DB uses RLE compression for at record level... this is big saving ... = iVAN [EMAIL PROTECTED] =
Re: RFC 90 (v1) Builtins: zip() and unzip()
what about (not zip() offcource :")): @a = (1,2,3); @b = (4,5,6); @c = (7,8,9); zip (how,@a,@b,@c); i.e. @list = zip (0,@a,@b,@c); #stright result (1,2,3,4,5,6,7,8,9) @list = zip (1,@a,@b,@c); #reverse result (7,8,9,5,6,7,1,2,3) @list = zip(2,@a,@b,@c); # all first elems, then all second..etc result (1,4,7,2,5,8,3,6,9) @list = zip(3,@a,@b,@c); #and reverse... result (7,4,1,8,5,2,9,6,3) Also we can tell : @list = zip(1,@a,@b,reverse @c); = iVAN [EMAIL PROTECTED] =
Re: matrices : RFC 91 (v1) Builtin: partition
Sorry that read this later... It is one step from matrix to create SQL syntax :") if we have MATRIX operations what about adding a conditions to it.. i.e. : @a = (1,2,3); @b = (4,5,6); @c = (7,8,9); matrix x3, @a, @b, @c where x3 > 5; ( 1,2,3 4,5,6 7,8,9 ); x3 in where mean column 3 (?syntax), should return : ( 4,5,6 7,8,9 ); = iVAN [EMAIL PROTECTED] =
Re: Recording what we decided *not* to do, and why
hi, it will be good if all these RFC are put somewhere on the WEB (we can't follow all those mailing lists if the amout of posts stay the same :") ) also in this way we will get broader picture what is happenning.. = iVAN [EMAIL PROTECTED] =
Re:MATRIX implementation [ RFC 90 (v1) Builtins: zip() and unzip()]
> "David L. Nicol" wrote: > > > > These things sound like perfectly reasonable CPAN modules. > > What's the block prevenenting their implementation w/in the > > perl5 framework? > > Jeremy and I are working on a general purpose matrix/unmatrix function > that may well be core-worthy. This would allow arbitrary reshaping of 2d > (Nd?) arrays into any form imaginable. > > However, I would probably argue that zip/unzip/merge/unmerge/whatever go > into a module (Math::Matrix?) since they'll probably just be specialized > calling forms of matrix/unmatrix. I think the trend is to put a lot of > formerly-core functions and features in modules, especially if subs get > fast enough (and it sounds like they're going to). > ]- One possible implementation of MATRICES is for example : As I read in perlguts-illustrated the array is represented as a array of POINTERS i.e. (pointer to $a[0], pto $a[1], pto $a[3], pto $a[n]) then we can have f.e. "matrix" : matrix 10x5, @a; this just reorders the list in the following LIST-ARRAY structure : (pto $a[0] .. $a[9]) --next-> (pto $a[10] .. $a[19]) ---next-> () now we have chained-arrays. The benefit : (@a is now internally known for perl as MATRIX) push @a,@b; will push one by one all elements of @b into correspondending rows in @a matrix push is now executed in MATRIX CONTEXT. If you gotcha the idea then all splice, pop,shift, unshift will do their correspodending roles. (offcource there is some glitches such as what happen if the @b array is smaller/bigger the necessary elements for the matrix - then we can have fillwith zeros, with default value ... etc) THE other operator "unmatrix" just convert the matrix back to array.. We can easly access say element 250 for example like $a[250] 'cause the exact position is is easy calculated, offcource the access will be little bit slower than normal array. WHAT HAPPEN with HASHES ?!? May be we can look at them as TABLES... = iVAN [EMAIL PROTECTED] =
Re: RFC 104 (v1) Backtracking
> There's also the cut operator which I didn't see mentioned in the RFC. > It blocks backtracking so that something like this: > > B1 andthen B2 andthen cut B3 andthen B4 andthen B5 > wouldn't backtrack to B2 once it forwardtracked to B3. ]- I tried minimalistic approach as small as possible additions to the Perl language, we get only the "backtrack" mechanism i.e. something that is harder or slower to be done outside of the perl core. The rest should be done outside . (I too want all in the core) Example : my $cutState = 0; { { block1 } andthen { block2 } andthen { block3 } andthen if ($cutState) { last AFTER} else { $cutState = 1}; 1; } andthen { block4 } andthen { block5 }; } AFTER: code not sure will this also do the job : { $cutState = $cutState ? last AFTER : 1 } . So the CUT is candidate for module. Offcourse I preffer all syntax to be embeeded, cut,fail ... but if I tried in this way there is smaller chance this to get in the core .. Think, it is only around 10 lines of code to be added in perly.y i.e. 10 lines C code in Perl-core. Mainwhile CUT is small too :") > Okay, the more I think about it, the more I think it should be a > module. ]- How this can be done as module ? = iVAN [EMAIL PROTECTED] =
Re: RFC 104 (v1) Backtracking
> > They behave similarly like &&, ||, and, or operator with one main > > distinction they "backtrack" for example: > > > > { block1 } B { block2 }; > > This would be a good use of the to-be-liberated => operator: > > { block1 } => { block2 }; > > In any case, "andthen" doesn't seem like a good choice. > Other possibilities: > therefore > implies > segue > seq > so ]- any proposal for the name are welcomethey must be two. the reason I decided to use this is cause it works like/is similar to -> if-then-else, also look like and/or comparions operator. The Prolog operators "," and ";" are already overused in perl. THEN is not used by PERL, so here comes : AND+THEN OR+THEN :") = iVAN [EMAIL PROTECTED] =
Re: RFC 104 (v1) Backtracking:example
hi jeremy, all, here is one simple example , let say we have this XML file: how we can implement the following XPath expression - "file://code" I'm giving here very simplified example (orthen works as shown in first interpretation i.e.) : if "block1" return true(1) the end result is true(1) but if "block1" return false(0) "block2" is evaluated then if "block2" return true(1) the end result is true(1) if "block2" return false(0) we evaluate "block1" again i.e. start from the beginning. === node stores STATE information...to be easy ... don't take care about the syntax...or some small semantic errors... sub getNextChildNode { my $node = shift; if ($node->{visited}) {return 0} else $node->{currchild}++; return getchild($node) }; }; my $node = ROOT; { getNextChildNode($node) orthen getParentNode($node) } andthen { is this add to the result; $node->visited(1)}; OK.What is happening 1.I'm in the root 2. Give me the ROOT child -> context changes to first 3. Is this -> no 4. Give me the next node child -> context changes to first 5. Is this -> no 6. Give me the next node child -> no childs 7. Give me the parent -> context changes to first 8. Give me the next node child -> context changes to first 9. Is this -> no 10. Give me the next node child -> no childs 11. Give me the parent -> context changes to first 12. Give me the next node child -> no MORE childs 13. Give me the parent -> context changes to first 14. Is this -> no 15. Give me the next node child -> context changes to second ...and so on did U gotcha the idea ... (pls correct me if I'm wrong) this code will traverse the whole TREE and will find all elements... similar approach can be used for directories or all others TREE structures... I will try in the next RFC to give more examples... sorry for this, but my Perl is far-better than Prolog or C. Shorter : "Get Parent or Child and check for " every node has two connections, one of them CHILD(is array of nodes) other parent [ declarative,natural semantic the way human think not the way machine think ] The main idea is to think about this not as algorithm(step-by-step instructions, how this will be done, "the way" if you use while,until or do cycles), but on the following way : "the tag should be somewhere let me check all childs and parents of my nodes" THIS is called DECLARATIVE SEMANTICS and is the PROLOG biggest strength, the drawback of this type of programming is sometimes the speed ... but when you want speed you can combine - PROCEDURE and DECLARATIVE semantics. Example : PROCEDURE (HOW-TO), DECLARATIVE (FAQ). If someone can explain this better, please do it - my English is not so good.thanx. I think the equivalent will be : sub walk { my $node = shift; if ($node->name eq "code") {do something; return}; while (getNextChildNode) { if ($_) { walk($_) } else {getParent} } } but think again this is not normal way of solving the problem i.e. U use recursion does the "forward flow" programming has the notion of the recursion i.e. describe the problem "with yourself" - NO ? This is the way human think...So the BACKTRACKING is yet another way humans thinks. Someone will say - Yes but I can do it faster w/o backtracking. The answer - It will be alot faster if U use Assembler, isn't it ?:") Other benefits : Yet another way to get rid of this "if-elseif-elseif" construction, this is my most hated construction (I've never used it and will not :")). Can U believe that there is a people that can make 25 screens if-elseif-...-elseif contruction, I have a bad luck to correct such a beast :"( Think of THREADS, this way of programming is much more threads-friendly Other areas of usage : Lexers,Parsers,REGEX's I'm also a very very ... very beginner in Prolog :"( so don't worry. PS... Yet another getNextChildNode :") sub getNextChildNode { my $node = shift; ! $node->{visited} andthen { $node->{currchild}++ orthen return getchild($node) } }; HtH = iVAN [EMAIL PROTECTED] =
Re: RFC 104 (v1) Backtracking
hi, > > So how is that different from: > > > > do BLOCK1 until do BLOCK2 > > It's the same. > But the real fun starts when blocks and functions can suspend and > resume. > >{ ... > # Return value and suspend. > suspend $i; > # Next iteration will resume here > ... >} andthen { ... }; > > -- Johan ]- hm I will say wrong point of view. Why ? You are looking at this code at "Procedure semantic side" of view. Let'see how this look to me... "declarative guy" :") "Suspend" works for me like "INBLOCK CUT". I will ask what will happen in recursive block if you place the "end conditions" before suspend :") = iVAN [EMAIL PROTECTED] =
Re: RFC 104 (v1) Backtracking :ref
=head1 REFERENCE Icon language brief intro : http://www.cs.arizona.edu/icon/intro.htm
Multiway comparisons
RFC 25 (v1): Multiway comparisons and now snip from the Icon language : http://www.cs.arizona.edu/icon/docs/ipd266.htm 2.1 Conditional Expressions In Icon there are conditional expressions that may succeed and produce a result, or may fail and not produce any result. An example is the comparison operation i > j which succeeds (and produces the value of j) provided that the value of i is greater than the value of j, but fails otherwise. Similarly, i > j > k succeeds if the value of j is between i and k. The success or failure of conditional operations is used instead of Boolean values to drive control structures in Icon. An example is if i > j then k := i else k := j which assigns the value of i to k if the value of i is greater than the value of j, but assigns the value of j to k otherwise. I think the idea of leaving the value "j" in "i > j" is cool... = iVAN [EMAIL PROTECTED] =
Nice to have'it
Hi, I have couple of ideas which may or may not worth it, so I didn't wrote the RFC but will list them here in short. Here are the nice to have'it. 1. There will be good to have some sort of "match and/or assign" operator for structures i.e. HASHES. Can't still figure out the syntax but may be it must borrow some ideas from "switch/case" and Pascal "with" it should be also easy to say : if ( %a match %b ) or %a assign_diff %b - assign and/or add all key and/or values from %b which are not in %a OR diff ... :") 2. "in" operator i.e. $a in (5,6,10,33,45) $a in @b 3. min,max,avg !!! $a = min(5,6,10,33,45) if ( max(@b) > 22 ) ... 4. op() - Prolog like operator/keywords precedence. f - position of the op/keyword x - if there are more operators in this operand they must be lower precedence y - if there are more operators in this operand they must be equal or lower precedence. yfx - left-associative evaluate from left to right xfy - righ-associative evaluate from right to left op(100,yfx,"*"); op(200,yfx,"+"); this mean that : a+b*3 is (a+b)*c, but not a+(b*c) More interesting will be redifining the keywords :") 5. Persistency and easy integration in other systems as example mod_perl, deamons like stuff etc... THE CLUE 6. CPAN = module -> bundle -> distribution Distriburion(many modules+many bundles) to be something that the OS vendors will add to their OS's or other people do separately. F.e..Perl Power Pack. Primary task as small as possible interaction with the user... many of the current CPAN modules can't install successfuly on the fly 'cause thay need some info for which they ask interactively. In some extent this can be achieved for OS vendors 'cause they know their Config better.. 7. DBM f/locking support in standard Perl 8. The following syntax to be possible : $hash{/re/} i.e. this is the same like my @res; foreach my $k (keys %hash) { if ($k =~ /re/) {push $hash{$k},@res} }; OR keys %hash{/re/} values %hash{/re/} each %hash{/re/} This is very usefull for fast searching in DBM for example. 9. 64-bit aware Perl - Merced is comming !!! 10. I know this is very hard or some may argue against this, but I think it should be possible to hack perl itself easy by every "seasoned" Perl programmer i.e. some possibility to change language on the fly. (And not only by the Perl-core-hackers). A good steps toward that direction are Filter and Inline modules... further it will be very good if we can Lex/Yacc-ing in Perl, preprocesing source etc.. 11. "Gobble" parameters from both sides i.e. sub add(x,y){ } may act like this : x add y add x,y add(x,y) This should be some play with Prototypes. I think also that it is good as mantioned in one RFC that there should be the way that we can have several subs with the same name and depending on their number of params executed is that one that match..i.e sub add(a,b) {} sub add(a,b,c) {} If I call add(4,5) the first one is executed, if I call add($c,12,45) second one. 12. CONTEXT - there should be a way to define different and new types of contexts. Let we think what is a context ? Shortly it is - THE WAY WE PASS PARAMETERS and THE WAY WE RECIEVE THE RESULT. So the context can be SUB that accept a reference to all the params and return reference - may be .. i.e. sub add(a,b) { return $a+$b }; this SUB is supposed to handle the scalars, but when we use it in array context it shold do whatever is expected she to do w/o explictly code this in the SUB or to be more clear DWIM. (the description again can be handled to some extent by the prototypes) then : { context array; @c = add @a,@b; # or better @a add @b } sub array { $sub = shift; @refs = @_;#not the same but just example, leave details for you my @res;$i=0; #I dont care about the number of arrays passed here i.e foreach $v (@refs) # we should care while ( $#{$refs[0]} && $#{$refs[1]}) { my $a = shift @{$refs[0]}; my $b = shift @{$refs[1]}; $res[$i++] = &$sub($a,$b); }; return \@res;# !??! } Some EXAMPLES of contexts : scalar,array,iterator,boolean,matrix That is in short, thanx for your attention PS. Perl6 should stay Perl, but must be more than Perl. Perl6 should be fast as mentioned in one RFC - but most importantly it must be featurefull and must continue its tradition - "writing less, doing much" = iVAN [EMAIL PROTECTED] =
{....} if condidion
hi, We now can say : $x = 10 if $y > 12; It will be good if this also work.( i.e. block before if ). {$x =10; $z =15} if $y > 12; or $x =10, $z =15 if $y > 12; # 8 click shorter instead of this : if ($y > 12) {$x =10; $z =15} ; 4 keyboard click shorter - Shift+( and Shift+) = iVAN [EMAIL PROTECTED] =
Re: {....} if condidion
> >$x =10, $z =15 if $y > 12; # 8 click shorter > > Should work now. I just tested it in 5.6, but I think that's been valid > since Perl4 or earlier. ]- yep my mistake...sorry :") > >instead of this : > > > >if ($y > 12) {$x =10; $z =15} ; > > > >4 keyboard click shorter - Shift+( and Shift+) > > Paucity of keystrokes, while important, shouldn't be the driving force > behind new features. What benefit would the examples you gave really give > except making it easier to play golf? :")
"Counting the birds" :")
hi, here is one simple script (Requires Parse::RecDescent) that count operators in scripts.(and my fisrt grammar ;") ) OK. I started this against my current perl installation. (it is not pure RH6.2 install, but many things are added) i.e. find /perl_dir -name *.pm | ./count.pl | tee allops.txt it is little bit slower so try first on some PERL subdir not ROOT-Perl dir. # I can't figure out why \w+ OR \w+?\b didn't work so I use \S+ # this is a bit slower 'cause action is executed on every # chunk text instead only on words Add other delimers if used i.e. other than [,{,(,!,#,| for "q and re" stuff. for THE results see at the END of the mail. What is interesting to me : 1. "push" is used more than any of the other array ops, even than "shift" 2. "use" is very good candidate for speedup 3. We still use very much "goto" :") 4. "each" is used more than "values" and "keys" 5. Things like "hex,chr,oct,atan2" are used very rarely 6. "pack" and "unpack" are also used very rarely, "study" - the same number of times. We can make similar thing for the whole CPAN. What will this give to us : 1. It will help us to decide which of the operators are mostly used (CPAN is suitable for this) so then we can take care to speed up only mostly used ops in the new Perl6 (or Perl5) (current script doesn't care about the "weight" of the ops i.e. it doesn't count how many times any op will be used in REAL LIFE f.e some op may execute 10 times during the life of the module but other can be executed only once. They are both counted as "ONE time" execution) Also how many times the module is dloaded from CPAN, has some meaning, for making better calculation. 2. Will give us some better idea which of all outofcore-candidates can be easly purged from the CORE 3. Can focus our attention on which ops will be more problematic for retaining compatibility. One very good idea for the Perl5->Perl6 TRANSLATION script to be used module such as Parse::RecDescent. The script count also the content of POD comments, which is bad. #!/usr/bin/perl use strict; use Parse::RecDescent; use vars qw{ @ops %ops $text $grammar }; sub loadfile($) { open FILE, $_[0] or return "-->"; my $contents = ; close FILE; return $contents; }; #== GRAMMAR ===# my $grammar = q{ start : op(s) op: stuff | /\S+/ $::ops{$item[1]}++ if defined $::ops{$item[1]}; # print "=$item[1]|\n" } stuff : qstuff | restuff qstuff : m*q[qwxr]?[\[\{\(\|!/#]* { $::ops{qstuff}++ } restuff : m*([ysm]|tr)[\[\{\(\|!/#]* { $::ops{restuff}++ } }; #==OPS=# #from perlfunc @ops = chomp chop chr crypt hex index lc lcfirst length oct ord pack reverse rindex sprintf substr uc ucfirst pos quotemeta split study abs atan2 cos exp hex int log oct rand sin sqrt srand pop push shift splice unshift grep join map reverse sort unpack delete each exists keys values binmode close closedir dbmclose dbmopen die eof fileno flock format getc print printf read readdir rewinddir seek seekdir select syscall sysread sysseek syswrite tell telldir truncate warn write pack read syscall sysread syswrite unpack vec chdir chmod chown chroot fcntl glob ioctl link lstat mkdir open opendir readlink rename rmdir stat symlink umask unlink utime caller continue die do dump eval exit goto last next redo return sub wantarray caller import local my package use defined dump eval formline local my reset scalar undef wantarray alarm exec fork getpgrp getppid getpriority kill pipe setpgrp setpriority sleep system times wait waitpid do import no package require use bless dbmclose dbmopen package ref tie tied untie use accept bind connect getpeername getsockname getsockopt listen recv send setsockopt shutdown socket socketpair msgctl msgget msgrcv msgsnd semctl semget semop shmctl shmget shmread shmwrite endgrent endhostent endnetent endpwent getgrent getgrgid getgrnam getlogin getpwent getpwnam getpwuid setgrent setpwent endprotoent endservent gethostbyaddr gethostbyname gethostent getnetbyaddr getnetbyname getnetent getprotobyname getprotobynumber getprotoent getservbyname getservbyport getservent sethostent setnetent setprotoent setservent gmtime localtime time times abs bless chomp chr exists formline glob import lc lcfirst map my no prototype qx qw readline readpipe ref sub sysopen tie tied uc ucfirst untie use dbmclose dbmopen binmode chmod chown chroot crypt dbmclose dbmopen dump endgrent endhostent endnetent endprotoent endpwent endservent exec fcntl flock fork getgrent getgrgid gethostent getlogin getnetbyaddr getnetbyname getnetent getppid getprgp getpriority getprotobynumber getprotoent getpwent getpwnam getpwuid getservbyport getservent getsockopt glob ioctl kill link lstat msgctl msgget msgrcv msgsnd open pipe readlink rename select semctl semget semop setgrent sethostent setnetent setpgrp setpriority setprotoent setpwent setservent setsockop
Check this !! messaging langage or so ...!!!
hi, REBOL is the next generation of distributed communications. By "distributed" we mean that REBOL code and data can span more than 40 platforms without modification using ten built-in Internet protocols. The pieces of a program can be distributed over many systems. By "communications" we mean that REBOL can exchange not only traditional files and text, but graphical user interface content and domain specific dialects that communicate specific meaning between systems. We define communications to include not only information exchanged between computers, but information exchange between people and computers, and information exchanged between people. REBOL accomplishes all of these. http://www.rebol.com/developer.html http://www.rebol.com/howto.html http://www.rebol.com/faq.html Q. I noticed REBOL has built-in compression. How do I use it? Q. Why doesn't REBOL have an ELSE statement? Q. What IS a series? = iVAN [EMAIL PROTECTED] =
Don't require braces
hi, I was thinking will it be good if the braces are used but not required for ops like while, until, if, unless ...etc... what I have in mind : if $x > 10 print $x; work as if ($x > 10) {print $x}; OR while $i < 10 print $i; mean while ($i < 10) { print $i }; I know that some will tell that when the condition is more complicated this will not work for the readability of the program, but there we can still use braces... this is only the shortcut, and will make things clearer for shorter things... while $x > 10 && $y > 5 print $x+$y; while $x > 10 && $y > 5 { print "Result : \n"; print $x+$y; } will still work 'cause if the first condition is false the second one and "print" will not be executed. = iVAN [EMAIL PROTECTED] =
Re: Don't require braces
hi, > so, > >while $i < 10 print $i; print $j; > > should become > >while ($i < 10) { print $i; print $j; } > > or > >while ($i < 10) { print $i; } print $j; > ??? ]- !!! ;") problem can be solved again in this way i.e. shell like syntax : while $i > 10 && $i++ && print $i; mean this while ($i > 10 ) {$i++; print $i}; As I think litle bit more for this may be only "if/unless" if $x > 10 print $x; are a good candidates for this shortage, but some can again argue to use print $x if $x > 10; instead OR use "then" instead i.e. if then ...do something... while then ...do something... just thoughts, nothing w/o we can live ofcourse ;") = iVAN [EMAIL PROTECTED] =
Re: perl6storm #0050
> On Thu, 21 Sep 2000, Tom Christiansen wrote: > > > =item perl6storm #0050 > > > > Radical notion: consider removing precedence. > > Wrong precedence makes people miserable. > > (Some people already suggest that Perl only has two precedence rules: (1) > multiplication and division come before addition and subtraction, and (2) > parenthesize everything else.) > > This would make Perl more like Lisp, I suppose. But it would make code > less ambiguous, probaly at the cost of readability. Arguably, some (most?) > of the precedence levels already work the way people expect them to (for > example, == binds more tightly than || or &&), so fewer "cluttering" > parentheses are needed to make things readable while still being correct. What if we have these 2 rules or no rules AND we can set manualy the precedence of all operators... as in PROLOG (op(precedencePriority,associativity!,operator)). This way older scripts will still work , and for the new scripts any can decide ambiguousity or readability is more important!! = iVAN [EMAIL PROTECTED] =
List Comprehensions (from Python)
hi, I haven't used Python... but last days I read some stuff, wanted to compare both languages for myself and found something interesting. They are proposing extentinon to Pyhon 2 (with their so called PEP documents, this also is good idea i.e. using current or some modified version of RFC's for features addition in Perl 7,8,9,10 ;") ) Can this be done easly at the moment OR via some of the new proposals ?!!!? Does this have some benefit compared to array creation via cycles !!! List Comprehensions This is a flexible new notation for lists whose elements are computed from another list (or lists). The simplest form is: [ for in ] For example, [i**2 for i in range(4)] yields the list [0, 1, 4, 9]. This is more efficient than a for loop with a list.append() call. You can also add a condition: [ for in if ] For example, [w for w in words if w == w.lower()] would yield the list of words that contain no uppercase characters. This is more efficient than a for loop with an if statement and a list.append() call. You can also have nested for loops and more than one 'if' clause. For example, here's a function that flattens a sequence of sequences:: def flatten(seq): return [x for subseq in seq for x in subseq] flatten([[0], [1,2,3], [4,5], [6,7,8,9], []]) This prints [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] thanx = iVAN [EMAIL PROTECTED] =
What will be the Perl6 code name ?!!
hi, Most of the software projects has their code name f.e. : You still can see in the INF files win95 code name Chicago, there was Memphis .. Red Had Version 7 (Guinness) Version 6.2 (Zoot) Version 6.1 (Cartman) Version 6.0 (Headwig) Version 5.2 (Apollo) Version 5.1 (Manhattan) Version 5.0 (Hurricane) Version 4.2 (Biltmore) Version 4.1 (Vanderbilt) Version 4.0 (Colgate) ;") ...etc.. What will be the Perl6 code name ? even the perl books has some animal to represent the main idea behind... or just for the fun. = iVAN [EMAIL PROTECTED] =
Re: What will be the Perl6 code name ?!!
> What will be the Perl6 code name ? ]- OK what about Velociraptor ;") - It is animal - continuing the tradition ... - it is one of the CLEVEREST dinos. (only truodont!! is thought that is clever) - it is PREDATOR - will hunt all other "languages" - small - little bigger than human ... (leaner)... - fast, versatile - other scripting languages will stay in the DUST ;") - They always hunt in "PACKS" ... perl 6 will be the first that will be written by the whole community... not mostly by Larry - They have big "CLAW", perfectly suited for every "FLESH" ...i.e. the "clue" language ;") PERL6 (Velociraptor) PS. My email address has nothing to do with this proposal ;") = iVAN [EMAIL PROTECTED] =
nice2haveit
hi, Two things i think is good to have it : 1. ALIAS keyword. - first reason is 'cause many people don't know that this is possible.. at least any newscommer and it will help not to forgot that it exist :"). - Code become more readable. - can be Overloaded - the syntax for aliasing can become reicher :") 2. Hash-reg-ex-slice %hash{/\d*/} instead of : grep {/\d*/} keys %hash %hash{/\d*/} = (); %hash{/\d*/} = @list;# pump the @list values into %hash values (keys stay the same) - espesialy usefull with DBM 3. For this I'm not totaly sure, but it comes to my mind many modules uses notation like this to pass params i.e. someFunc ( -param1 => 'blah', param2 => 'xxx' .) Why not have %_ in our case we have the following elements : %_{'-param1'} = 'blah' %_{'param2'} = 'xxx' If in object/class contrext (can this be checked in some way) first element goes to : %_{self} note : all references goes directly i.e. : my %_ = map { $_ unless ref } @_; Also there is no need the HASH to be generated until we use it for the first time, for speedup !?! is this possible. I think if it is not hard for implementation it is nice shortcut. = iVAN [EMAIL PROTECTED] =
Re: nice2haveit
>> Two things i think is good to have it : >> >> 1. ALIAS keyword. >> - first reason is 'cause many people don't know that this is possible.. at >> least any newscommer and it will help not to forgot that it exist :"). >> - Code become more readable. >> - can be Overloaded >> - the syntax for aliasing can become reicher :") > > Would you like to clarify what you mean here. > Are you talking about typeglob assignments? > Perl 6 will have: > > $Foo::{'$bar'} = \$baz; # Alias $Foo::bar to $baz ]- Can I see more examples of typeglob assignment somewhere ? link ? I mean something like this : instead of : #$Request->{Params} local *myhash = \%{$$Request{Params}}; my %myhash alias %{$$Request{Params}};#see - it is my (now as far as I know u can't have it 'my') = iVAN [EMAIL PROTECTED] =
Re: nice2haveit
the structure is something like this : $Request = { Params => { abc => 1, ddd => 2 } } the idea is that U don't dereference i.e. : my $myhash = ($Request->{Params}); if u want to use it U have to do this : print $$myhash{abc}; #or if u preffer print $myhash->{abc} in the case of : >local *myhash = \%{$Request->{Params}}; u do this : print $myhash{abc}; so it is first clearer and second I hope much faster = iVAN [EMAIL PROTECTED] =
Re: nice2haveit
> Yes but can't the same be accomplished with... > > my $myhash = (%{$Request->{Params}}); > print $myhash{abc}; > > Though again it copies the structure, I don't see how dereferencing can be > unclear? ]- if u have someting like this anything u can remove in some way is worth it:)) $tables{$$self{rel}{$k}{table}}[0][VALS] or this : $$params{$$self{rel}{$k}{names}[$t].$j} especialy if U have a couple of this :") in 3-4 rows of code... = iVAN [EMAIL PROTECTED] =
Re: aliasing - was:[nice2haveit]
> > > I mean something like this : > > > > > instead of : > > > #$Request->{Params} > > > local *myhash = \%{$$Request{Params}}; > > > > > my %myhash alias %{$$Request{Params}};#see - it is my (now as far as I know > > > u can't have it 'my') > > > >You don't need a typeglob there; you can do the following, which does work > >with 'my': > > > >my %myhash = %{$Request->{Params}}; > > Originally he wanted an alias, and that won't do it. You'll flatten and > unflatten, and changes to %myhash won't be reflected in the original. ]- that's right ... and it is not very good if the HASH is big ... and what to say if it is tied to DBM, even slower the idea of aliasing is to preserve the fast access and on the other side to shorden the "accessor"(i.e the way to access the structure) and make code clearer.(mostly u can choose a name that has better meaning in your context) Also if we talk about object methods it many times good to have many methods do the same thing.. say (just examples, don't blame me just throwing what comes in my mind): &get alias Obj::getAttribute &set alias Obj::setAttribute &setAttr alias Obj::setAttribute oldObj::myOldBrokenMethod alias Obj::myBrandNewMethod ; #backward compatibility &mypop alias pop;#core func aliasing $flag alias $My::Very::Hairy::Object::Which::Is::Very::Hard::To::Access::flag :") = iVAN [EMAIL PROTECTED] =
http://www.go-mono.com/faq.html
http://www.go-mono.com/faq.html
Re: aliasing - was:[nice2haveit]
>> Does such a thing exist already? > >A WTDI exists already: > >for ( $XL->{Application}->{ActiveSheet} ) { > $_->cells(1,1) = "Title"; > $_->language() = "English"; >} > >(presuming lvalue-methods, of course...) So, in this case, a "with" synonym for "for" would work. ]- OR with alias for; with ( $XL->{Application}->{ActiveSheet} ) { $_->cells(1,1) = "Title"; $_->language() = "English"; } :") = iVAN [EMAIL PROTECTED] =
one more nice2haveit
hi, As I was programming i got again to one thing i alwas needed to have... especialy when write something fast or debug some result... words comes about for/foreach and accessing the current-index of the array I'm working with i.e. say I have two arrays @a and @b and want to print them (also say they are connected in some way so I want to see them both). In case of one array I write : print "$_\n" for @a; fast, simple, goodbut in my case I have to write something like this : for ($i = 0; $i < scalar @a; $i++) { print "$a[$i] : $b[$i]\n" }; I've go tired of typing :"), but if I had current index-iterator ( say under $i just as example) at hand the way I have $_ i can just type : print "$_ : $b[$i]\n" for @a; OR print "$a[$i] : $b[$i]\n" for @a; isn't that cute :") ... the same count for list in $i I just get current position in the list. (we can also use "pos" in some way!!!) print "$_ : $a[$i] : $b[$i]\n" for (qw(val1 val2 val3)); I need it very often.:") don't bother if the lenght of both arrays are different when u use it, u know what u are doing... = iVAN [EMAIL PROTECTED] =
Re: array/hash manipulation [was :what's with 'with'?]
> So my initial code (which I modified a little...) > > for ( @foo, @bar ) { > print "$_[0] : $_[1]\n"; > } > > for would set each element of the @_ array to correspond to the arguments in > for() , therfore $_[0] will equal to the current element of @foo and $_[1] > will equal to the corresponding element of @bar. As I mentioned before this > can very easily be accomplished through 0..$#foo loop, but people disagreed > based on that it would be a nice option, in my opinion it's useless, but if > was implemented this could be a way:) ]- Yes ... and one more option : for my $el1, $el2 ( @foo, @bar ) { print "$el1 : $el2\n" } $el1 will get values from @foo and $el2 from @bar, but the following : for my $el ( @foo, @bar ) { print "$el\n" } will print : $foo[0] $bar[0] $foo[1] $bar[1] if people like the other way they can write : for my $el ( (@foo, @bar) ) { print "$el\n" } will print : $foo[0] $foo[1] ...$foo[x] $bar[0] $bar[1] is this correct , but now I'm looking at these too... http://dev.perl.org/rfc/90.pod http://dev.perl.org/rfc/91.pod http://dev.perl.org/rfc/148.pod so may be what must be the order of passing the arguments and other stuff should be done via these proposed functions. PS. I was thinking of that before, what if we have something let's call it 'transform' for transformation of any structure to other structure.. but as i thought it should combine in some way the features of switch,if-else,for/foeach, do, while, array/hash-slices, assignment etc ps I'm talking about DWIM operator. anyway... is it possible to really add such "dwim" function/operator that can be modified on the fly so that it suit all programmers tastes and don't make real mess...") ... ok i say it :"))) = iVAN [EMAIL PROTECTED] =
Re: array/hash manipulation [was :what's with 'with'?]
> Hmmm. Didn't think about that. That would be a nice way, that way you can > manipulate it's behaviour depending with how many aliases you provide. > > for my $el1, $el2 ( (@foo, @bar) ) { > print "$el\n" > } > > $el1 and $el2 would of course be aliases, right? ]- yes ALIASING will be better, instead of copyng values into $el,$el2 scalars just one point I placed around them "(" ")", so that the arrays would be flattened :") ... but now as u told it will be beter they to be aliases.. so may be this is the right one : for my ($e1,$2,e3...,$eX) ( @a1, @a2, @a3, .. @aX) { .blah... } and later on the first iteration $el's are aliased to the zero elements of arrays (if the $el's are more than @a's then the latest $el's are not aliased/probably undef'ed/, if @a's are more then all $el's are occuped and on the next iteration they doesn't start to be aliesed again from the @a1 but from the next @a's !!). If we have Scalars in the list, then they behave as array with one element (just got aliesed every time). If we have Hashes then VALUES get aliased... if someone wants keys it should write explictly keys %hash (temporarily has to be created scalars may be), the same with each. just one possible solution.. may be there is many things i've not seen.. And then what about this :") for my ( $e1, @els,$el3) ( @a1, 5..10, @a2,%h1, $x .. @aX) { .blah... }; :"))) There is endless ways to do it : TIEWTDI = iVAN [EMAIL PROTECTED] =
Re: array/hash manipulation [was :what's with 'with'?]
ooops I forgot if the vars in for are aliesed then it will be ok for using it like 'with' : for my $el ( $Request->{Param} ) { print $el{qsParam1} print $el{qsParam2} } but then what will be $_ ... alias OR copy !?! :") I mean mostly backward compatibility... One other way is 'local' to make copy & 'my' alias in this particular case ?!?!?! I can't remember the current-descision about 'local' Say : for my $el , local $el2 (@a1, @a2) { print $_; #alias print local $_;#copy }; Dusk till down :") = iVAN [EMAIL PROTECTED] =
Re:aliasing a value [...]
I'm ok with both : alias (%foo, %bar); AND my \%foo = \%bar; the first variant look better to me (I mean it is easy to spot when u are reading the code), but I also expected as U the second to work in Perl5 and was very dissapointed to see that it doesn't work.:"( The keyword "alias" on the other hand can do also some other stuff us (can't figure out what else but.. :") ), or can be ALIASED too :") so we can override its behaviour if we want or if it look like operator we can use perl overriding mehanism : %foo alias %bar; still not see what can be the benefit... but just thinking... = iVAN [EMAIL PROTECTED] = > "Sterin, Ilya" wrote: > > > > alias(%foo, %bar) is better IMO since it conforms to other functions in > > perl. > > my %foo is alias = %bar; #seems a little out of scope of the language, > > unless more functionality is implemented in that way. > > > > Ilya > > > Is there a problem with the following? Besides that it doesn't work > like I want it to? Am I mistaken in believing that it is a clear, > concise and unambiguous way to request assignment of a symbol to > be an alias to another? > > my \%foo = \%bar; > > (And besides that it extends p5 syntax instead of being apo2-compliant?)
freezing, thawing, cloning etc...
hi, I just wanted to ask, 'cause i've not seen info on this anywhere does functionality like those of Storable/Data::Dumper be available in the perl-core ( i mean runtime ) ... thanx = iVAN [EMAIL PROTECTED] =
if then else otherwise ...
hi, we have <=> and 'cmp' operators but we don't have the conditional constroct to use better their result : May be forthcomming switch will solve this in some way, but isn't it better to have shortcut like this : if (cond) { } else {} otherwise {} i.e. if cond == 1 then 'then-block' if cond == 0 then 'else-block' if cond == -1 then 'otherwise-block' If the "if" construct doesn't have "otherwise" it behave like the current "if-else".. = iVAN [EMAIL PROTECTED] =
Re: if then else otherwise ...
I've/m never used/ing "elseif" ( i hate it :") from the time I have to edit a perl script of other person that had 25 pages non-stop if-elsif sequence) ... never mind there is two conditions in your example... of coruse i've think of this just like a shortcut nothing special ... later on : $x = cond ? $then : $else : $otherwise;#at least this is a good shortcut :") > What's the point, you can accomplish the same with if/elsif/else. Maybe I'm > not understanding this correctly, but > > if (cond) > {} > elsif (cond) > {} > else > {} > > Ilya
Re: if then else otherwise ...
> I'm lost. How would you decrease the number of elsif statements with > otherwise??? ]- it is not to decrease the number of "elsif" (this that i hate elsif was just comment :") not that u have to stop using it ), but to give a shortcut ... ok forget about "otherwise" ( i also think no one will accept it, no matter that i like it :") ). But at least the second shortcut is worth it, i think : cond ? then : else : otherwise >And as a matter effect the new perl switch construct would > take care of that. It would be called switch but rather I believe given, if > I remember right. ]- yep "given". now "switch" and "case" are free for something else :") = iVAN [EMAIL PROTECTED] = PS. to David u are welcome to recomend a book, especialy some of the "Learn it in just 24 hours" ... :"), but I already read a couple of books or better recomend some SF-book
Re: if then else otherwise ...
> This makes no sense. ?: tests a boolean value, which is either true or false. > There is no ternary state for a boolean value. True/False, Yes/No, On/Off, > 1/0. Are you suggesting Yes/No/Maybe? Or are you redefining True and False? ]- I'm not talking about boolean's... but mostly this can be result of some expression... The simplest example is <=> and cmp but it also can be some function call that returns : -1, 0, 1 Let me give you one example (that was the reason for my thouights about this ): I have to build a SELECT query and there was three possible combinations to insert one condition into WHERE part i.e.: $whereCond = $cond ? ' field > $x AND ' : '' : ' field < $x AND'; $Query = qq{ SELECT FROM ... WHERE $whereCond ...}; gotcha...short and clear... > Doesn't matter. What you're asking has no counterpart in boolean logic, and > as such would make no sense in any computer language. ]- yes you are right about this... but in the real live we don't have real-TRUE and real-FALSE let's not go further but i think that things like semiTrue and semiFalse incorporated in some way into the language will be very cool addition that no one have...:") i'm dreaming here ... &&& ... ||| :") >You may have an idea, but you are saying it wrong if you do. ]- sorry, you are may be right again :") = iVAN [EMAIL PROTECTED] =
Re: if then else otherwise ...
But at least the second shortcut is worth it, i think : > >cond ? then : else : otherwise This has a vague smell of Fortran. ]- I don't know Fortran sorry :") = iVAN [EMAIL PROTECTED] =
Re: if then else otherwise ...
> Linguistically, "if then else, otherwise" doesn't make sense, since 'else' > and 'otherwise' are synonymous. ]- ok .. I choosed wrong word... I'm not native English sorry... but I agree that if-else-otherwise construct is not so good, for most of the people... I forgot about it already :") > ? : : suffers from the same problem, just in terms of the ternary ?: > operator (which of course, wouldn't be ternary anymore) instead of English. > I'm not sure if there will be ambiguity where the standalone colon is being > used elsewhere, but I suspect that it would make parsing more difficult. > (At least in a BNF grammar.) ]- then may be some other way : cond ? then : else ~ otherwise;# i don't know > Regardless of how you perceive the results of <=> and cmp, it's still two > conditionals. Something has to make the differentiation between positive > and negative. ]- we told trenary not boolean context... is trenary context ok ? we will have many more contexts in Perl 6.66 aren't we ];"):: > You're simply asking for another way of writing 'if {} elsif {} else {}', > because you don't like 'elsif'. Fine. As has been said before, use a > switch. > Still too verbose? Let's look at your example > > > $whereCond = $cond ? ' field > $x AND ' : '' : ' field < $x AND'; > > $Query = qq{ SELECT FROM ... WHERE $whereCond ...}; > > I think if you specify WHERE you need a clause. > 'SELECT foo FROM bar WHERE' doesn't make sense. ]- my mistake sorry. There is "..." if u see, so it is more specificaly : $whereCond = $cond ? ' field > $x AND ' : '' : ' field < $x AND'; $Query = qq{ SELECT FROM ... WHERE $whereCond field2 = (SELECT fieldX FROM blah WHERE fieldA = $id )}; is this way okand this is just example, can figure out some other at the moment, but that is the reason I'm posting here to see all your opinions if it is worth it. If (not) I'm ok ( sorry for your time) else (then OK) otherwise (will see) :") = iVAN [EMAIL PROTECTED] = PS. What type of query to build : $qtype = cond ? SELECT : INSERT : UPDATE; or I'm building a query for update or insert how to decide how the current key -> value pair will be used : this time we are deciding between INSERT, UPDATE or UPDATE-WHERE clause : $kv .= $qtype ? do {$values .= "$v, ", "$k, "} : "$k = $v, " : "$k = $v AND ";#is this correct later : chop,chop...substr..!! $query = "INSERT INTO blah ( $kv ) VALUES ( $values )"; OR $query = "UPDATE blah SET $kv WHERE something..."; OR $query = "UPDATE ..something... WHERE $kv"; More examples : = index(ref $var, 'A') - 1 ? SCALAR-LVALUE-case : HASH-case : ARRAY-case; i.e. index(ref $var) - 1 ? $v = $var : $v alias $var : @v = @$var; = form-field-type ? : : ; = output-type ? print-to-web : print-to-stdout \n : print-to-STDERR; = $x = $a <=> $b ? $a : $default : $b; can figure out more at the moment :")
Re: if then else otherwise ...
> in ?:: or any other condition checking block, 0 is true, everything else is > false. I am yet to see why otherwise or any third condition is needed. If > that's then we can have 4 conditions 1,0,-1,undef, and we can keep going. > That is why there are conditions, if you want to check for -1 you must > specifically do it. > > if($foo == 1) > {} > elsif ($foo == -1) > {} > elsif (!$foo) > {} > else > {} ]- then why to use "else-elseif" at all when we can use "goto" instead..:") ... why the languages use two-state(boolean 1/0) when they can use one-state(1) and still have their work done SHORCUTs/PATTERNs that is > I know this is a dead issue, but I just can't see how some people actually > see the logic in having three conditions 1,0,-1. What about -2, -3, etc... > The whole purpose in ?:: is to deferentiate between true or false, weather > it be 1|0 2|0, -1|0, doesn't matter is still true or false. ]- it is not -2,-3 ... it is -1,0,1 or if u want t -infinity,0,+infinity... tristate ... forgot about boolean for one moment... IT IS SHORCUT. ok i'ill not urge u moreenought... see... but what about.if ... we can... can we ?... ok let's talk about something else. thanx for your time. = iVAN [EMAIL PROTECTED] =
the Parser
hi, I see nobody is talking here ... so ! Anyone to have idea how the Parser will work... I mean mostly at the language-developer side (not the internals). It will be written in Perl, right ?! some striped-version of Perl ?! i.e. what will be allowed and will not ? Will it support lookahead, lookbehind and backtrack ? Some samples ? How we will hack on it ? As far as I remember it will be compiled to bytecode. I saw on Damian site that Perl5/6 parser based on Fast::RecDescent is pending ?! As the Fast::RecDescent itself :") At all what do U think ! = iVAN [EMAIL PROTECTED] =
Re: two-way hashes
> >I want to say also : > > > >{value}hash% = key; > Just use two hashes for this purpose. If you can write a class that help > keeping > track of the two hashes, that will be more useful than inventing weird > syntax. ]- this was not a proposed syntaxI was just joked about it ... sorry. :"|
Re: new syntax idea: eval "..."o;
> David L. Nicol wrote: > > eval ${code}o; > > Another brilliant idea from David Nicol! > > However, I'm not keen on the syntax. > I'd rather see a different keyword. I'm thinking "eval1", > but I'm not very creative. :-/ ]- what about : qe//;# qe{}; OR qo//
That could be interesting ... CPAN? and why there is no C/C++ CPAN
http://www.kuro5hin.org/story/2001/6/8/11126/34098
Qouting and white-space etc..
hi, I was wondering if there was some way when using qouting to specify triming of white space or other type of charachters we may need ... say like TT or may be ...one example.. my $javascripCode = qq{ | |function blah() |if ( ) |}; | }; |<-inner spaces/tabs preserved and I want to have some syntax so I can specify that First and Last "\n" be removed, plus the whole script body goes one tab to left... i.e. removed first X \t (the number of tabs/spaces removed depends on the position of
!< and !>
hi, I was looking at Interbase SELECT syntax and saw these two handy shortcuts : = {= | < | > | <= | >= | !< | !> | <> | !=} !< and !> Personaly i didn't liked if (! ...) construct too much, so even that starting to use "unless" is harder for non-english speaker, I think is much cleaner and good. Particulary 'cause if(!...) is harder to spot... but moving it near to comparison operator looks good of cource not the same with !ne , !eq .. = iVAN [EMAIL PROTECTED] = PS. In my native language we doesn't have a word that fit best to "unless"(if not) ...
Re: !< and !>
| | > !< and !> | | How is !< different from >=? ]- the way of Expression or syntax-sugar if u like it :"), and is faster to prononce :") if, if not, unless bigger, smaller, equal less than or equal, bigger than or equal not bigger, not smaller ...etc. Personally I almost always make error when type '>=', my hands go faster and I write '=>' insteadnot that this matter much.. = iVAN [EMAIL PROTECTED] =
Re: LangSpec: Statements and Blocks [first,last]
hi, As we read in Damian Conway- Perl6-notes, there will by a var-iterator that can be used to see how many times the cycle has been "traversed" i.e. foreach my $el (@ary) { .. do something print $#; <--- print the index (or print $i ) } shall we have : foreach my $el (@ary) { print $# if $#.first(); <--- print the index on the first iteration i.e. 1 .. do something print $# if $#.last(); <--- print the index on the first iteration i.e. $#ary }; note : we can iterate on something else not only array OR : foreach my $el (@ary) { print $# if first; .. do something print $# if latest; }; = iVAN [EMAIL PROTECTED] = PS. One place where TT is before Perl :")
Re: LangSpec: Statements and Blocks [first,last]
| I don't know if (and if so, how) you would see if you were on the last | iteration. (And would that be last, as in the very last argument passed in, | or last, as in you're not going to iterate again?) ]- yep I didn't thougth about that I can be sure I'm at the last iteration only with some sort of 'callback' which will be called at the exit of the loop... but not as some sort of generalised-check condition.. = iVAN [EMAIL PROTECTED] =
Re: LangSpec: Statements and Blocks
will the iterator variable be available in map, grep, join...etc... I was also wondering if the join syntax be extended in a way that it can support preffix and suffix... what i have in mind ... not necesary but : #pair join ($prefix => $suffix), @ary; so : my $select = join (qq{} => ''), @ary; or is better to stay like this : my $select; map { $select .= qq{$_} } @ary; = iVAN [EMAIL PROTECTED] =
Re: General Feelings on Apoc 3
I think this would be interesting for U :") http://www.cs.yorku.ca/Courses/3401/lectures/340198-11-27HTML/ http://www.cogs.susx.ac.uk/local/books/nlp-in-prolog/ch04/chapter-04-sh-1.5. html#sh-1.5 | On Thu, 4 Oct 2001, Michael G Schwern wrote: | | > > Backtracking is at the heart of Logic Programming (or Declarative | > > Programming, if you like). This is one of the 3 main programming paradigms | > > (along with procedural and functional). The most popular Declarative | > > language is Prolog. It is great for writing programs that are largely about | > > resource allocation and constraints. There's some links to start you off | > > here: | > > | > > http://foldoc.doc.ic.ac.uk/foldoc/foldoc.cgi?backtracking | > | > Sounds like a chess computer. | | It kind of struck me that this type of concept might be handy for writing | parsers directly in Perl without an 'intermediate' parsing language. Or | for making it easier to write such an intermediate language. | | - D | | <[EMAIL PROTECTED]> |
:= The bind
Is the following correct for := : left side is like function in the respect that the right side is treated differently depending on the left-side-types i.e. left side is like prototype!! for the right side. (@a ,@b) := (@b,@a) is the same as : (\@a, \@b) = (\@b, \@a);#if we had ref-allowed on the left in perl5 of cource :") ($x,@y) := (@b, @a) is the same as : ($x, \@y) = ($b[0],\@a); Which is most close explanation : BIND or ALIAS = iVAN [EMAIL PROTECTED] = PS. we have := now we have to get 'with(){...}' too :") In the past I could tell : ( cond ? res1 :'') now it is ( cond ?? res1 ::'') So these operators are still free --->':)' and ':")' And also : print4 @all instead of : print for @all :")
Another link [ Re: General Feelings on Apoc 3 ]
http://www.perlmonks.org/index.pl?node_id=71319&lastnode_id=71484
use parrot;
hi, will it be possible to do this inside Perl program : use parrot; ...parrot code... no parrot; OR sub mysub is parrot { parrot code ... } = iVAN [EMAIL PROTECTED] =
Re: Hyper-operators and Underscore
I find underscore also a little bit mesleading, but at least will not broke my code (I was never using underscore in identifiers, I'm using Upercassing i.e. $yetAnotherVar ) :") = iVAN [EMAIL PROTECTED] = PS. it is time new keyboard to be invented :")
continuation .... ?
hi, Any idea what the "continuation" will be ? Something similar like while(){..}continue{..} construct, but more primitive/lower-level ? { my $val = 10 } -=> { print $val; $val = 11 } -=> { print $val } prints 10 and 11 i.e. lexicals of BLOCK1 are preserved for BLOCK2 and BLOCK3 i.e until continuation ends.. { my $val = 10 } -=> { print $val; somesub(); $val = 11 } -=> { print $val } somesub() still have access to $val . Or it will do other things too, not only extending the lexical scope... Just thoughts !!! = iVAN [EMAIL PROTECTED] =
Re: NaN semantics
| So the imaginary numbers would be standard literals? Like | | $x=2+10i; | | Great idea, as well as sqrt(-1) returning 1i istead of raising the | exception. BTW, I was thinking once that numeral literals like 4k or 10G | (meaning 4*2**10, 10*2**30) would be very nice. What do you think? I like the idea ... this is one of the ways to suspend the calculations to the last moment... But one probelm comes to my mind, what the k,G etc mean 1000 or 1024 or k => 1000, K => 1024 Or probably the best way will be to have a hook so that we can specify what is a Number and how it has to be calculated down to the real number...!!! = iVAN [EMAIL PROTECTED] =
Re: NaN+NaNi
| > As for more complex string literals evaluating to numbers, I think that's | > something best left to either a user-written sub, or user-written fancy | > parser hacks. Up to Larry whether it goes in the base language, but I think | > I'd prefer not. | | Speaking of string turning into numbers ... | | It's bothered me that I can write 100_000 in my perl code, but if I have | a string "100_000" it'll evaluate to 100 when numerified. It would be | really weird if "10indigo" became 10i, "1e3foobar" became 1000, and | "10_000" became 10 in Perl 6 IMHO. ]- Agree if u want this in strings then use : "$( 10i ) ndigo" "$( 1e3 ) foobar" = iVAN [EMAIL PROTECTED] =
Indenting
Hi, I was looking at TPJ one-liners and saw this : #32A trick for indenting here strings ($definition = <<'FINIS') =~ s/^\s+//gm; The five varieties of camelids are the familliar camel, his friends the llama and the alpaca, and the rather less well-known guanaco and vicuna. FINIS Courtesy of The Perl Cookbook It is very cool if we have a way to set this RegEx so that it executes in compile time I mean if we have the ability to set this, so that we have any funny formating we want w/o loosing the speed of parsing it at runtime... Or it works that way !! already.. cheers = iVAN [EMAIL PROTECTED] =
Ex4, Apo5, when ?
Did u passed "Bermuda Triangle" :") raptor
VM, closures, continuation
I was just reading this : http://www.javalobby.com/clr.html and a question raised to me. Will Parrot have some optimisation (features) that will speed up closures & continuation ? raptor [EMAIL PROTECTED]
Apo-Ex arhive
hi, I thought it will be good if on dev.perl6.org we have an arhive with all Apo's and Ex's, so anyone can get them in pack... (prefebaly printed version) Throught the links I got all except Apo1. Anyone to have the link nearby iVAN [EMAIL PROTECTED] - Danke very much :")
Re: I'll show you mine...
great idea :") I've just tried gnuCash program and think it is very cool (i've enjoyed to take first steps in double-entry accounting, i was always wondering what the hell is this :") )... http://www.ncsysadmin.org/july2001/ncsa-gnucash-talk.html#toc1 (very entertaining intro :") ) Meanwhile during browsing the docs i found that there was a way to extend the program but via Scheme (it had possiblity to be extended via perl at the begining but now not, for some their reason !!!). And so I wanted always to learn Prolog & Lisp and so now I'm reading the Scheme online book : http://www.scheme.com/tspl2d/index.html It looks very cool, so go for it... i hope i will learn it :") = iVAN [EMAIL PROTECTED] PS. Before a couple of years I was using happily Windows and one my friend told me (arguing constantly ) do u know that Linux is very cool (no matter it used Win :")) .. so i got a book and started to learn Linux, i read about awk and started to write a report program (parsing IIS,proxy etc.. logs), meanwhile i constantly saw Perl examples in the same book, and also precaution that Perl is much more powerfull and hard to learn, so be prepared to spend alot of time. so one day i decided this awk is cute but what if i try Perl ? And on the third week my program much more featurefull was ready :") (up to this time i used only pascal & basic) The good things always happen acidently .. So ... Thank you very much.
Re: Loop controls
]- me too . |I actually like Andy Wardly's suggestion of iterators. It makes a lot of |sense and looks a lot cleaner to read and write and adds less new syntax |to remember (and parse). | |Clayton raptor
Re: Loop controls
|Oh! I have an idea! Why don't we make the lexer just realize a prefix |"els" on any operator. Then you could do C. :P | |My point is that, IMO, this whole "els" thing is completely preposterous. |I'm the kind of person that likes to keep down on keywords. And I never |liked Perl5's C anyway; I always preferred C. I really |don't understand what at all is appealing about C. ]- yeah i think we better stay away from all those elsxxx nightmare ... and don't go to the trap of those or similar abbreviation ... Better have else xxx (whatever this xxx is).. i think we should do abbreviatoins only on something we use very often.. |Here's my synopsis of how everything's gone so far: | |We have the following syntaxes for elses on loops (for any kind, not just |loop). | loop ;; {} else {} | loop ;; { else {} } | loop ;; { ELSE {} } |Or replace any of these with C. | |Furthermore, we have a couple of different ways for loops to come after |elses: | elsloop ;; {} ]- pls nooo... | else loop ;; {} | else { loop ;; {} } | |I don't think C has been proposed :). ]- better no :") |If anyone has other ideas, or an insanely good reason why one of these is |optimal, we're all ears. I think we all trust Larry to make the right |decision, but he might not be God. New ideas are good. ]- This whole thread lead us to think we need one compound word/s-construction that ]handle condtions & loops in a common way... which is a good thing i think :") i.e. loops and conditions to become a special cases of this.. == iVAN [EMAIL PROTECTED] PS. I can't remember was this discused but will we have pre-post handlers to sub's ... will we have this ability for {blocks} and then is the loop some sort of block, so that we can attach these too :")
Re: Loop controls
|On Mon, Apr 29, 2002 at 02:55:09PM -0500, Allison Randal wrote: |> I still don't like the idea of Cs on loops. I already do an |> instant double take with C of "Where's the if?" (with visions of |> old Wendy's commercials dancing in my head). | |Me too. That's why the looping "else" should be spelled "otherwise" |IMHO. ]- count me too...
Re: Loop controls
|> Damian, now having terrible visions of someone suggesting C ;-) | |Then may I also give you nightmares on: elsdo, elsdont, elsgrep, elstry ... ]- unlessdo, unlesdont, unlessgrep, unlesstry what about "elsunless/unlesselse" then :")
Re: Loop controls
perfect... in fact during the middle of the read someting similar come to my mind.. i.e the best way should be to have several in-loop-proprietes that we can test and decide what to do ... There have to be CAPITALISED words only for the block stuff ... raptor
PRE-POST methods [Was: Selective exporting of properties/methods]
]- I can't remember but i think I read somewhere or it was discussed here (can't ]remember), but I think it was mentioned that Perl6 will have PRE and POST method/sub ]handlers probably specified as attribute, so that (syntax may be wrong): class XXX { method blah is PRE {} method blah {} method blah is POST {} } is ok.. not sure about the FALSE-condition that prohnobit the blah-method-call ? One more thing I was wondering would it be possible to define a method/sub with different signatures but with the same name ? ( i think yes, ?Class::Multimethods?! was doing that aren't it ?) raptor PS. One thing just pooped to me... is the "class { }" a block so that we can do all block mumbo-jumbo with it :") |> What I've often wanted would be standard method that is called before |> every |> subroutine call. If that method returns false then the method that was |> called is not called. | |I think maybe what you're looking for is another Eiffel/Sather-ism. I |know Eiffel at least has both pre and post-conditions that look |something like this(it's been a while, so if this isn't quite right): | |class | ACCOUNT |creation | make_with_balance |feature { BANK } | balance: INTEGER | make_with_balance(initial_balance: INTEGER) is | require | initial_balance >= 0 | do | balance := initial_balance | ensure | balance >= 0 | end |end | |I too have thought this might be useful in Perl6. Perhaps... | |class Account { | my INT $balance; | method new(INT $initial_balance //= 0) { | REQUIRE { $initial_balance >= 0; } | $.balance = $initial_balance; | ENSURE { $.balance >= 0; } | } |} | |
Re: 6PAN (was: Half measures all round)
|On 6/4/02 12:22 PM, David Wheeler wrote: |> I think that if we can agree to forego backwards compatibility, we might |> also be in a better position to set up a CP6AN with much better quality |> control. All of the most important modules will be ported very quickly |> (e.g., the DBI), and a lot of the cruft will be left to die (at least from |> the Perl 6 perspective). | |Speaking of "CPAN for Perl 6" (or "CP6AN", or "6PAN"), what's the status of |this effort? Do we even have a vague idea of the requirements? Or does |everyone think CPAN (and module distribution/installation in general) as it |exists now it pretty much okay, and just needs some tweaks to work with Perl |6 code? I really hope that's not the case! :) ]- I think there is CPANTS initiative underway which may be will solve some of ]problems of the current CPAN... there was even a write-up on www.perl.com about it ...
<= ?
I've seen in theDamian Sypnosys following code : $val <= $key does this mean that we now have also reversed syntax possible for hashes ? and pairs too ? raptor
what's new continued
me again, At the moment based on Apo1->4 no ex's "walked" yet. - There is a questions inside feel free to answer ... [?? ... ??] - Also links for other reference implementation will be good. - Also feel free to correct my english :") What's new ? Let me first mention this is in no means full list of the new features in Perl6, this is mostly a list pf those features I find most entertainig. For a detailed description look at all these links : http://dev.perl.org/perl6/apocalypse/ http://dev.perl.org/perl6/exegesis/ http://dev.perl.org/perl6/synopsis/ And to see what the Larry and crew had to take into account look here : http://dev.perl.org/rfc/ So lets start 1.) Proprietes == reference implementation : Attribute::Types, Attribute::Handlers, Attribute::Handlers::Prospective http://www.cpan.org/authors/id/DCONWAY/Attribute-Types-0.10.readme http://www.cpan.org/authors/id/DCONWAY/Attribute-Handlers-0.76.readme http://www.cpan.org/authors/id/DCONWAY/Attribute-Handlers-Prospective-0.01.readme Every subrotine or variable or method or object can have a "notes" (out of bound data) attached to it and they are called "properties". (Internally properties are hashes --> pHash). The proprietes can be compile time and run time... (the common case is they to be compile-time) Samples : my $x is constant = 5;#this says that $x is constant and its value is 5 my $x is foo = 0; Now $x.foo is equal to 1, but $x is 0. In fact $x.foo is interpreted as method call i.e. $x.foo(). If there is no method with name foo() then such method is pretended to exist and it returns the value of property with that name. $x.prop will return hash-ref to properties hash i.e. pHash-ref. So that : print keys %{$x.prop} will print "foo" (and probably if SCALAR's have some default props they will be printed too) U can also just use : print keys $x.prop since the hash ref returned by .prop will be automatically dereferenced by the hash context of "keys". (In Perl6 we will have much more contexts than that we had under Perl5. Here are part of them : Void context Scalar context Boolean context Integer context Numeric context String context Object context List context Flattening list context (true list context). Non-flattening list context (list of scalars/objects) Lazy list context (list of closures) Hash list context (list of pairs) And we will have much more powerfull "want" operator so that we can check the context in which the sub are executed. ) U can specify more props at once and also skip "is" keyword like this : my $i is constant note('I use this var for loop counter') maxValue(100) = 0; instead of : my $i is constant is note('I use this var for loop counter') is maxValue(100) = 0; then : print $i.prop{note} should print "I use this var for loop counter". 2.) Multiway comparison == Now we can say : 0 <= $x <= 10 to check if $x is between 0 and 10 inclusive i.e. 0 <= $x && $x <= 10 3.) Hyper operators == Cool no more loop-in-loop-in-loop:"). All operators can be hyper-ed simply prepend them with "^" - upper-cap. Samples : @a ^* @b multyplies both arrays and will return a list of ( $a[0]*$b[0], $a[1]*$b[1], ... $a[n]*$b[n] ) OR ( @a[0]*@b[0], @a[1]*@b[1], ... @a[n]*@b[n] ) if we use Perl6 notation/syntax. @a ^+ 1 will return a list of all elements of @a increased by one. (@a stays uncanged). @a ^&& @b will produce a list of (@a[0] && @b[0], @a[1] && @b[1] ...) @a ^|| @b will produce a list of (@a[0] || @b[0], @a[1] || @b[1] ...) Here is how in one sweep we can change some text in every element of array : @foo ^=~ s/foo/bar/ And how to increase the elements of array with 1 but this time applying the changes to the @a @a ^+= 1 we can even have hyper-assignment : my ($a, $b) ^= new Foo; The expression below will not distribute over $a and $b : my ($a, $b) = new Foo; Let's someone of the anti-perl camp tell me that this "upper-cap noise" makes the code hard to read and I will smash him with a hammer in the head :") and leave him to type "from here to tommorow loop after loop after loop after loop" :"). Gees those perl designers with LW in the head are mad-scientists . 4.) Binding == In addition to the standard assignment operator of perl5 "=" we will also have ":=" i.e. bind operator. If you're familiar with Prolog, you can think of it as a sort of unification operator (though without the implicit backtracking semantics). In human terms, it treats the left side as a set of formal arguments exactly as if they were in the declaration of a function, and binds a set of arguments on the right hand side as though they were being passed to a function. This is what the new := operator does. Another way of thinking of it is that: $a
Re: what's new continued
|Comments (otherwise you have things pretty much right): ]- that is good :") | |> Every subrotine or variable or method or object can have a "notes" (out of bound |data) |out-of-band data ]- yep |> we can even have hyper-assignment : |> |> my ($a, $b) ^= new Foo; | |This is unlikely to do what you wanted. It creates a new Foo object and then |assigns a reference to that one object to both $a and $b. It doesn't create two |Foo objects. (But maybe one object referenced twice is what you wanted). ]- i've got it from here : For historical reasons, the assignment in my ($a, $b) = new Foo; will not distribute automatically over $a and $b. If you want that, use the ^= hyperassignment instead, maybe. But probably i havent understood it ! | |> Let's someone of the anti-perl camp tell me that this "upper-cap noise" makes the |code hard to read and I will smash him with a hammer in the head :") and leave him to |type "from here to tommorow loop after loop after loop after loop" :"). Gees those |perl designers with LW in the head are mad-scientists . | |Do you really need to say this? ]- no just kidding :") | |> 7.) Quantum superpositions === |> |> case2 - hyperoperator : |> |> my $result = 0; |> for ($a,$b,$c) { |>if ($x == $_) { $result =1; last} |> } | |Not correct. The second case is the same as: | | ($x == $a, $x == $b, $x == $c) | |which reduces in effect to: | | $x == $c ]- i see now... so if ',' works the Perl5 way, then all are ecaluated but the result ]is the result of the last comparison, but in superposition if for some comparision we ]have true the rest are not evaluated.. |> and all they (except CATCH) are in fact proprietes of the block | |So is CATCH. ]- i see, i havent read it well : There is, however, no catch property to go with the CATCH block. thanx