 |
| Recent blog posts: | |
 |
| Forums: | | |
 |
| Discuss: | |
 |
| Recent forum topics: | |
 |
| Recent forum comments: | |
 |
| Модератор: | |
 |
Thursday, 5 March 2009
|
| r25693 - docs/Perl6/Spec Guest 01:30:37 |
| | Author: lwall Date: 2009-03-04 23:30:37 +0100 (Wed, 04 Mar 2009) New Revision: 25693
Modified: docs/Perl6/Spec/S12-objects.pod Log: clarify enum vs sub for moritz++
Modified: docs/Perl6/Spec/S12-objects.pod =================================================================== --- docs/Perl6/Spec/S12-objects.pod 2009-03-04 22:27:08 UTC (rev 25692) +++ docs/Perl6/Spec/S12-objects.pod 2009-03-04 22:30:37 UTC (rev 25693) @@ -14,7 +14,7 @@ Date: 27 Oct 2004 Last Modified: 4 Mar 2009 Number: 12 - Version: 72 + Version: 73 =head1 Overview @@ -1293,7 +1293,7 @@ An enum is a low-level class that can function as a role or property. A given enum value can function as a subtype, a method, or as an ordinary -value (an argumentless sub). The names of the values are specified as a list: +value. The names of the values are specified as a list: my enum Day ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; my enum Day <Sun Mon Tue Wed Thu Fri Sat>; @@ -1411,7 +1411,6 @@ $x.does(day) $x.day == Tue day($x) == Tue - Tue($x) $x.Tue all return true, and @@ -1436,6 +1435,23 @@ type C<bit>. Never compare a value to "C<true>", or even "C<True>". Just use it in a boolean context. +Like type names, enum names are parsed as standalone tokens +representing scalar values, and don't look for any arguments. +Unlike type names which are undefined protoobjects, enums are defined +constant values. Also unlike types, they do not respond to C<.()>. +They may not be post-declared. + + our enum Maybe <OK FAIL>; + sub OK {...} + $x = OK; # certainly the enum value + $x = OK() # certainly the function + +Since there is an enum OK, the function OK may only be +called using parentheses, never in list operator form. (If there is +a collision on two enum values that cancels them both, the function +still may only be called with parentheses, since the enum symbol +is "poisoned".) + Enum types (and perhaps certain other finite, enumerable types such as finite ranges) define a C<.pick> method on the protoobject of that type. Hence:
|
| | Add comment |
Wednesday, 4 March 2009
|
| Re: user sessions Gunnar Hjalmarsson 21:09:31 |
| | Stanis aw T. Findeisen wrote:
Hello, how to make user sessions? Something like: * log in using password * maintain session state across several executions of several scripts forming the application * log out Do I have to do it manually or is there something ready that you can recommend? http://search.cpan.org/search?query=session
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
|
| | 1 answer | Add comment |
|
| r25684 - docs/Perl6/Spec Guest 19:27:18 |
| | Author: lwall Date: 2009-03-04 17:27:17 +0100 (Wed, 04 Mar 2009) New Revision: 25684
Modified: docs/Perl6/Spec/S03-operators.pod docs/Perl6/Spec/S12-objects.pod Log: [S03] deprecate TOP in favor of .parse and .parsefile [S12] mention restriction on calling class metamethods when there isn't a class
Modified: docs/Perl6/Spec/S03-operators.pod =================================================================== --- docs/Perl6/Spec/S03-operators.pod 2009-03-04 09:53:11 UTC (rev 25683) +++ docs/Perl6/Spec/S03-operators.pod 2009-03-04 16:27:17 UTC (rev 25684) @@ -12,9 +12,9 @@ Maintainer: Larry Wall <larry@wall.org> Date: 8 Mar 2004 - Last Modified: 26 Feb 2009 + Last Modified: 4 Mar 2009 Number: 3 - Version: 155 + Version: 156 =head1 Overview @@ -3142,7 +3142,7 @@ List Seq Array KeySet KeyBag KeyHash Hash Class Enum Role Type - Subst Grammar Regex + Subst Regex Char Cat Str Int UInt etc. Num Match Capture @@ -3165,15 +3165,9 @@ to treat the buffer as other than a sequence integers is erroneous, and warnings may be generously issued. -Matching against a C<Grammar> object will call the C<TOP> method -defined in the grammar. The C<TOP> method may either be a rule -itself, or may call the actual top rule automatically. How the -C<Grammar> determines the top rule is up to the grammar, but normal -Perl6 grammars will default to setting top to the first rule in the -original base grammar. Derived grammars then inherit this idea of -the top rule. This may be overridden in either the base grammar or a -derived grammar by explicitly naming a rule C<TOP>, or defining your -own C<TOP> method to call some other rule. +Matching against a C<Grammar> treats the grammar as a typename, +not as a grammar. You need to use the C<.parse> or C<.parsefile> +methods to invoke a grammar. Matching against a C<Signature> does not actually bind any variables, but only tests to see if the signature I<could> bind. To really bind
Modified: docs/Perl6/Spec/S12-objects.pod =================================================================== --- docs/Perl6/Spec/S12-objects.pod 2009-03-04 09:53:11 UTC (rev 25683) +++ docs/Perl6/Spec/S12-objects.pod 2009-03-04 16:27:17 UTC (rev 25684) @@ -1604,6 +1604,9 @@ $obj.HOW.methods($obj); $obj.^methods(); +(If you are using prototype-based OO rather than class-based, you must use +the object form, since every such object functions as its own class.) + Class traits may include: identifier { :name<Dog> :ver<1.2.1> :auth<http://www.some.com/~jrandom> }
|
| | Add comment |
|
| Masak's S29 list Timothy S. Nelson 08:40:40 |
| | Here's my comments on Carl Masak's S29 list. Note that some of the things that say that they're "now in" something still need a lot of work.
# Range objects have .from, .to, .min, .max and .minmax methods
Now in S32/Containers.pod
# .contains on Hash and Array
Where's this from?
# Code has a .sig
Seems (from what I can tell) to be synonymous with .signature, so I standardised on .signature.
# .ACCEPTS and .REJECTS on most everything -- provided by the Pattern role. Likely a mistake to put one under each section, though. Perhaps put one under Object and put a reference to S03.
What does Pattern? Should we have Object does Pattern?
# The cat contextualizer.
There's a .cat() method on Container in Containers.pod. Is this what you want?
# Object has .print and .say.
Ok, this makes things difficult. The algorithm of these functions is obviously something like: 1. Object -> Str 2. Output Str on handle
Something that makes this interesting is, what happens when you call IO.print? At the moment, S16 says that this will print a string on the IO object. So to print the IO object itself, you would have to do the algorithm above manually.
The obvious solution is to rename the function on the IO object to something like "doprint", and have Object.print, Object.say, and Object.printf all call on IO.doprint.
Where this starts to get difficult is that the IO object currently has input/output record/field separators specced on it. If the new algorithm converts an array to a string, it's obviously going to have to call on these.
My question is, would we be better off having the string conversion routine for arrays worry about the input/output record/field separators, rather than the IO object? The downside I can see is that you couldn't have separate separators for different IO objects; you'd have to code specially if you wanted that functionality. Is this too much of a downside, or is it a good way to go?
# Block types have .next, .last, .redo and .leave on them. These are also functions, and need to be specced as such. # Block also has a .labels method.
Now in S32/Callable.pod
# fail and .handled (the former is in S29, but has no signature/summary).
Now in S32/Exceptions.pod. But note the role/class Failure double declaration. This is not allowed by the spec, but according to how I read the spec for Failure, that's how it has to be. Obviously I need someone to explain how Failure should *really* be implemented .
# .match, .subst and .trans from S05.
Now in S32/Str.pod. But I wasn't sure what subst() returns.
# Match objects: .from, .to, .chars, .orig and .text. # Match state objects: .pos.
Now added to S32/Regex.pod
The rest I'll leave for another time.
--------------------------------------------------------------------- | Name: Tim Nelson | Because the Creator is, | | E-mail: wayland@wayland.id.au | I am | ---------------------------------------------------------------------
----BEGIN GEEK CODE BLOCK---- Version 3.12 GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y- -----END GEEK CODE BLOCK-----
|
| | 5 answers | Add comment |
Tuesday, 3 March 2009
|
| SQL Keyword is used as Field Name. SELECT Query Problem using DBI. Moderator 16:17:08 |
| | Hello,
One of our tables awb_msg has the field name 'text' and when I try to use the DBI to do a select it prompts an error. How can I do this.
I can't change the field name as it is in a production environment and has been use for the past 10 years with no problems. We are using ms- sqlserver. And also, I have no control of changing the field name. So, changing the field name is not possible.
Here is my test:
This is working correctly.
-- my $sql = "SELECT seq, create_date, msg_code, send_receive FROM awb_msg where seq = 7989176";
it returns:
Number of Fields: 4 7989176, 2009-03-02 01:20:45.430, FHL, R
---
But, once I add the 'text' field in the SELECT Query, Perl DBI stops with an error:
--- my $sql = "SELECT seq, create_date, msg_code, send_receive, text FROM awb_msg where seq = 7989176";
DBD::ODBC::st fetchrow_arrayref failed: [Microsoft][ODBC SQL Server Driver]Strin g data, right truncation (SQL-01004)(DBD: st_fetch/SQLFetch (long truncated DBI attribute LongTruncOk not set and/or LongReadLen too small) err=-1) at ./dbi.pl line 34. DBI::db=HASH(0x10055fb8)->disconnect invalidates 1 active statement handle (eith er destroy statement handles or call finish on them before disconnecting) at ./d bi.pl line 45.
---
I have tried various ways and all returns an error:
awb_msg.text awb_msg."text" "awb_msg"."text" etc.
Please guide me how I can do this.
|
| | 8 answers | Add comment |
Monday, 2 March 2009
|
| Statement modifiers as list comprehension operators Dave Whipp 21:34:47 |
| | S04 mentions that statement modifiers behave as for perl5 (excpet that you can have both an conditional modifier and a looping modifier on a single statement.
Both then it gives this example, with be modifiers being operators within an expression, not as modifiers of a statement.
line 260: @evens = ($_ * 2 if .odd for 0..100);
I had originally thought that this was a typo: surely those parens shouldn't be there! But on #perl6, Larry suggested that this is for list-comprehension expressions. We don't seem to have any tests for it, and it's not implemented in either Rakudo or Pugs.
Because these are operators within an expression (and not strictly statement modifiers), a question that occurred to me was one of nesting:
@triangle = ( ( $_ for 1..$_ ) for 1..10 )
Larry suggested this would work if we could rename the loop variable to avoid ambiguity. But S04 seems to say that this is unecessary:
line 492: When used as statement modifiers, C<for> and C<given> use a private instance of C<$_> for the left side of the statement. The outer C<$_> can be referred to as C<$OUTER::_>. (And yes, this implies that the compiler may have to retroactively change the binding of <$_> on the left side. But it's what people expect of a pronoun like "it".)
The left-to-right ordering seems to make that unnecessary. To my mind,
@triangle = ( ( $_ for 1..$OUTER::_ ) for 1..10 )
is confusing because the inner $_ should exist only on the LHS of that inner "for" loop. So perhaps the original should work.
|
| | Add comment |
|
| $?OS change Timothy S. Nelson 18:55:34 |
| | Hi. I note that we have $?OS, $?VM, and $?DISTRO (and their $* counterparts). I'd like to recommend that we eliminate $?OS, and replace it with $?KERNEL (ie. Linux) and maybe $?ARCH (ie. i386). Thoughts?
--------------------------------------------------------------------- | Name: Tim Nelson | Because the Creator is, | | E-mail: wayland@wayland.id.au | I am | ---------------------------------------------------------------------
----BEGIN GEEK CODE BLOCK---- Version 3.12 GCS d+++ s+: a- C++$ U+++$ P+++$ L+++ E- W+ N+ w--- V- PE(+) Y+>++ PGP->+++ R(+) !tv b++ DI++++ D G+ e++>++++ h! y- -----END GEEK CODE BLOCK-----
|
| | 8 answers | Add comment |
|
| Meta- and Hyperoperators and Anonymous Subroutines Thomas Chust 18:47:08 |
| | Hello,
looking into Perl 6 syntax I noticed that there are meta- and hyperoperators to perform among others the classical functional map and fold operations. However, if I understood this correctly, you can only use these constructs to lift scalar *operators* to the domain of arrays.
Coming from a functional programming background (I write a lot of Scheme code), I am very much accustomed to use map and fold operations, but experience teaches me that a lot the the expressive power offered by these operations comes not from the ability to pass a predefined operator to them but rather from the fact that one can also easily pass a custom operation.
Therefore I think that it would be a nice addition for Perl 6 if the X...X, <<...>> and similar operators could be applied to anonymous subroutines in addition to other operators. If such a syntactic change wasn't possible it would probably be worthwhile to offer methods like map and fold on array instances that take subroutine references as an alternative.
cu, Thomas
-- When C++ is your hammer, every problem looks like your thumb.
|
| | 2 answer | Add comment |
|
| PATCH: DBI: misuse of %lx and %ld formats Charles Jardine 14:14:29 |
| | On 26/02/09 16:31, Charles Jardine wrote:
I have built a 64 bit version of Perl 5.10.0 under SLES 10 (x86-64). I am now installing DBI and DBD::Oracle. Both of these modules produce alarming warnings at compile time. E.g.
DBI.xs: In function dbih_setup_fbav : DBI.xs:1549: warning: format %ld expects type long int , but argument 3 has type int [snip]
I wondered why I had never seen this before. It turns out that Perl 5.10.0 has an improvement in this area. For gcc, the declaration of PerlIO_printf has been enhanced by the addition of '__attribute__((format(__printf__,2,3)))'. This, for the first time, allows gcc to check the types of PerlIO_printf's arguments. I have now looked at the DBI situation more carefully. The new warnings have revealed that there are a very small number cases where %ld or %lx format elements have been used without the requisite casting of arguments. The omissions have probably done no damage on 32-bit platforms, but may have led to incorrect trace output on some 64-bit architectures.
I attach a patch against DBI-1.607 to fix these micro-bugs.
While I was there, on line 888 of DBI.xs, I have interchanged the order of two arguments. I believe this fixes a bug in the tracing of set_trace itself.
-- Charles Jardine - Computing Service, University of Cambridge cj10@cam.ac.uk Tel: +44 1223 334506, Fax: +44 1223 334679
diff -r -u DBI-1.607/DBI.xs DBI-1.607.patched/DBI.xs --- DBI-1.607/DBI.xs 2008-07-22 21:47:32.000000000 +0100 +++ DBI-1.607.patched/DBI.xs 2009-02-27 16:45:19.150114514 +0000 @@ -884,7 +884,7 @@ neatsvpv(h,0), (long)(level & DBIc_TRACE_FLAGS_MASK), (long)(level & DBIc_TRACE_LEVEL_MASK), - DBIc_TRACE_LEVEL(imp_xxh), DBIc_TRACE_FLAGS(imp_xxh), + (long)DBIc_TRACE_FLAGS(imp_xxh), (long)DBIc_TRACE_LEVEL(imp_xxh), XS_VERSION, dbi_build_opt, (int)PerlProc_getpid()); if (!PL_dowarn) PerlIO_printf(DBIc_LOGPIO(imp_xxh)," Note: perl is running without the recommended perl -w option\n"); @@ -1546,14 +1546,14 @@ return av; /* we need to adjust the size of the array */ if (DBIc_TRACE_LEVEL(imp_sth) >= 2) - PerlIO_printf(DBILOGFP," dbih_setup_fbav realloc from %ld to %ld fields\n", av_len(av)+1, i); + PerlIO_printf(DBILOGFP," dbih_setup_fbav realloc from %ld to %ld fields\n", (long)(av_len(av)+1), (long)i); SvREADONLY_off(av); if (i < av_len(av)+1) /* trim to size if too big */ av_fill(av, i-1); } else { if (DBIc_TRACE_LEVEL(imp_sth) >= 5) - PerlIO_printf(DBILOGFP," dbih_setup_fbav alloc for %ld fields\n", i); + PerlIO_printf(DBILOGFP," dbih_setup_fbav alloc for %ld fields\n", (long)i); av = newAV(); DBIc_FIELDS_AV(imp_sth) = av; @@ -1567,7 +1567,7 @@ while(i--) /* field 1 stored at index 0 */ av_store(av, i, newSV(0)); if (DBIc_TRACE_LEVEL(imp_sth) >= 6) - PerlIO_printf(DBILOGFP," dbih_setup_fbav now %ld fields\n", av_len(av)+1); + PerlIO_printf(DBILOGFP," dbih_setup_fbav now %ld fields\n", (long)(av_len(av)+1)); SvREADONLY_on(av); /* protect against shift @$row etc */ return av; } diff -r -u DBI-1.607/DBIXS.h DBI-1.607.patched/DBIXS.h --- DBI-1.607/DBIXS.h 2008-05-28 14:01:29.000000000 +0100 +++ DBI-1.607.patched/DBIXS.h 2009-02-27 16:30:18.343030577 +0000 @@ -304,7 +304,8 @@ if (!DBIc_ACTIVE(imp) && ph_com && !dirty \ && ++DBIc_ACTIVE_KIDS(ph_com) > DBIc_KIDS(ph_com)) \ croak("panic: DBI active kids (%ld) > kids (%ld)", \ - DBIc_ACTIVE_KIDS(ph_com), DBIc_KIDS(ph_com)); \ + (long)DBIc_ACTIVE_KIDS(ph_com), \ + (long)DBIc_KIDS(ph_com)); \ DBIc_FLAGS(imp) |= DBIcf_ACTIVE; \ } while(0) #define DBIc_ACTIVE_off(imp) /* adjust parent's active kid count */ \ @@ -314,7 +315,8 @@ && (--DBIc_ACTIVE_KIDS(ph_com) > DBIc_KIDS(ph_com) \ || DBIc_ACTIVE_KIDS(ph_com) < 0) ) \ croak("panic: DBI active kids (%ld) < 0 or > kids (%ld)", \ - DBIc_ACTIVE_KIDS(ph_com), DBIc_KIDS(ph_com)); \ + (long)DBIc_ACTIVE_KIDS(ph_com), \ + (long)DBIc_KIDS(ph_com)); \ DBIc_FLAGS(imp) &= ~DBIcf_ACTIVE; \ } while(0)
|
| | 1 answer | Add comment |
|
| Google's Summer of Code 2009 Hinrik rn Sigur sson 13:15:59 |
| | Google has announced this year's Summer of Code[1]. The Perl Foundation accepted one project (mentored by Moritz) related to Perl 6 last year[2]. I was wondering if there are any developers interested in mentoring students on Perl 6-related projects this year. I for one would like to apply (as a student) for some Perl 6 work.
1. http://code.google.com/soc/ 2. http://code.google.com/soc/2008/perl/about.html
|
| | 2 answer | Add comment |
|
| r25654 - docs/Perl6/Spec/S32-setting-library Guest 13:09:04 |
| | Author: leto Date: 2009-03-02 11:09:04 +0100 (Mon, 02 Mar 2009) New Revision: 25654
Modified: docs/Perl6/Spec/S32-setting-library/Numeric.pod Log: Fix typo in Numeric
Modified: docs/Perl6/Spec/S32-setting-library/Numeric.pod =================================================================== --- docs/Perl6/Spec/S32-setting-library/Numeric.pod 2009-03-02 09:02:03 UTC (rev 25653) +++ docs/Perl6/Spec/S32-setting-library/Numeric.pod 2009-03-02 10:09:04 UTC (rev 25654) @@ -67,7 +67,7 @@ =item succ our Num multi method succ ( Num $x: ) is export - out Int multi method succ ( Int $x: ) is export + our Int multi method succ ( Int $x: ) is export Returns the successor of C<$x>. This method is used by C<< prefix:<++> >> and C<< postfix:<++> >> to increment the value in a container.
|
| | Add comment |
|
| r25652 - docs/Perl6/Spec Guest 09:00:48 |
| | Author: wayland Date: 2009-03-02 07:00:47 +0100 (Mon, 02 Mar 2009) New Revision: 25652
Modified: docs/Perl6/Spec/S28-special-names.pod Log: Should've looked first -- $*DISTRO is documented in S02
Modified: docs/Perl6/Spec/S28-special-names.pod =================================================================== --- docs/Perl6/Spec/S28-special-names.pod 2009-03-02 05:51:23 UTC (rev 25651) +++ docs/Perl6/Spec/S28-special-names.pod 2009-03-02 06:00:47 UTC (rev 25652) @@ -78,7 +78,7 @@ @=DATA (S26) Array # Same as above, but array %?DEEPMAGIC S13 Hash of XXX # Controls the mappings of magical names to sub definitions $?DISTRO S02 SoftwarePackage # Which OS distribution am I compiling under - $*DISTRO SoftwarePackage # Which OS distribution am I running under + $*DISTRO S02 SoftwarePackage # Which OS distribution am I running under $*EGID Int # effective group id %*ENV S02 Hash of Str # system environment variables $*ERR S16 IO # Standard error handle
|
| | Add comment |
|
| r25651 - docs/Perl6/Spec Guest 08:51:24 |
| | Author: wayland Date: 2009-03-02 06:51:23 +0100 (Mon, 02 Mar 2009) New Revision: 25651
Modified: docs/Perl6/Spec/S28-special-names.pod Log: S28: - Did more heading changes to make it "Special Names" instead of "Special Variables" - Added lots of spec cross-references - Added a $*DISTRO variable (hopefully this was just an omission) - Added a SoftwarePackage class that represents the name and version of the software mentioned, whether this be Perl, and OS, or a Distro.
Modified: docs/Perl6/Spec/S28-special-names.pod =================================================================== --- docs/Perl6/Spec/S28-special-names.pod 2009-03-02 05:29:37 UTC (rev 25650) +++ docs/Perl6/Spec/S28-special-names.pod 2009-03-02 05:51:23 UTC (rev 25651) @@ -11,8 +11,10 @@ Last Modified: 25 Feb 2009 Version: 5 -=head1 Introduction +=head1 Special Variables +=head2 Introduction + This document serves as a collection point for what is known about special variables in Perl 6 and correlates them with the changes from Perl 5. @@ -23,9 +25,9 @@ Perl 5 variable(s). The list of main entries is also followed by a table showing the 5 and 6 variables side-by-side. -=head1 Overview +=head2 Overview -=head2 Secondary Sigils (also known as "twigils") +=head3 Secondary Sigils (also known as "twigils") A quick reminder of the relevant twigils from S02: @@ -56,7 +58,7 @@ rather than compiler control. The structure of these variables will be fleshed out in S26. -=head2 Named variables +=head3 Named variables Variable Spec Type Description -------- ---- ---- ----------- @@ -68,44 +70,45 @@ @*ARGS S06 Array of Str # command-line arguments $*ARGFILES S02 IO # The magic command-line input handle &?BLOCK S06 Block # current block (itself) - ::?CLASS Str # current class (as package or type name) - $?CLASS Class # current class - @=COMMENT # All the comment blocks in the file - %?CONFIG Hash of XXX # configuration hash - $=DATA # data block handle (=begin DATA ... =end) - @=DATA # Same as above, but array + ::?CLASS S12 Str # current class (as package or type name) + $?CLASS S02 Class # current class + @=COMMENT (S26) # All the comment blocks in the file + %?CONFIG Hash of XXX # configuration hash XXX What does this do? + $=DATA (S26) IO # data block handle (=begin DATA ... =end) + @=DATA (S26) Array # Same as above, but array %?DEEPMAGIC S13 Hash of XXX # Controls the mappings of magical names to sub definitions - $?DISTRO S02 Str # Which OS distribution am I compiling under + $?DISTRO S02 SoftwarePackage # Which OS distribution am I compiling under + $*DISTRO SoftwarePackage # Which OS distribution am I running under $*EGID Int # effective group id - %*ENV Hash of Str # system environment variables + %*ENV S02 Hash of Str # system environment variables $*ERR S16 IO # Standard error handle $*EUID Int # effective user id $*EXECUTABLE_NAME Str # executable name - $?FILE Str # current filename of source file - $?GRAMMAR Grammar # current grammar + $?FILE S02 Str # current filename of source file + $?GRAMMAR S02 Grammar # current grammar $*GID Int # group id $*IN S16 IO # Standard input handle; is an IO object $*INC S11 # where to search for user modules (but not std lib!) $?LANG S02 # Which Perl parser should embedded closures parse with? $*LANG S02 Str # LANG variable from %*ENV that defines what human language is used - $?LINE Int # current line number in source file + $?LINE S02 Int # current line number in source file %*META-ARGS S19 Hash of XXX # Meta-arguments - $?MODULE Module # current module + $?MODULE S02 Module # current module %*OPTS S19 Hash of XXX # Options from command line %*OPT... S19 Hash of XXX # Options from command line to be passed down - $?OS Str # operating system compiled for - $*OS Str # operating system running under + $?OS SoftwarePackage # operating system compiled for + $*OS SoftwarePackage # operating system running under $*OUT S16 IO # Standard output handle $?PARSER S02 Grammar # Which Perl grammar was used to parse this statement? - $?PACKAGE Package # current package - $?PERL S02 Str # Which Perl am I compiled for? - $*PERL Str # perl version running under + $?PACKAGE S02 Package # current package + $?PERL S02 SoftwarePackage # Which Perl am I compiled for? + $*PERL S02 SoftwarePackage # perl version running under $*PID Int # system process id %=POD S02 # (or some such) - $*PROGRAM_NAME Str # name of the Perl program being executed + $*PROGRAM_NAME S19 Str # name of the Perl program being executed %*PROTOCOLS S16 Hash of Method # Stores the methods needed for the uri() function ::?ROLE Str # current role (as package or type name) - $?ROLE Role # current role + $?ROLE S02 Role # current role &?ROUTINE S06 Routine # current sub or method (itself) $?SCOPE S02 # Current "my" scope (XXX unnecessary?) $*UID Int # system user id @@ -123,15 +126,19 @@ to called code. Likewise each thread could log its own errors to its own C<$*ERR>, since a thread is a dynamic scope. -=head1 Special Variables +=head2 Special Classes -This section only lists variables that don't have a "See S16" or suchlike next to them in -the overview above. +These are classes defined especially for the benefit of the Special Variables. -XXX Some of the information here is either old, or needs to be moved elsewhere. XXX + class SoftwarePackage { + has Str $name; + has Version $version; + } -=head2 Perl5 to Perl6 special variable translation +This class is intended to represent a software package at a fairly basic level. +=head3 Perl5 to Perl6 special variable translation + If a column has a "-" in it, it means that item is unavailable in that version of Perl. Perl 5 Perl 6 Comment @@ -207,7 +214,7 @@ $SIG{__DIE__} $*ON_DIE ${^OPEN} - This was internal; forget it -=head1 NOT YET DEFINED +=head2 NOT YET DEFINED The following items are not yet defined, but will need to be defined. @@ -218,7 +225,7 @@ The $?LANG and $*LANG variables are also confusing (both in S02). -=head2 Form.pm +=head3 Form.pm These go in the Perl5 to Perl6 conversion table: @@ -247,12 +254,12 @@ - $^A $ACCUMULATOR -=head2 S15-unicode.pod +=head3 S15-unicode.pod ${^ENCODING} variable -- S32/Str.pod implies this is $*ENC ${^UNICODE} variable -=head2 Infectious trait spec +=head3 Infectious trait spec ${^TAINT} variable, which is pending, among other things, infectious trait spec
|
| | Add comment |
|
| r25650 - docs/Perl6/Spec Guest 08:29:37 |
| | Author: wayland Date: 2009-03-02 06:29:37 +0100 (Mon, 02 Mar 2009) New Revision: 25650
Added: docs/Perl6/Spec/S21-calling-foreign-code.pod Log: Wrote this a few days ago, but forgot to svn add.
Added: docs/Perl6/Spec/S21-calling-foreign-code.pod =================================================================== --- docs/Perl6/Spec/S21-calling-foreign-code.pod (rev 0) +++ docs/Perl6/Spec/S21-calling-foreign-code.pod 2009-03-02 05:29:37 UTC (rev 25650) @@ -0,0 +1,52 @@ + +=encoding utf8 + +=head1 Title + +DRAFT: Synopsis 21: Calling Foreign Code + +=head1 Version + + Author: Tim Nelson <wayland@wayland.id.au> + Maintainer: Larry Wall <larry@wall.org> + Contributions: Tim Nelson <wayland@wayland.id.au> + Larry Wall <larry@wall.org> + Date: 27 Feb 2009 + Last Modified: 27 Feb 2009 + Version: 1 + +The document is a draft. + +If you read the HTML version, it is generated from the pod in the pugs +repository under /docs/Perl6/Spec/S21-calling-foreign-code.pod so edit it there in +the SVN repository if you would like to make changes. + +=head1 Overview + +Unfortunately, calling foreign code properly is quite platform dependent. This means that +parts of the external calling conventions can't be standardised. But the parts that can +be standardised are specified here. + +=head1 Specification + +The C<use> statement allows an external language to be specified in +addition to (or instead of) an authority, so that you can use modules +from other languages. The C<from> adverb also parses any additional +parts as short-form arguments. For instance: + + use Whiteness:from<perl5>:name<Acme::Bleach>:ver<1.12>:auth<cpan CONWAY>; + use Whiteness:from<perl5 Acme::Bleach 1.12 cpan CONWAY>; # same thing + + use libc:from<C>; + +=head1 Other Considerations + +=head2 Linking to common platforms + +XXX We need a discussion of how to link to some of the common platforms + +=head1 Additions + +Please post errors and feedback to perl6-language. If you are making +a general laundry list, please separate messages by topic. +
|
| | Add comment |
|
| Perl DBI program fails unexpectedly in Apache CGI-mode *only* SundialServices 08:16:44 |
| | Please refer to the thread, "Do XS-components require special considerations with CGI?", found at http://www.perlmonks.org/?node_id=746397 for a complete explanation of this problem.
I have a Perl CGI-program which works perfectly under Apache on my development system, and in the command-line on the (ordinary Linux...) shared host system, but which fails under Apache CGI-mode on that same system.
As I related at-length in the aforementioned thread on "perlmonks," with copious details that I therefore do not wish to repeat here... I have captured logs produced by the program running in both environments on the same machine with "DynaLoader" debug-messages turned on in both cases. And, I have "diff"ed them.
(1) The =entire= log output of both, particularly including "DynaLoader"'s recitation of the "@INC" path, is (almost) identical. "DBD::mysql" and "DBI" are dynaloaded successfully.
(2) Here is the -only- difference ... the failure-indications that appear only in the Apache CGI output:
[Sat Feb 28 19:41:12 2009] spe-cgi.pl: Had to create DBD::mysql::dr::imp_data_size unexpectedly at .../local-perl/lib/perl/ 5.8.8/DBI.pm line 1212. [Sat Feb 28 19:41:12 2009] spe-cgi.pl: Had to create DBD::mysql::db::imp_data_size unexpectedly at .../local-perl/lib/perl/ 5.8.8/DBI.pm line 1242. Demo FAILED with this error: DBIx::Class::ResultSet::next(): DBI Connection failed: Undefined subroutine &DBD::mysql::db::_login called at .../local-perl/ lib/perl/5.8.8/DBD/mysql.pm line 142.
(In each of the above messages I have elided-out much of the path-name just for brevity (".../local-perl"). I have verified that this IS, in fact, exactly the right path to where "DBI.pm" is, and ought to be.
LD_LIBRARY_PATH in both cases (the working case and the non-working case) is identical... it is "undef."
Remember: the program produces correct output in the command-line on the selfsame system where it fails (gracefully...) when run in CGI- mode. That is to say, the program runs, it generates its own "error detected" output, loads all the right XS-modules, and so on.
Furthermore, a programmatic "ldd" command, issued by the program in both environments for "mysql.so" and 'libmysqlclient.so," produces apparently-CORRECT output: there are no missing symbols.
After more than a week of banging my head against this problem, I am utterly baffled ... and beyond desperate.
|
| | Add comment |
|
| r25541 - docs/Perl6/Spec Guest 04:24:09 |
| | Author: wayland Date: 2009-02-25 07:08:52 +0100 (Wed, 25 Feb 2009) New Revision: 25541
Modified: docs/Perl6/Spec/S28-special-names.pod Log: S28: Incorporated some more stuff from the old documentation lower down, and a few variables from S02.
Modified: docs/Perl6/Spec/S28-special-names.pod =================================================================== --- docs/Perl6/Spec/S28-special-names.pod 2009-02-25 05:31:24 UTC (rev 25540) +++ docs/Perl6/Spec/S28-special-names.pod 2009-02-25 06:08:52 UTC (rev 25541) @@ -50,6 +50,7 @@ $?CLASS # current class (as variable) %?CONFIG # configuration hash $=DATA # data block handle (=begin DATA ... =end) + $?DISTRO S02 # Which OS distribution am I compiling under $*EGID # effective group id %*ENV # system environment $*ERR S16 # Standard error handle; is an IO object @@ -71,16 +72,20 @@ $?OSVER # operating system version compiled for $*OSVER # operating system version running under $*OUT S16 # Standard output handle; is an IO object + $?PARSER S02 # Which Perl grammar was used to parse this statement? $?PACKAGE # current package (as object) $?PACKAGENAME S10 # name of current package - $?PERLVER # perl version compiled for - $*PERLVER # perl version running under + $?PERL S02 # Which Perl am I compiled for? + $*PERL # perl version running under $*PROGRAM_NAME # name of the program being executed $*PID # system process id ::?ROLE # current role (as package name) $?ROLE # current role (as variable) &?ROUTINE S06 # current sub or method (itself) + $?SCOPE S02 # Current "my" scope $*UID # system user id + $?VM S02 # Which virtual machine am I compiling under + $?XVM S02 # Which virtual machine am I cross-compiling for Note that contextual variables such as C<$*OUT> may have more than one current definition in the outer dynamic context, in which case @@ -166,10 +171,11 @@ $^H - These were only ever internal anyway %^H - - $! Current exception (see L<S04-control>) - $! $ERRNO $OS_ERROR - Can get some info from new $! - $? $CHILD_ERROR - - $@ $EVAL_ERROR - Just throws an exception now (see L<S04-control>) - $^E - + $! $ERRNO $OS_ERROR - Use shiny new $! + $? $CHILD_ERROR - Use shiny new $! + $@ $EVAL_ERROR - Use shiny new $! + $^E - Use shiny new $! + $^S - $. $NR $*IN.input_record_number() $/ $RS $*IN.input_record_separator() $| $*OUT.autoflush() @@ -203,14 +209,22 @@ ARGVOUT $*ARGVOUT Another IO object @F @*INPLACE_AUTOSPLIT_FIELDS ..or some such %ENV %*ENV + ${^OPEN} - This was internal; forget it =head2 Old stuff for p5/p6 comparison This section will eventually die, but for now, it contains some old information on which -Perl5 special variables will turn into Perl6 special variables. +Perl5 special variables will turn into Perl6 special variables. The reason they are +retained is either: -=over 4 +=over +=item * Their status is undecided + +=item * They have some commentary on stuff that needs consideration + +=back + Because a blank entry in either column could be taken to mean either "not in Perl 6" or "unknown", the information as presented below presumes an entry in both columns for every entry. @@ -229,29 +243,25 @@ Other organizational schemes may become appropriate when the table is more complete. -=back - ******* XXX the columns seem to have switched! ********* ? ${^ENCODING} + ? ${^UNICODE} Pending S15 Unicode - - $^V $PERL_VERSION - $] version + patchlevel / 1000 of Perl interpreter Replacement for the above two is unclear. + Is this $?PERL? - - ${^OPEN} + ? ${^TAINT} Pending, among other things, infectious trait spec - ? ${^TAINT} - ? ${^UNICODE} - - $^W $WARNING Probably gone. But we need a reasonably granular way to suppress specific (groups of) warnings within both lexical and dynamic scopes. - ? $ARGV + ? $ARGV Can this be handled with $*IN.name, etc? ? @INC Uncertain but we need a way to add to search path ? %INC Uncertain but we need a way to add to search path @@ -259,13 +269,14 @@ ? @_ +This signal handling stuff is pending S16. + %*SIG %SIG Or possibly &*ON_SIGINT, etc. But then we'd need to add some signal introspection in another way. &*ON_WARN __WARN__ &*ON_DIE __DIE__ &*ON_PARSEERROR - - $^S $EXCEPTIONS_BEING_CAUGHT XXX Everything below this line is older than everything above it.
|
| | 2 answer | Add comment |
|
| pod variables? Jon Lang 03:54:55 |
| | Under the section about twigils in S02, "$=var" is described as a "pod variable". I'm not finding any other references to pod variables; what are tey, and how are they used? (In particular, I'm wondering if they're a fossil; if they aren't, I'd expect further information about them to be in S26.)
-- Jonathan "Dataweaver" Lang
|
| | 2 answer | Add comment |
|
| test DBD::Oracle DBI connect('','user/password@database',...) failed: ORA-12154 Jeff Collins 02:53:46 |
| | I can connect to the database using sqlplus as user oracle, but not as root.
I can compile DBD::Oracle but not complete the test.
I tried to set variables properly:
ORACLE_HOME=/u/oracle/10.2.0 ORACLE_HOST=hostname ORACLE_PORT=1522 ORACLE_SID=databasename ORACLE_USERID=user/password@databasename PATH=/u/oracle/10.2.0/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin PWD=/usr/src/pub/dbd-oracle/DBD-Oracle-1.22 TNS_ADMIN=/u/oracle/10.2.0/network/admin TWO_TASK=T:hostname:ORACLE_SID
The machine has a medium sized production Oracle 10g database which works fine with a Java application.
The # perl Makefile.PL appears to work and the make appears to work
I have a user name/password which permits read-only access to the database which I have verified as user oracle.
I would appreciate any help,
Jeff
|
| | 1 answer | Add comment |
Sunday, 1 March 2009
|
| Range and continuous intervals Darren Duncan 22:27:06 |
| | I don't know if this was previously discussed and dismissed but ...
Inspired by some recent discussion in the "comparing inexact values" thread plus some temporal discussion and some older thoughts ...
I was thinking that Perl 6 ought to have a generic interval type that is conceptually like Range, in that it is defined using a pair of values of an ordered type and includes all the values between those, but unlike Range that type is not expected to have discrete consecutive values that can be iterated over.
I'm thinking of a Range-alike that one could use with Rat|Num or Instant etc, and not just Int etc. There would be operators to test membership of a value in the interval, and set-like operators to compare or combine intervals, such as is_inside, is_subset, is_overlap, union, intersection, etc. Such an interval would be what you use for inexact matching and would be the result of a ± infix operator or % postfix operator. Also, as Range has a .. constructor, this other type should have something.
Now, ideally the type would also support discontinuous ranges, or maybe it would be best to have 2 types, one that is a single continuous range and the other which is a set of the first and supports discontinuous ranges. So, union|intersection etc would generally only work with the discontinuous version but the other operators could work with the continuous ones. In any event I only had closed-ended intervals in mind, and not open-ended ones.
I'm thinking that at least the simpler continuous version of the range should be in core since it is generic in the way that Range is generic, and it is simple, and could be widely usable in common contexts such as fuzzy matching of numerics and instants. The noncontinuous version is less important, though quite useful.
Barring a better name coming along, I suggest calling the type "Interval", and it would be immutable.
As for determination of where ranges overlap or not, eg whether a matching start and end point counts as an overlap or just an adjacency, this could be customizable (eg, an overlap if the ordered type is discrete like Int, and an adjacency if it is continuous like Rat|Num) unless there are general rules best applied generally. I cite the "comparing inexact values" for prior discussion of these matters, that don't necessarily need repeating.
-- Darren Duncan
|
| | 10 answers | Add comment |
|
| r25645 - docs/Perl6/Spec Guest 11:48:36 |
| | Author: lwall Date: 2009-03-01 09:48:35 +0100 (Sun, 01 Mar 2009) New Revision: 25645
Modified: docs/Perl6/Spec/S02-bits.pod docs/Perl6/Spec/S28-special-names.pod Log: doc tweaks. $?OSVER should be $?OS.ver or some such
Modified: docs/Perl6/Spec/S02-bits.pod =================================================================== --- docs/Perl6/Spec/S02-bits.pod 2009-03-01 08:43:49 UTC (rev 25644) +++ docs/Perl6/Spec/S02-bits.pod 2009-03-01 08:48:35 UTC (rev 25645) @@ -2123,9 +2123,6 @@ &?ROUTINE Which routine am I in? &?BLOCK Which block am I in? -All the nested C<@?> variables are ordered from the innermost to the -outermost, so C<@?BLOCK[0]> is always the same as C<&?BLOCK>. - The following return objects that contain all pertinent info: $?OS Which operating system am I compiled for?
Modified: docs/Perl6/Spec/S28-special-names.pod =================================================================== --- docs/Perl6/Spec/S28-special-names.pod 2009-03-01 08:43:49 UTC (rev 25644) +++ docs/Perl6/Spec/S28-special-names.pod 2009-03-01 08:48:35 UTC (rev 25645) @@ -86,7 +86,6 @@ $*GID Int # group id $*IN S16 IO # Standard input handle; is an IO object $*INC S11 # where to search for user modules (but not std lib!) - $?LABEL # label of current block (XXX unnecessary?) $?LANG S02 # Which Perl parser should embedded closures parse with? $*LANG S02 Str # LANG variable from %*ENV that defines what human language is used $?LINE Int # current line number in source file @@ -96,8 +95,6 @@ %*OPT... S19 Hash of XXX # Options from command line to be passed down $?OS Str # operating system compiled for $*OS Str # operating system running under - $?OSVER Str # operating system version compiled for - $*OSVER Str # operating system version running under $*OUT S16 IO # Standard output handle $?PARSER S02 Grammar # Which Perl grammar was used to parse this statement? $?PACKAGE Package # current package
|
| | Add comment |
Saturday, 28 February 2009
|
| connect_cached and timeouts Steve Freegard 14:46:18 |
| | Hi,
I've been trying to implement a timeout wrapper for my database functions to handle a database connection that is remote and therefore could either become very slow of the link could disappear completely.
I'm using something like this:
use DBI; use Sys::SigAction;
my($dbh); eval { my $h = set_sig_handler('ALRM',sub {die "timeout";}, { trap => [ 'ALRM', 'INT' ], safe=>0 }); alarm(30); $dbh = DBI->connect_cached(...); alarm(0); }; alarm(0); if($@) { ... }
This works fine if the connection to the database is not already established and times out after 30 seconds correctly; however if the database connection was established previously (and cached) it takes > 200 seconds to return instead of the expected 30 seconds.
An strace shows the following:
rt_sigaction(SIGALRM, NULL, {SIG_DFL}, 8) = 0 rt_sigprocmask(SIG_BLOCK, [ALRM], ~[KILL STOP RTMIN RT_1], 8) = 0 rt_sigaction(SIGALRM, {0xd30835, [], SA_RESTORER, 0xc29a9 , {SIG_DFL}, 8) = 0 rt_sigprocmask(SIG_SETMASK, ~[KILL STOP RTMIN RT_1], NULL, 8) = 0 rt_sigaction(SIGALRM, {0xd3419d, [ALRM], SA_RESTORER, 0xc29a9 , NULL, 8) = 0 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0 alarm(30) = 0 rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0 send(6, "Q\0\0\0\37SELECT \'DBD::Pg ping test\'\0", 32, 0) = 32 rt_sigaction(SIGPIPE, {SIG_DFL}, {SIG_IGN}, 8) = 0 poll( [{fd=6, events=POLLIN|POLLERR}], 1, -1) = -1 EINTR (Interrupted system call) --- SIGALRM (Alarm clock) @ 0 (0) --- rt_sigprocmask(SIG_UNBLOCK, [ALRM], NULL, 8) = 0 socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 9 setsockopt(9, SOL_TCP, TCP_NODELAY, [1], 4) = 0 fcntl64(9, F_SETFL, O_RDONLY|O_NONBLOCK) = 0 fcntl64(9, F_SETFD, FD_CLOEXEC) = 0 connect(9, {sa_family=AF_INET, sin_port=htons(5432), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress) poll( *** hangs here for ~280 seconds ***
Does anyone have any idea as to what I'm doing wrong or how to workaround this??
Kind regards, Steve.
|
| | 4 answer | Add comment |
Friday, 27 February 2009
|
| r25626 - docs/Perl6/Spec Guest 22:28:33 |
| | Author: lwall Date: 2009-02-27 19:24:47 +0100 (Fri, 27 Feb 2009) New Revision: 25626
Modified: docs/Perl6/Spec/S04-control.pod Log: Document new lift statement for writing generic multis
Modified: docs/Perl6/Spec/S04-control.pod =================================================================== --- docs/Perl6/Spec/S04-control.pod 2009-02-27 17:47:30 UTC (rev 25625) +++ docs/Perl6/Spec/S04-control.pod 2009-02-27 18:24:47 UTC (rev 25626) @@ -12,9 +12,9 @@ Maintainer: Larry Wall <larry@wall.org> Date: 19 Aug 2004 - Last Modified: 27 Dec 2008 + Last Modified: 27 Feb 2008 Number: 4 - Version: 71 + Version: 72 This document summarizes Apocalypse 4, which covers the block and statement syntax of Perl. @@ -571,7 +571,7 @@ # Not an error: Equivalent to "if foo() -> $x { say $x }" { say $^x } if foo(); -=head2 The gather statement +=head2 The C<gather> statement prefix A variant of C<do> is C<gather>. Like C<do>, it is followed by a statement or block, and executes it once. Unlike C<do>, it evaluates @@ -638,6 +638,40 @@ C<Capture> object is generated, not when it is bound (which could happen more than once). +=head2 The C<lift> statement prefix + +When writing generic multi routines you often want to write a bit of +code whose meaning is dependent on the context of the caller. It's +somewhat like virtual methods where the actual call depends on the type +of the invocant, but here the "invocant" is really the lexical scope of +the caller, and the virtual calls are name bindings. Within a lift, +special rules apply to how names are looked up. Only names defined +in the lexical scope of the immediately surrounding routine are considered concrete. +All other names (including implicit names of operators) are looked up +in the lexical scope of the caller when we actually know who the caller +is at run time. (Note the caller can vary from call to call!) +Through this mechanism, a generic multi can redirect execution to +a more specific version, but the candidate list for this redirection +is determined by the caller, not by the lexical scope of the multi, +which can't see the caller's lexical scope except through the CALLER:: +pseudo package. For example, Perl forces generic C<eq> to coerce to +string comparison, like this: + + proto infix:<eq> (Any $a, Any $b) { lift ~$a eq ~$b } # user's eq, user's ~ + multi infix:<eq> (Whatever, Any $b) { -> $a { lift $a eq $b } } # user's eq + multi infix:<eq> (Any $a, Whatever) { -> $b { lift $a eq $b } } # user's eq + multi infix:<eq> (&f $), Any $b) { -> $a { lift f($a) eq $b } } # user's eq + multi infix:<eq> (Str $a, Str $b) { !Str::leg($a, $b) } # primitive leg, primitive ! + + +Note that in each piec of lifted code there are references to +variables defined in the multi, such as C<$a>, C<$b>, and C<&f>. +These are taken at face value. Everything else within a lift is +assumed to mean something in the caller's context. (This implies +that there are some errors that would ordinarily be found at +compile time that cannot be found until we know what the caller's +lexical scope looks like at run time. That's okay.) + =head2 Other C<do>-like forms Other similar C<Code>-only forms may also take bare statements,
|
| | 3 answer | Add comment |
|
| r25633 - docs/Perl6/Spec Guest 22:28:33 |
| | Author: lwall Date: 2009-02-27 22:12:45 +0100 (Fri, 27 Feb 2009) New Revision: 25633
Modified: docs/Perl6/Spec/S04-control.pod Log: typo from Jon++
Modified: docs/Perl6/Spec/S04-control.pod =================================================================== --- docs/Perl6/Spec/S04-control.pod 2009-02-27 20:53:38 UTC (rev 25632) +++ docs/Perl6/Spec/S04-control.pod 2009-02-27 21:12:45 UTC (rev 25633) @@ -664,7 +664,7 @@ multi infix:<eq> (Str $a, Str $b) { !Str::leg($a, $b) } # primitive leg, primitive ! -Note that in each piec of lifted code there are references to +Note that in each piece of lifted code there are references to variables defined in the multi, such as C<$a>, C<$b>, and C<&f>. These are taken at face value. Everything else within a lift is assumed to mean something in the caller's context. (This implies
|
| | Add comment |
|
|