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. snip - apo3 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. /snip Another way of thinking of it is that: $a := $b makes $a another name for the variable
= ?
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
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 ...
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: Loop controls
|On Mon, Apr 29, 2002 at 02:55:09PM -0500, Allison Randal wrote: | I still don't like the idea of Celsifs on loops. I already do an | instant double take with Celse 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 Celswhen ;-) | |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
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: 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.
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 :)
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]
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] =
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] =
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: 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 :)
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{option value=$_} = '/option'), @ary; or is better to stay like this : my $select; map { $select .= qq{option value=$_$_/option} } @ary; = iVAN [EMAIL PROTECTED] =
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 :)
! and !
hi, I was looking at Interbase SELECT syntax and saw these two handy shortcuts : operator = {= | | | = | = | ! | ! | | !=} ! 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) ...
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{ |script |function blah() |if ( ) |}; |/script }; |-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 script, u gottcha) Yes I know I can use regex... Similar like : snip Perl6-notes Here docs . RFC 111: Here doc Terminators . RFC 162: Here doc contents . Whitespace no longer significant before here doc identifier . Whitespace no longer significant before or after here doc terminator (nor are semicolons) . Identifier must be quoted . Here doc contents left-shifted according to whitespace before terminator example /snip but inner space/tabs are preserved.. = iVAN [EMAIL PROTECTED] =
That could be interesting ... CPAN? and why there is no C/C++ CPAN
http://www.kuro5hin.org/story/2001/6/8/11126/34098
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. :|
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: 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 ? select : input : textarea; = output-type ? print-to-web BR : 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] =
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: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] =
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'?]
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 - 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: 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
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
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: 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] =
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] =
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 !!! snip List Comprehensions This is a flexible new notation for lists whose elements are computed from another list (or lists). The simplest form is: [expression for variable in sequence] 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: [expression for variable in sequence if condition] 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] /snip thanx = 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] =
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 condition then ...do something... while condition then ...do something... just thoughts, nothing w/o we can live ofcourse ;") = iVAN [EMAIL PROTECTED] =
Check this !! messaging langage or so ...!!!
hi, snip 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. /snip 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] =
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 = FILE; 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
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] =
Re: RFC 104 (v1) Backtracking:example
hi jeremy, all, here is one simple example , let say we have this XML file: root unit q/q answertag/tag/answer /unit unit q/q answer desc code/code /desc /answer /unit unit q/q answer code/code /answer /unit /root 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 code 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 unit 3. Is this code - no 4. Give me the next node child - context changes to first q 5. Is this code - no 6. Give me the next node child - no childs 7. Give me the parent - context changes to first unit 8. Give me the next node child - context changes to first answer 9. Is this code - no 10. Give me the next node child - no childs 11. Give me the parent - context changes to first unit 12. Give me the next node child - no MORE childs 13. Give me the parent - context changes to first root 14. Is this code - no 15. Give me the next node child - context changes to second unit ...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 code 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 code" 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 code 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 ]- BIG GREEN 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 snip 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. /snip I think the idea of leaving the value "j" in "i j" is cool... = 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 } Bandthen { 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 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: 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 "textBR"; OR printtd, printtr print "TDtext/TD"; 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 BR's at the end ALSO ... print @array; must work like this : foraeach (@array) { print "$_\n"}; foraeach (@array) { print "$_BR"}; not like at the moment : foraeach (@array) { print $_}; = 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: 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] =
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.