[perl #40674] [PATCH] Reduce verbosity in t/codingstd/tabs.t
# New Ticket Created by Paul Cochrane # Please include the string: [perl #40674] # in the subject line of all future correspondence about this issue. # http://rt.perl.org/rt3/Ticket/Display.html?id=40674 > Hi, This patch reduces the amount of output generated by the t/codingstd/tabs.t test, and makes the output like that of the other coding standards tests. Comments welcome! Regards, Paul files affected: t/codingstd/tabs.t Index: t/codingstd/tabs.t === --- t/codingstd/tabs.t (revision 15005) +++ t/codingstd/tabs.t (working copy) @@ -35,15 +35,26 @@ my @tabs; foreach my $file (@files) { -open my $fh, '<', $file -or die "Cannot open '$file' for reading: $!\n"; +my $path; -my $tabcount; +## get the full path of the file +# if we have the files on the command line, the file is the full path +if (@ARGV) { +$path = $file; +} + +# otherwise, use the Parrot::Doc::File::path method +else { +$path = $file->path; +} + +open my $fh, '<', $path +or die "Cannot open '$path' for reading: $!\n"; + +# search each line for leading tabs while (<$fh>) { -next unless /^ *\t/; -push @tabs, "tab in leading whitespace, file '$file', line $.\n"; -if ( ++$tabcount >= 5 ) { -push @tabs, "skipping remaining lines (you get the idea)\n"; +if ($_ =~ m/^ *\t/) { +push @tabs => "$path\n"; last; } } @@ -51,12 +62,13 @@ } ok( !scalar(@tabs), "tabs in leading whitespace" ) -or diag(@tabs); +or diag("Found tab in leading whitespace in " . scalar(@tabs) +. " files. Files affected:[EMAIL PROTECTED]"); exit; sub source_files { -return map { $_->path } ( +return ( map( $_->files_of_type('C code'), $DIST->c_source_file_directories ), map( $_->files_of_type('C header'), $DIST->c_header_file_directories ), map( $_->files_of_type('PMC code'), $DIST->pmc_source_file_directories ),
Re: set_pmc_keyed_int delegates to set_pmc_keyed...?
Nicholas Clark wrote: To me that feels like a hack. The current rather-too-static dispatch (to me) seems to be the bug, and the thing that needs fixing. Yeah, you're right. So, I decided to try and address this. From what I can see, the problem comes up in building the v-table for the subclass. The v-tables of the parent classes are not searched for any methods that they implement when building the v-table for the subclass. Instead, entries from the deleg_pmc PMC v-table (or the ParrotObject one) are stuck in it's place. So, in the attached patch I implemented searching v-tables of parent classes. The idea is that if it finds a method that we'd have delegated before but is implemented by a parent, it sticks the parent's method in the v-table. (Well, kinda - what I really needed to do was check that a PMC had over-ridden a method, but there is no v-table for the default PMC, so I just used the Undef PMC's v-table for now - that's *wrong* I know, but I just wanted an approximation to test the idea out with). Anyway, I discovered two problems as a result of this. First is that a subclass is always really an instance of the ParrotClass PMC, which uses the PMC_data slot. However, Capture.pmc uses that for its data too (and I guess the situation is the same for other PMCs). Obviously both PMCs can't put their data in the same slot, so you just wind up with a segfault. Second is that PGE segfaults now - somehow the exists_keyed of the Hash PMC is getting called now where it wasn't before. But if it wasn't before, then I'm not quite sure what *was* being called (well, it was exists_keyed in deleg_pmc, but that appears to call exists_keyed on attribute 0 (which looks me to mean whatever's in PMC_data, which would be the array of parents?! I must have misunderstood something here...) Either way, seems problem 1 is the real issue, and problem 2 is probably just me being confused (though I'd love an explanation, from @leo ;-)). Jonathan Index: src/objects.c === --- src/objects.c (revision 15108) +++ src/objects.c (working copy) @@ -290,21 +290,41 @@ #endif } else if (full) { -/* - * the method doesn't exist; put in the deleg_pmc vtable, - * but only if ParrotObject hasn't overridden the method - */ -if (((void **)delegate_vtable)[i] == ((void**)object_vtable)[i]) { -if (ro_vtable) -((void **)ro_vtable)[i] = ((void**)deleg_pmc_vtable)[i]; -((void **)vtable)[i] = ((void**)deleg_pmc_vtable)[i]; +/* See if a parent PMC has already provided an implementation of + * the method, and in that case put that in the v-table slot. + * Otherwise, stick in a delegate PMC entry or, if ParrotObject + * overrides it, a ParrotObject v-table entry. */ +int num_parents = VTABLE_elements(interpreter, class->vtable->mro); +int p; +VTABLE* const default_vtable = +interpreter->vtables[enum_class_Undef]; /* XXX want enum_class_default, but abstract. */ +void* parent_meth = NULL; +for (p = 1; p < num_parents && parent_meth == NULL; p++) { +PMC* cur_parent = VTABLE_get_pmc_keyed_int(interpreter, +class->vtable->mro, p); +VTABLE* parent_vtable = cur_parent->vtable; +if (((void **)parent_vtable)[i] != ((void**)default_vtable)[i]) +parent_meth = ((void **)parent_vtable)[i]; } -else { + +if (((void **)delegate_vtable)[i] != ((void**)object_vtable)[i]) { +/* Overridden in ParrotObject. */ ((void **)vtable)[i] = ((void**)object_vtable)[i]; if (ro_vtable) ((void **)ro_vtable)[i] = ((void**)ro_object_vtable)[i]; - } +else if (parent_meth != NULL) { +/* We found a parent method. Use that.*/ +if (ro_vtable) +((void **)ro_vtable)[i] = parent_meth; +((void **)vtable)[i] = parent_meth; +} +else { +/* Not overridden in ParrotObject. */ +if (ro_vtable) +((void **)ro_vtable)[i] = ((void**)deleg_pmc_vtable)[i]; +((void **)vtable)[i] = ((void**)deleg_pmc_vtable)[i]; +} } } }
[svn:parrot-pdd] r15109 - in trunk: compilers/imcc docs/pdds/clip docs/stm
Author: rgrjr Date: Sat Nov 4 14:28:25 2006 New Revision: 15109 Modified: trunk/docs/pdds/clip/pdd25_concurrency.pod Changes in other areas also in this revision: Modified: trunk/compilers/imcc/imclexer.c trunk/compilers/imcc/imcparser.c trunk/docs/stm/howto.pod Log: * compilers/imcc/imcparser.c: * compilers/imcc/imclexer.c: + Fix some cuddled elses. The remainder are in *.c or *.l files, which I am not sure I can test properly. * docs/stm/howto.pod: * docs/pdds/clip/pdd25_concurrency.pod: + Quoted code also ought to be conformant. Modified: trunk/docs/pdds/clip/pdd25_concurrency.pod == --- trunk/docs/pdds/clip/pdd25_concurrency.pod (original) +++ trunk/docs/pdds/clip/pdd25_concurrency.pod Sat Nov 4 14:28:25 2006 @@ -772,7 +772,8 @@ if (thork()) { # fork a thread # thread A func1($aaa, $bbb, $ccc); - } else { + } + else { # thread B func2($bbb.property); }
Re: Anyone relying on objects stringifying to class names?
Jonathan Worthington wrote: At the moment, if you have some ParrotObject instance, say foo, and do something like: $S0 = foo Then $S0 will contain the name of the class. ... =item C Erm, what the heck was I smoking when I wrote this...the name method doesn't control what an object stringifies to at all. I managed to read it as get_string. :-( Sorry 'bout that. And while this is marked as being bad in the comment, I can't remove it since it's used (and I'm not even sure, how bad it is now). PGE uses it for example. D'oh. Jonathan
[svn:perl6-synopsis] r13415 - doc/trunk/design/syn
Author: larry Date: Sat Nov 4 10:00:08 2006 New Revision: 13415 Modified: doc/trunk/design/syn/S02.pod Log: More clarification on parsing of "if " vs "if()". Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Nov 4 10:00:08 2006 @@ -2342,9 +2342,12 @@ is notionally "first" wins. For instance, given the example above, a statement_control is always going to win out over a prefix operator of the same name. And the reason you can't call a function named "if" -directly because it would be hidden either by the statement_control -category at the beginning of a statement or the statement_modifier -category elsewhere in the statement.) +directly as a list operator is because it would be hidden either by +the statement_control category at the beginning of a statement or by +the statement_modifier category elsewhere in the statement. Only the +C form unambiguously calls an "if" function, and even that +works only because statement controls and statement modifiers require +subsequent whitespace, as do list operators.) Here are the current grammatical categories:
Re: set_pmc_keyed_int delegates to set_pmc_keyed...?
On Fri, Nov 03, 2006 at 04:28:41PM -0800, Jonathan Worthington wrote: > Leopold Toetsch wrote: > >Class inheritance from PMCs is very static still (like PMC-only cases). I > >hope that the :vtable patches will provide the base for a better solution. > >For now, you can only implement the mssing _integer_keyed cases in Match > >so that default isn't triggered. We could of course remove the defaults > >too, but that would need a very complete set of these keyed vtables on all > >PMCs. > > > Or how about removing them from default.pmc and having an extra > attribute specifiable on PMCs like "auto_keyed" (uh, somebody please > think of a less naff name) that generates missing keyed methods for > those PMCs that want them. To me that feels like a hack. The current rather-too-static dispatch (to me) seems to be the bug, and the thing that needs fixing. Nicholas Clark
[svn:perl6-synopsis] r13414 - doc/trunk/design/syn
Author: larry Date: Sat Nov 4 09:29:42 2006 New Revision: 13414 Modified: doc/trunk/design/syn/S02.pod Log: Clarified that ordering of grammatical categories is controlled by the magical hash matching construct. Modified: doc/trunk/design/syn/S02.pod == --- doc/trunk/design/syn/S02.pod(original) +++ doc/trunk/design/syn/S02.podSat Nov 4 09:29:42 2006 @@ -12,9 +12,9 @@ Maintainer: Larry Wall <[EMAIL PROTECTED]> Date: 10 Aug 2004 - Last Modified: 9 Oct 2006 + Last Modified: 4 Nov 2006 Number: 2 - Version: 76 + Version: 77 This document summarizes Apocalypse 2, which covers small-scale lexical items and typological issues. (These Synopses also contain @@ -2324,11 +2324,27 @@ At each point in the parse, the lexer knows which subset of the grammatical categories are possible at that point, and follows the longest-token rule across all the active grammatical categories. -(Ordering of grammatical categories matters only in case of a "tie", -in which case the grammatical category that is notionally "first" -in the grammar wins. For instance, a statement_control is always going to win out over a prefix operator of the same name. More specifically, you can't -call a function named "if" directly because it would be hidden either -by the statement_control category or the statement_modifier category.) +The grammatical categories that are active at any point are specified +using a regex construct involving a set of magical hashes. For example, +the matcher for the beginning of a statement might look like: + +<%statement_control +| %scope_declarator +| %prefix +| %prefix_circumfix_meta_operator +| %circumfix +| %quote +| %term +> + +(Ordering of grammatical categories within such a construct matters +only in case of a "tie", in which case the grammatical category that +is notionally "first" wins. For instance, given the example above, a +statement_control is always going to win out over a prefix operator of +the same name. And the reason you can't call a function named "if" +directly because it would be hidden either by the statement_control +category at the beginning of a statement or the statement_modifier +category elsewhere in the statement.) Here are the current grammatical categories:
Re: set_pmc_keyed_int delegates to set_pmc_keyed...?
Leopold Toetsch wrote: Class inheritance from PMCs is very static still (like PMC-only cases). I hope that the :vtable patches will provide the base for a better solution. For now, you can only implement the mssing _integer_keyed cases in Match so that default isn't triggered. We could of course remove the defaults too, but that would need a very complete set of these keyed vtables on all PMCs. Or how about removing them from default.pmc and having an extra attribute specifiable on PMCs like "auto_keyed" (uh, somebody please think of a less naff name) that generates missing keyed methods for those PMCs that want them. I discovered the same issue when implementing :vtable, and it can produce some misleading error messages - you get a "no get_integer_keyed" error when you know full well the code is doing a get_integer_keyed_int. Jonathan
[svn:parrot-pdd] r15108 - trunk/docs/pdds/clip
Author: particle Date: Sat Nov 4 08:30:37 2006 New Revision: 15108 Modified: trunk/docs/pdds/clip/pdd15_objects.pod Log: [PDD15]: pod formatting fixes Modified: trunk/docs/pdds/clip/pdd15_objects.pod == --- trunk/docs/pdds/clip/pdd15_objects.pod (original) +++ trunk/docs/pdds/clip/pdd15_objects.pod Sat Nov 4 08:30:37 2006 @@ -6,6 +6,7 @@ docs/pdds/pdd15_objects.pod - Object and Class semantics for Parrot =head1 REQUIREMENTS + This PDD is due an overhaul. This requirements section is for language implementers to list the OO-related needs of their language in so as to aid that. @@ -29,6 +30,7 @@ garbage collection schemes. =head2 Classes + A class is a collection of methods and attributes. It would be desirable, for those classes whose definition is fully known at compile time, to have a convenient way to have the class along with its attributes and methods stored @@ -36,9 +38,11 @@ classes at runtime will be needed too. =head2 Meta-classes + Ruby: Ruby has meta classes. It would be nice if classes were objects in Parrots OO model. =head2 Attributes + Attributes are instance data associated with a class (or role, however those are supported). They may not always be of a type specified by a PMC, though boxing/unboxing is of course an option. @@ -58,6 +62,7 @@ Ruby: Attributes can be dynamically added and removed at runtime. =head2 Methods + Perl 6: Methods may be public (anyone can invoke them) or private (only invokable by the class they are defined in). Additionally, submethods are methods that do not get inherited. @@ -68,6 +73,7 @@ Methods can be dynamically added and removed at runtime. =head2 Constructors + A constructor is run when an object is instantiated. .Net: There may be many constructors for an object (provided they all have @@ -75,6 +81,7 @@ parameters. =head2 Inheritance + Perl 6: Multiple inheritance. .Net: Single inheritance. @@ -82,6 +89,7 @@ Ruby: Single inheritance but support for mixins of ruby modules. =head2 Interfaces + An interface specifies a set of methods that must be implemented by a class that inherits (or implements) the interface, but does not provide any form of implementation for them. @@ -90,6 +98,7 @@ check behavior of you implement two interfaces with methods of the same name. =head2 Roles + A role consists of a set of methods and attributes. It cannot be instantiated on its own, but must be composed into a class. When this happens its methods and attributes become of that classes methods and attributes. This may happen @@ -106,6 +115,7 @@ for runtime composition, that's not so easy though. =head2 Introspection (aka Reflection) + Perl 6: Reflection provides access to a list of methods that a class has, its parent classes and the roles it does, as well as the name of the class and its memory address. For methods, their name, signature, return type and whether @@ -116,6 +126,7 @@ methods are also available. =head2 Inner Classes + An inner class is essentially a class defined within a class. Therefore it has access to things private to its outer class. @@ -125,6 +136,7 @@ internal. =head2 Delegation + Delegation is where a method call is "forwarded" to another class. Parrot may provide support for simple cases of it directly, or could just provide a "no method matched" fallback method that the compiler fills out to implement the
Re: set_pmc_keyed_int delegates to set_pmc_keyed...?
Am Samstag, 4. November 2006 16:17 schrieb Patrick R. Michaud: > Because 'Match' doesn't define its own set_integer_keyed_int > vtable entry, it ought to be inheriting the one from Capture. > But unfortunately, the default.pmc function above gets in the > way, and redispatches the keyed_int call as a keyed call, Class inheritance from PMCs is very static still (like PMC-only cases). I hope that the :vtable patches will provide the base for a better solution. For now, you can only implement the mssing _integer_keyed cases in Match so that default isn't triggered. We could of course remove the defaults too, but that would need a very complete set of these keyed vtables on all PMCs. leo
set_pmc_keyed_int delegates to set_pmc_keyed...?
Yesterday and today I've been working on a Capture PMC type for Parrot, and I'm running into all sorts of interesting issues when dealing with subclassing. (For those who aren't familiar with Captures, a Capture is essentially a container object that has both indexed (array) and keyed (hash) components, like Match object.) Here's the latest... Currently src/pmc/default.pmc has lots of functions like the following: /* Converts C to a PMC key and calls C with it and C. */ void set_integer_keyed_int (INTVAL key, INTVAL value) { PMC* r_key = INT2KEY(INTERP, key); DYNSELF.set_integer_keyed(r_key, value); } If I understand how this works, this means that any subclass of ParrotObject that doesn't define its own set_integer_keyed_int vtable entry is automatically re-dispatched to set_integer_keyed instead. The same is true for others -- e.g., set_pmc_keyed_int is forwarded to set_pmc_keyed, etc. Well, okay, but that doesn't work if a compiler uses PIR to create a subclass of a PMC class that makes a distinction between keyed access and integer access. For example: $P99 = subclass 'Capture', 'Match' $P1 = new 'Match' $P1['abc'] = 1 # store value in hash component $P1[0] = 2 # store value in array component Because 'Match' doesn't define its own set_integer_keyed_int vtable entry, it ought to be inheriting the one from Capture. But unfortunately, the default.pmc function above gets in the way, and redispatches the keyed_int call as a keyed call, so that the last instruction stores a 2 in the object's hash component instead of its array component. Here's a more complete example showing how inheritance isn't working properly for a subclass: $ cat z.pir .sub main :main $P0 = new .Capture # create Capture object $P0['alpha'] = 1 # store value in hash component $P0[0] = 2 # store value in array component $I0 = elements $P0 # display size of array (should be 1) print $I0 print "\n" # create a 'Match' subclass of Capture $P99 = subclass 'Capture', 'Match' $P1 = new 'Match' # create Match object $P1['alpha'] = 1 # store value in hash component $P1[0] = 2 # store value in array component $I1 = elements $P1 # display size of array (should be 1) print $I1 print "\n" .end $ ./parrot z.pir 1 0 Any thoughts about how we should resolve this? Pm