Re: CGI Session management (was Re: the CGI.pm in Perl 6)
I agree completely. In that vein, I think that one thing a lot of web developers would like to have available more easily would be session management. In PHP it's as simple as $_SESSION['key'] = 'value'. I understand that CGI.pm is a fundemantally different concept from PHP and that this can't be completely taken care of by the module. Still, if something could be written in, I think it would make many people's lives simpler. In Perl 5, CGI::Session is one solution that feels this gap well. In frameworks like CGI::Application, sessions can be integrated so they are apart of the of the same object anyway: self.query -- CGI.pm object self.session -- CGI::Session object. As far as I'm aware, no work on CGI::Session for Perl 6 has started yet. I'm sure there will be some things that would be nice to change about it as well, as it currently has some features only for backwards compatibility. Mark
best practice for web form stickiness (was: Re: the CGI.pm in Perl 6)
Juerd wrote: Personally, I am *against* HTML generating for elements that are not form fields. And for form fields, I think the solution should be in the templating thing, not elsewhere. Stickiness makes sense on invalid data only anyway, and we need to put the error message and a pointer somewhere, and those are also templating things. Even the simple contact page is much better off with a nice templating tool, than with HTML generating methods. I think HTML::FillInForm is a much better way to handle form stickiness. It allows you to keep the form generation in HTML /and/ still support stickiness. So, it's fine with me if the sticky feature of CGI.pm doesn't re-appear. Mark
use perl5:CGI as a solution (was: Re: the CGI.pm in Perl 6)
Aankhen wrote: The major feeling was that there should be no CGI.pm (if someone was hellbent on using it, they could use the Perl 5 module). In theory, use perl5:CGI could be a fine solution. In practice, it hasn't worked out well for me. Even something that seems simple like passing a hashref to Perl 5 is not documented now. In summary, I found it easier to update CGI.pm p6 to meet my needs than to 'use perl5:CGI' to meet my needs. I think the reality it is yet to been seen now well calls to Perl 5 modules can work for the general case. Mark
Index of terms
It would be useful to have a consolidated global index into the synopses, etc. Also, I noticed in a thread someone asked a question that arose because some topics are covered in more than one synopsis. This problem might eased if a single index had links for all documents in a single place.
Trying to make a new operator
I tried to make a new growth operator. The code was (32 + 48).say; sub infix:+ ($left,$right) { return 100 * ($right/$left -1); }; $pugs ./p6test.p6 returns with 50 But if I change the + character to (say) a cyrillic letter Д, I get the following error: $ pugs ./p6test.p6 *** unexpected \1041 expecting operator or ) at ./p6test.p6 line 1, column 5 I also tried other latin characters, but I get errors. It seems I can change an existing operator, but not introduce another. What am I doing wrong?
Re: Trying to make a new operator
What am I doing wrong? Sounds like you need to define (or at least declare) the new operator before you use it. Perl 6, like Perl 5 compiles with a single pass, so when you are using your random operator, it hasn't yet read the declaration further down the file. It does its best to DTRT with most functions, but when you're defining arbitrarily random operators, it can only be so clever. -- Sufficiently advanced humour is indistinguishable from tedium. corollary: Humour distinguishable from tedium is insufficiently advanced. http://surreal.istic.org/ Hack code until it works, then stop. pgpvoliG9dy3X.pgp Description: PGP signature
more on perl5 modules
The .can workaround doesnt seem to work for more complex modules. Here is a working perl5 program that puts up a message with two buttons. use strict; use Gtk2 -init; use Gtk2::Ex::Dialogs(destroy_with_parent=-1, modal=-1, no_separator = 0); my $window = Gtk2::Window-new('toplevel'); Gtk2::Ex::Dialogs-set_parent_window( $window ); my $r = Gtk2::Ex::Dialogs::Question-ask( Is Perl only hackers glue?); if ($r) {print yes\n;} else {print no\n;}; Here is an attempt to do the same in perl6 use v6; use perl5:Gtk2 -init; say called Gtk3 init; my $window = initialise(); say window initialised; use perl5:Gtk2::Ex::Dialogs(destroy_with_parent=-1, modal=-1, no_separator = 0); our gsetparent := Gtk2::Ex::Dialogs.can('set_parent_window'); say Now trying to use the window; gsetparent( $window ); our ask := Gtk2::Ex::Dialogs::Question.can('ask'); my $r = ask( Is Perl only hackers glue?); if ($r) {say yes;} else {say no;}; sub initialise () { # I took this eval(uation) of perl5 by pugs from one of the examples in the pugs distribution eval (q! my $win = Gtk2::Window-new('toplevel'); $win; !,:langperl5); }; Here is the output $ pugs ./gtk2_test.p6 called Gtk3 init window initialised Now trying to use the window Undefined subroutine main:: called. I tried a variety of coding techniques. None seems to work. eg., our gwin := Gtk2::Window.can('new'); our gwin := Gtk2.can('Window-new'); our gwin := Gtk2.can('Window.new'); The problem seems to be that Gtk2::Window does not exist as a separate module, viz., there is no Window.pm in the Gtk2 directory space. Any ideas?
perl6 and a multi-interpreted-language example
I just took a second glance at my post and saw the scoping error in the $steps variable. Please don't bother fixing it-- I want to know what a perl6 version would be like :)
Re: Web development I: Web::Toolkit
Aankhen skribis 2006-09-17 11:54 (-0700): The point is not to have autogenerated code conform to the XHTML standard. The point is to not use XHTML simply because it's shiny. That's a good point, but my point was different. XHTML should be a conscious choice, not a default, in a general purpose web development library. -- korajn salutojn, juerd waalboer: perl hacker [EMAIL PROTECTED] http://juerd.nl/sig convolution: ict solutions and consultancy [EMAIL PROTECTED]
Re: more on perl5 modules
* Richard Hainsworth [EMAIL PROTECTED] [2006-09-17 18:05]: The .can workaround doesnt seem to work for more complex modules. Err, the .can workaround is a way to get past missing sub exports. Methods are never exported. Why are you using the workaround for sub exports on methods. Here is a working perl5 program that puts up a message with two buttons. use strict; use Gtk2 -init; use Gtk2::Ex::Dialogs(destroy_with_parent=-1, modal=-1, no_separator = 0); my $window = Gtk2::Window-new('toplevel'); Gtk2::Ex::Dialogs-set_parent_window( $window ); my $r = Gtk2::Ex::Dialogs::Question-ask( Is Perl only hackers glue?); if ($r) {print yes\n;} else {print no\n;}; Should be simply: use perl5:Gtk2 '-init'; use perl5:Gtk2::Ex::Dialogs :destroy_with_parent( -1 ) :modal( -1 ) :!no_separator; my $window = Gtk2::Window.new( 'toplevel' ); Gtk2::Ex::Dialogs.set_parent_window( $window ); my $r = Gtk2::Ex::Dialogs::Question.ask( Is Perl only hackers glue? ); say $r ?? 'yes' !! 'no'; Regards, -- #Aristotle *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}; Just-another-Perl-hacker;
Re: perl6 and a multi-interpreted-language example
* William Herrera [EMAIL PROTECTED] [2006-09-17 21:50]: perl 5 (9 lines, 353 bytes) use FreezeThaw qw(cmpStr); my @a1_9 = (1 .. 9); my @numbers = sort {rand(10) $a} @a1_9; for (my $steps = 0; cmpStr([EMAIL PROTECTED], [EMAIL PROTECTED]); ++$steps) { print join( , @numbers), \nReverse how many? ; my $flipcount = STDIN; @numbers[0..$flipcount - 1] = reverse(@numbers[0..($flipcount-1)]); } print Done! That took you $steps steps.\n; To be fair, Perl 5 can be a good deal nicer. 10 lines, 316 bytes, and much less punctuation: use List::Util 'shuffle'; my @numbers = shuffle my @goal = ( 1 .. 9 ); my $num_steps; while ( @numbers ne @goal ) { print @numbers\nReverse how many? ; my @slice = 0 .. STDIN - 1; @numbers[ @slice ] = reverse @numbers[ @slice ]; ++$num_steps; } print Done! That took you $num_steps steps.\n; Regards, -- #Aristotle *AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(,$\/, )[defined wantarray]/e;$1}; Just-another-Perl-hacker;
Re: perl6 and a multi-interpreted-language example
su, 2006-09-17 kello 20:36 +0200, Juerd kirjoitti: while (@numbers[] ne @numbers.sort()) { Should Ceqv be used here? while @numbers !eqv @numbers.sort { -- Ilmari Vacklin [EMAIL PROTECTED] signature.asc Description: Digitaalisesti allekirjoitettu viestin osa