Re: Referring to source code within Perldoc: the new A code

2007-06-20 Thread Mark Overmeer
* Damian Conway ([EMAIL PROTECTED]) [070620 05:17]:
 Feedback and suggestions are most welcome.

Clear and usable, in the boundaries you set to yourself.

Just my thoughts.  A lot of questions and speculation, you do
not need to answer all.  I'll try to only comment on this design,
and not restart our usual discussion.

 role Transaction {
 =alias class  Arole
 
state Int $trans_counter;
 =alias Vmy Int  Astate Int
 
 =DESCRIPTION
 The Amy Int variable is used to track the total number of transactions
 active at any one time. The value of Amy Int is incremented by the
 Aclass CBUILD submethod and decremented by the Aclass destructor.

This is exactly the form of documentation you do *not* want the
user to write, for various reasons:

  * it is stylish quite bad to repeat words like 'variable', 'class',
or 'method' in nearly every sentence.  It makes manual-pages
painfully unpleasant.

  * The explicit naming of the class name in method and attribute
descriptions is in general a bad idea: by inheritance, you get
sub-classes which also provide this method.  In the people's
mind (I mean normal people, not our perl guru), this
requires continuous translations which distracts from the message.

 h1class Transaction/h1
 pThe transaction class defines the following methods and attributes./p

 pThe $trans_counter variable is used to track the total number of
 transactions active at any one time. The value of $trans_counter is
 incremented by the Transaction BUILD submethod and decremented by
 the Transaction destructor./p

 pThe $max variable reports the number of Transaction objects which
 are allowed to be processed in parallel.  This is a constant value,
 which defaults to 10./p
 
and so on.  For many pages long.  What, IMO, you want is a clean
and condensed way of expressing.  At least I would prefer output
in this shape:

 h1class Transaction/h1
 pThe transaction class defines the following methods and attributes./p

 ul
 dtprivate attribute $trans_counter/dd
 ddtracks the number of transactions actions active at any one time. The
 value is incremented by BUILD() and decremented at Transaction
 destruction./dd
 dtpublic attribute $max (read-only, default 10)/dt
 ddthe number of transactions are allowed to be processed in
 parallel./dd

Concise, correct, and complete.
Of course, adapted to the features of the output channel, using
templates and style-sheets in the document generating tools.

  * How do you see this syntactically work in combination with the
item list? At least the POD(5) needed that.  I need a combined
example.

  * Having aliases is pratical, for referencing.  However, in this
latter example it is used to help the programmer to shoot himself
in the foot.  If you allow people to say class each time they
mean role, or function where it is method, then on the long
run people will start making avoidable programming mistakes.

In the chosen approach, this abuse cannot be avoidable. But it
may be a wise not to promote it by using it as example.

  * Using ambient back-references this way probably requires a
two-pass document generator. AFAIK this is not required for the
design of POD6 so far.

  * the A(..) syntax is nice, but has a few dangers.  Serious
problems.  Your examples are a bit brief.  A little larger:

 method eat(Food $meal) {...}

   =for DESCRIPTION
   The Amethod() method has the following argument list: A(..)

Now the method gets implemented:

 method eat(Food $meal) {
if($manger.isFull) { $manger.clean }
 }

   =for DESCRIPTION
   The Amethod() method has the following argument list: A(..)

Oops... now the argument list became (without warning)
$manger.isFull   So, either you impose a strict doc order, forcing
people into your style, or people have to use an alias everywhere,
bulking the file. More subtle examples of this problem can be
created, for instance when the method defines a return type

  * In the manual-page of my sub-class, I want to refer to the
documentation of specific attributes and methods.  How?
Can I also refer to elements in distributions which are not
mine, so where I cannot add X or such?  For instance,
when I inherit from a core Perl class?

  * In my sub-class, I want to enlist automatically the methods
and attributes which are inherited.  Automatically of course,
because I want to avoid mistakes.  In case of multi-level
inheritance, some way I need to know and show where each is
defined. How?
For instance, if your look at IO::File in Perl5, it defines
some own method, but then simply says: see also IO::Handle
and IO::Seekable.  IO::Handle says: see also perlfunc and
perlvar.  The more extended your OO model is, (Perl6's
structure is probably much more extended), the more levels
of hierarchy you get.  Are users able to 

Re: Query regarding Java/perl interface

2007-06-20 Thread Tim Bunce
On Wed, Jun 20, 2007 at 12:53:32PM +0800, Agent Zhang wrote:
 On 6/19/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 Hi I am sameer and am new to this group. It would realy help if any
 body can let me know is there a book or reference guiode where in i
 can get help regarding the perl/java interface and also about the tool
 named Java perl lingo.

Java perl lingo, or JPL, was the name for some very early work done by
Larry Wall to integrate Java and Perl5. As far as I know it was
abandoned a few years ago.

 For the Java to Perl 5 interface, see Inline::Java on CPAN:
 
 http://search.cpan.org/dist/Inline-Java/

Inline::Java seems to be the main form of integration with perl5 these days.
See http://search.cpan.org/~timb/JDBC/lib/JDBC.pm for an example.

Tim.

 For a Java to Perl 6 API translator, see Java::Javap:
 
 http://search.cpan.org/perldoc?Java::Javap
 
 The author's journals may be helpful too:
 
 http://use.perl.org/~philcrow/journal

 Cheers, agentz



[perl #43261] [TODO] give STMVar some real documentation

2007-06-20 Thread via RT
# New Ticket Created by  Allison Randal 
# Please include the string:  [perl #43261]
# in the subject line of all future correspondence about this issue. 
# URL: http://rt.perl.org/rt3/Ticket/Display.html?id=43261 


The PMC src/pmc/stmvar.pmc currently shows up in the package information 
as XXX.

http://search.cpan.org/~arandal/parrot-0.4.13/src/pmc/stmvar.pmc

Allison


Re: Perl6 new features

2007-06-20 Thread Moritz Lenz
cdumont wrote:
 I know that perl doesn't only focus on web apps and my question might 
 seem irrelevant
 but I've been searching the web in order to find the new features of 
 perl6 regarding
 new functions, core module lists (not perl grammar itself) but couldn't 
 find any thing...

Perl 6 is not yet finished, so the the list of core modules is not yet
specified.

 I would like to develop web apps with perl too but having to download 
 modules from CPAN
 every time makes me feel these apps will never be able to evoluate in 
 different environments.
 (environments you don't have control of)

That's a general problem with libraries, not only Perl ones. And you
can't solve this by putting everything into core - it just blows up the
distribution.

 I am a bit amazing to see that perl doesn't include a bunch a set theory 
 functions too.

Perl 6 does. See for example ext/Set/ in the pugs repository.
And so does Perl 5:
http://search.cpan.org/~samv/Set-Object-1.21/lib/Set/Object.pm


 I am not blaming perl but only hopes that perl6 will allow to make 
 things easy for the programmer.

That's one of the most important design goals ;-)

 as for the web, maintaining state thru server side cookies and DBI are 
 the very minimum I would recommend.
 more hash and array functions a minimum too.
 if there are such things in perl6, I'll be very happy to work with this 
 language !

You could help by contributing some suggestions to what the new Web
module should be able to do, and how so. Web is hopefully CGI done
right, and still in its early planning stage.

Cheers,
Moritz

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/



signature.asc
Description: OpenPGP digital signature


Re: Parrot 0.4.13 Clifton Released

2007-06-20 Thread David Fetter
On Tue, Jun 19, 2007 at 10:53:07PM -0700, Allison Randal wrote:
 Jonathan Scott Duff wrote:
 
 - Misc:
   + Updated Parrot distribution to Artistic License 2.0, from dual
 Artistic 1/GPL license.
 
  Does this mean that Parrot is no longer dual licensed?
 
 Yes. Under section 4(c)(ii) of Artistic 2.0 you can redistribute the
 code under the GPL (any version), LGPL, or MPL, so there's no need
 for dual licensing anymore.

Please find enclosed a modified .spec file for the new parrot's RPMs :)

Cheers,
D
-- 
David Fetter [EMAIL PROTECTED] http://fetter.org/
phone: +1 415 235 3778AIM: dfetter666
  Skype: davidfetter

Remember to vote!
Consider donating to PostgreSQL: http://www.postgresql.org/about/donate
Name:   parrot
Version:0.4.13
Release:1%{?dist}
Summary:Parrot Virtual Machine
License:Artistic 2.0
Group:  Development/Libraries
URL:http://www.parrotcode.org/
Source0:
http://www.cpan.org/authors/id/A/AR/ARANDAL/parrot-%{version}.tar.gz
BuildRoot:  %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires:  readline-devel
BuildRequires:  ncurses-devel
BuildRequires:  gmp-devel
BuildRequires:  gdbm-devel
BuildRequires:  /usr/bin/perldoc
BuildRequires:  bc
BuildRequires:  m4
BuildRequires:  libicu-devel
BuildRequires:  perl-SVK

%package devel
Summary:Parrot Virtual Machine development headers and libraries
License:Artistic 2.0
Group:  Development/Libraries
Requires:   %{name} = %{version}-%{release}
Requires:   %{_libdir}/pkgconfig

%description
Parrot is a virtual machine designed to efficiently compile and
execute bytecode for interpreted languages. Parrot will be a target
for the Perl 6 compiler, and is already usable as a backend for
Pugs, as well as variety of other languages.

%description devel
Parrot Virtual Machine development headers and libraries.

%prep
%setup -q

%{__perl} -pi -e 's,lib/,%{_lib}/, if (/CONST_STRING\(interp,/)' \
src/library.c
%{__perl} -pi -e s,'/usr/lib','%{_libdir}',;s,runtime/lib/,runtime/%{_lib}/, \
tools/dev/install_files.pl \
tools/dev/mk_manifests.pl

%build
%{__perl} Configure.pl \
--prefix=%{_usr} \
--libdir=%{_libdir} \
--sysconfdir=%{_sysconfdir} \
--infodir=%{_datadir}/info \
--mandir=%{_mandir} \
--cc=%{__cc} \
--cxx=%{__cxx} \
--optimize=$RPM_OPT_FLAGS -maccumulate-outgoing-args \
--parrot_is_shared \
--lex=/usr/bin/flex \
--yacc=/usr/bin/yacc \
--libs='-lcurses -lm'

export LD_LIBRARY_PATH=$( pwd )/blib/lib
make

%install
rm -rf $RPM_BUILD_ROOT

export LD_LIBRARY_PATH=$( pwd )/blib/lib
make reallyinstall DESTDIR=$RPM_BUILD_ROOT

# Drop the docs so rpm can pick them up itself.
rm -rf $RPM_BUILD_ROOT/%{_docdir}/parrot

# Force permissions on doc directories.
find docs examples -type d -exec chmod 755 {} \;
find docs examples -type f -exec chmod 644 {} \;

# Force permissions on shared libs so they get stripped.
find $RPM_BUILD_ROOT%{_libdir} -type f \( -name '*.so' -o -name '*.so.*' \) \
-exec chmod 755 {} \;

# These files *probably* aren't needed.
rm -rf $RPM_BUILD_ROOT%{_usr}/compilers \
$RPM_BUILD_ROOT%{_usr}/config \
$RPM_BUILD_ROOT%{_includedir}/src \
$RPM_BUILD_ROOT%{_usr}/src

%check
export LD_LIBRARY_PATH=$( pwd )/blib/lib
# make test  /dev/null
# %{?_with_fulltest:make fulltest  /dev/null}
# make test || :
# %{?_with_fulltest:make fulltest || :}

%clean
rm -rf $RPM_BUILD_ROOT

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files
%defattr(-,root,root,-)
%doc ABI_CHANGES ChangeLog CREDITS NEWS PBC_COMPAT PLATFORMS README
%doc RESPONSIBLE_PARTIES TODO
%doc docs examples
%exclude %{_bindir}/parrot-config
%{_bindir}/*
%{_libdir}/parrot
%{_libdir}/libparrot.so.*

%files devel
%defattr(-,root,root,-)
%{_bindir}/parrot-config
%{_includedir}/parrot
%{_libdir}/libparrot.so
%{_libdir}/libparrot.a
%{_libdir}/pkgconfig/*

%changelog
* Fri May 25 2007 David Fetter [EMAIL PROTECTED] 0.4.12-1
- Update to 0.4.12.

* Wed Apr 18 2007 Steven Pritchard [EMAIL PROTECTED] 0.4.11-1
- Update to 0.4.11.

* Wed Mar 21 2007 Steven Pritchard [EMAIL PROTECTED] 0.4.10-1
- Update to 0.4.10.

* Sat Mar 10 2007 Steven Pritchard [EMAIL PROTECTED] 0.4.9-1
- Update to 0.4.9.
- BR ncurses-devel.
- For some reason now I need to force -lm too.
- Remove some files/directories that shouldn't be included.

* Wed Jan 17 2007 Steven Pritchard [EMAIL PROTECTED] 0.4.8-1
- Attempt update to 0.4.8.

* Fri Jun 30 2006 Steven Pritchard [EMAIL PROTECTED] 0.4.5-5
- Override lib_dir and make various substitutions to try to fix multilib.
- Remove rpath use from Makefile.
- Fix a pod error in src/ops/experimental.ops.
- Enable make test since t/doc/pod.t won't fail now.

* Wed Jun 28 2006 Steven Pritchard [EMAIL PROTECTED] 0.4.5-4
- Force permissions on shared libraries so rpmbuild strips them.

* Wed Jun 28 2006 Steven Pritchard [EMAIL PROTECTED] 0.4.5-3
- 

Re: Perl6 new features

2007-06-20 Thread cdumont

Thank you for your kind reply !

Perl 6 is not yet finished, so the the list of core modules is not yet
specified.


I know that it is somehow not the subject,
but I think the actual 5.8 doc should be changed to some extents.
It could be nice if we could browse each core functions,
having the function parameters, flags (not that much used right?), and
the return value of the function, followed by exampleS
AND so that it could be a lot richer, allow people to comment...
I know this is not the point but it could be nice to do so for perl6 !
(I was thinking to create a kind of site like that for the actual perl,
but my programming competences are,well... )

Perl 6 does. See for example ext/Set/ in the pugs repository.


Glad to hear that !


You could help by contributing some suggestions to what the new Web
module should be able to do, and how so. Web is hopefully CGI done
right, and still in its early planning stage.


Web module is a good name.

Is there a place where we can add suggestions ? apart from the first one in...
2003 ? 4 years ago ?


Moritz Lenz wrote:


cdumont wrote:
 

I know that perl doesn't only focus on web apps and my question might 
seem irrelevant
but I've been searching the web in order to find the new features of 
perl6 regarding
new functions, core module lists (not perl grammar itself) but couldn't 
find any thing...
   



Perl 6 is not yet finished, so the the list of core modules is not yet
specified.

 

I would like to develop web apps with perl too but having to download 
modules from CPAN
every time makes me feel these apps will never be able to evoluate in 
different environments.

(environments you don't have control of)
   



That's a general problem with libraries, not only Perl ones. And you
can't solve this by putting everything into core - it just blows up the
distribution.

 

I am a bit amazing to see that perl doesn't include a bunch a set theory 
functions too.
   



Perl 6 does. See for example ext/Set/ in the pugs repository.
And so does Perl 5:
http://search.cpan.org/~samv/Set-Object-1.21/lib/Set/Object.pm


 

I am not blaming perl but only hopes that perl6 will allow to make 
things easy for the programmer.
   



That's one of the most important design goals ;-)

 

as for the web, maintaining state thru server side cookies and DBI are 
the very minimum I would recommend.

more hash and array functions a minimum too.
if there are such things in perl6, I'll be very happy to work with this 
language !
   



You could help by contributing some suggestions to what the new Web
module should be able to do, and how so. Web is hopefully CGI done
right, and still in its early planning stage.

Cheers,
Moritz

 




--
シリル・デュモン(Cyrille Dumont)
[EMAIL PROTECTED]
our work is the portrait of ourselves
tel: 03-5690-0230 fax: 03-5690-7366
http://www.comquest.co.j




Re: Perl6 new features

2007-06-20 Thread Chaddaï Fouché

2007/6/20, cdumont [EMAIL PROTECTED]:

I know that it is somehow not the subject,
but I think the actual 5.8 doc should be changed to some extents.

snip

AND so that it could be a lot richer, allow people to comment...


Well you can't comment it (CPAN Annotate allow you to comment the doc
of any CPAN module though), but the perl documentation is quite
extensive, and I for one don't understand what you mean by :


It could be nice if we could browse each core functions,
having the function parameters, flags (not that much used right?), and
the return value of the function, followed by exampleS


it seems to me that you already have this : in line of command you can
use perldoc -f split to get the split() doc, where there are
examples and return value and parameters are discussed at length, if
you prefer a modern format,
http://perldoc.perl.org/functions/split.html should content you, and
you can use Pod::POM::Web to get a small HTTP server where all Perl
doc (core and modules) can be browsed and searched, so what exactly
are you speaking about ?

--
Jedaï


Re: Perl6 new features

2007-06-20 Thread Moritz Lenz
A: because it disrupts the natural way of thinking.
Q: Why is top posting frowned upon?

cdumont wrote:
 Perl 6 is not yet finished, so the the list of core modules is not yet
 specified.
 
 
 I know that it is somehow not the subject,
 but I think the actual 5.8 doc should be changed to some extents.

You should discuss that on p5p, not here. Only Perl 6 is on topic here.

 Is there a place where we can add suggestions ? apart from the first one in...
 2003 ? 4 years ago ?

You can write them here on p6l.


-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/



signature.asc
Description: OpenPGP digital signature


Re: assign-if-uninitialized [Was: Generalizing ?? !!]

2007-06-20 Thread Charles Bailey

On 6/19/07, Larry Wall [EMAIL PROTECTED] wrote:

On Tue, Jun 19, 2007 at 11:50:35AM -0400, Charles Bailey wrote:
: Yep.  For that matter, if I had to pick one change in this area that'd
: have maximum impact, I'd say a good assign-if-uninitialized idiom
: would be way ahead of an if-then-else idiom.

Depending on how you mean uninitialized, that would be either:

$x //= 42;  # init if undefined

or

state $x = 42;  # init first time through

Both of which are getting borrowed back into Perl 5, as it happens.


This is a Good Thing, on both counts.  (I was thinking primarily of the former.)

My intent was to say that I'm glad this was addressed in the design of
P6, since it is, in my experience, a much more common version of the
conditional assignment problem than the ternary operator.   Yet
another example of P6 doing things well.

Rereading my original comment, I see this is less than clear.  My
apologies for the confusion.

--
Regards,
Charles Bailey
Lists: bailey _dot_ charles _at_ gmail _dot_ com
Other: bailey _at_ newman _dot_ upenn _dot_ edu


[perl #43246] [CAGE] Replace string_from_const_cstring() with string_from_cstring()

2007-06-20 Thread Nuno Carvalho via RT
Greetings,

On Mon Jun 18 16:57:45 2007, chromatic !-- x -- at wgz.org wrote:
 Per the note in src/string.c around line 509:
 
   /* XXX This is identical to string_from_cstring and should be removed */
   PARROT_API
   STRING *
   string_from_const_cstring(Interp *interp, 
   const char *buffer /*NULLOK*/, const UINTVAL len)
 
 ... replace all uses of string_from_const_cstring() with calls to 
 string_from_cstring(), then remove this function.

Replaced in r19164. Also replaced in languages/*, so, language
maintainers, please verify that this change didn't brake anything. From
my make tests everything looks ok. 

Probably needs a makeclean.

Best regards,
./smash


bignum.c seems to be unused

2007-06-20 Thread Andy Lester
bignum.c seems to be entirely unused.  Everything builds just fine  
without it.  There are many lint errors in it, such as int functions  
returning with return; and no value.


Can we throw it away?  Move it somewhere out of the way?

--
Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance






Re: [svn:perl6-synopsis] r14421 - doc/trunk/design/syn

2007-06-20 Thread brian d foy
In article
[EMAIL PROTECTED], Chaddaï
Fouché [EMAIL PROTECTED] wrote:

 The Learning Perl 6 argument seems
 equally contrived to me since anyway you don't need POD to understand
 programming in Perl and I never actually learned POD until I wanted to
 do a real module and document my little console utilities in Perl.

That's exactly my argument. You didn't need to learn that because you
weren't specifically doing anything with Pod. It doesn't even come up
because it's something you have to affirmatively do, and it's not
something that accidentally happens.

 And if some do it, hell, I seriously
 doubt that their program would be in the scope of the beginning of
 Learning Perl 6 !! You didn't put -+- there in previous versions,
 did you ?

I'm not sure what you mean mean by - + -.

Our current Learning Perl class starts off with a little Pod
manipulation because we know that everyone (should!) has the perldoc
along with their Perl. My actual experience trumps your serious doubt
:)


 The other problem is that if somehow a braindead guy (where would he
 get the idea from, I never saw such a style) put his = in first
 column expecting a assignment he won't get it... Seriously ? Are you
 really allowing for such weirdness in introductory material to a
 Language course ?

How is that braindead? It's perfectly fine, allowable, and intended
that a Perl 5 programmer can break statements over more than one line.
It's not weird at all.

I've taught a lot of beginner Perl classes, and people do all sorts of
things.


 So in my opinion, it would be fine to let slip that you can also
 create some kind of comment/doc by putting a = in the first column in
 the first chapter, and let the subject of POD for a later chapter.

The problem is that once you bring something up, people want to know
why you brought it up, and then they start playing with that point to
see what you meant. All of a sudden, you're explaining a lot of stuff
that doesn't get people any closer to completing a simple program.

As I've said previously, the rule for Pod looks simple, but the rules
for other things, such as strings, are now more complicated. However,
Larry mentioned that the Pod extractor may do what it likes, but Perl
shouldn't have to live with it's decisions about what is executable
code and what isn't, so it may still work out.


Re: [svn:parrot] r19168 - trunk/src

2007-06-20 Thread chromatic
On Wednesday 20 June 2007 07:57:15 [EMAIL PROTECTED] wrote:

 Modified:
trunk/src/inter_call.c

 Log:
 Changed MAX to PARROT_MAX to avoid conflicts with any existing MAX

 Modified: trunk/src/inter_call.c
 ===
=== --- trunk/src/inter_call.c (original)
 +++ trunk/src/inter_call.cWed Jun 20 07:57:14 2007
 @@ -27,6 +27,8 @@

  /* HEADER: include/parrot/inter_call.h */

 +/* Make sure we don't conflict with any other MAX() macros defined
 elsewhere */ +#define PARROT_MAX(a,b) (((a))  (b) ? (a) : (b))

Alternately, we could hoist this macro into a header, rename it back to MAX, 
and define it only if no system header defines MAX.  I think it's in math.h, 
but I'm not positive.

-- c


Re: [svn:parrot] r19168 - trunk/src

2007-06-20 Thread Andy Lester


On Jun 20, 2007, at 11:23 AM, chromatic wrote:

Alternately, we could hoist this macro into a header, rename it  
back to MAX,
and define it only if no system header defines MAX.  I think it's  
in math.h,

but I'm not positive.


It's that I'm not positive that scares me, because on the BSD box I  
was using it was in something that wasn't math.h, which surprised me.


So I did what I did.

--
Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance






Re: memcpy

2007-06-20 Thread Allison Randal
I wasn't entirely happy with either option, so I asked around a bit for 
other ideas. I like the macro approach below, it gives us both self 
documentation and better checking for the size of the two structs.


Allison

 Original Message 
From: Nick Forrette [EMAIL PROTECTED]
To: Allison Randal [EMAIL PROTECTED]

This can be a bit brittle -- you have to be careful when changing the
type of dst else you could end up with over or underflow.
memcpy(dst, src, sizeof(FOO));

I do like memcpy because it serves as a red flag that a potentially
medium to large size hunk of memory will be copied here,
memcpy(dst, src, sizeof(*dst));

This gets you better type checking (if src and dst are different
struct types, the compiler will complain). Much harder to overflow dst
or only partially copy src.
*dst = *src;


Something like this can get you the best of the above, as long as
you're careful about size-effects (I'd have to double check to be
sure, but I believe there are differences with pre-increment/decrement
in a dereference/assignment v.s. two arguments to a function).

#define copy_struct(dst, src) \
   (*(dst) = *(src))

copy_struct(dst, src);


You could use a more robust macro that does a run time check for size 
effects:


// returns int so it can be used in a , expression
int myAssert(int thisIsABool)
{
  assert(thisIsABool);
  return 0;
}

#ifdef NDEBUG
#define macro_assert(thisIsABool) 0
#else
#define macro_assert(thisIsABool) myAssert(thisIsABool)
#endif

#define copy_struct(dst, src) \
   (\
   macro_assert((dst) == (dst)), \
   macro_assert((src) == (src)), \
   (*(dst) = *(src)) \
   )


Gives you what I consider the best of all worlds. The compiler will
flag copying between different struct types, it is more robust in the
face of changed types for src or dst, in form that clearly spells out
what you're trying to do, that at least gives you run time checking
for abuse of side effects in debug builds.

Nick


Re: memcpy

2007-06-20 Thread Andy Lester


On Jun 20, 2007, at 11:50 AM, Allison Randal wrote:

I wasn't entirely happy with either option, so I asked around a bit  
for other ideas. I like the macro approach below, it gives us both  
self documentation and better checking for the size of the two  
structs.


I guess I don't see the need to document a standard C behavior with a  
macro.  We don't have


  #define inc(x) (x)++

do we?

xoxo,
Andy

--
Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance






Re: memcpy

2007-06-20 Thread Mark J. Reed

On 6/20/07, Andy Lester [EMAIL PROTECTED] wrote:

I guess I don't see the need to document a standard C behavior with a
macro.  We don't have

   #define inc(x) (x)++

do we?


Incrementing a var is much less likely to have unpredictable effects
due to modifying the wrong memory.  Sure, x might be a pointer, and
things might gang agley there, but pointers getting set to the wrong
type of pointee is a pretty common problem, and one that I'm happy to
have some runtime support in locating.

--
Mark J. Reed [EMAIL PROTECTED]


Re: memcpy

2007-06-20 Thread Mark J. Reed

On 6/20/07, Andy Lester [EMAIL PROTECTED] wrote:

My point is that

   *d = *s;

is no more a weird cryptic construct than

   n++;

or

   while (*s)
 *d++ = *s++;

for that matter.


That's a very good point.  As you said in the original message, all you need is

*dest = *src;

since the compiler will automatically complain if the two pointers
don't point to the same type of object.  AFAICT, the wrapping around
the assignment in the macro just makes sure that there aren't any side
effects - but the only reason side effects would be a problem is that
it's a macro...

--
Mark J. Reed [EMAIL PROTECTED]


Re: [svn:parrot] r19183 - in trunk: languages/m4/lib/Parrot/Test languages/plumhead/lib/Parrot/Test languages/plumhead/lib/Parrot/Test/Plumhead lib/Parrot

2007-06-20 Thread chromatic
On Wednesday 20 June 2007 12:39:08 [EMAIL PROTECTED] wrote:

 Modified: trunk/lib/Parrot/Test.pm
 ===
=== --- trunk/lib/Parrot/Test.pm(original)
 +++ trunk/lib/Parrot/Test.pmWed Jun 20 12:39:06 2007

 @@ -411,6 +412,76 @@
      return $path;
  }
  
 +
 +# These functions are only used by various
 +# Parrot::Test::lang modules.
 +# See RT#43266
 +# This implementation is experimental and currently only works
 +# for languages/plumhead
 +sub generate_languages_functions {
 +
 +    my %test_map = (
 +        output_is   = 'is_eq',
 +        output_like = 'like',
 +        output_isnt = 'isnt_eq'
 +    );
 +
 +    foreach my $func ( keys %test_map ) {
 +    
 +        my $test_sub = sub {
 +            my $self = shift;
 +            my ( $code, $output, $desc, %options ) = @_;
 +    
 +            my $count = $self-{builder}-current_test() + 1;
 +    
 +            # These are the thing that depend on the actual language
 implementation +            my $out_fn    = $self-get_out_fn( $count,  
  \%options ); +            my $lang_fn   = $self-get_lang_fn( $count,  
  \%options ); +            my @test_prog = $self-get_test_prog( $count,
 \%options ); +
 +            Parrot::Test::write_code_to_file( $code, $lang_fn );
 +    
 +            # set a TODO for Test::Builder to find
 +            my $skip_why = $self-skip_why( \%options );
 +            if ($skip_why) {
 +                $self-{builder}-skip($skip_why);
 +            }
 +            else {
 +    
 +                # STDERR is written into same output file
 +                my $exit_code = Parrot::Test::run_command(
 +                   [EMAIL PROTECTED],
 +                    CD     = $self-{relpath},
 +                    STDOUT = $out_fn,
 +                    STDERR = $out_fn
 +                );
 +    
 +                my $meth = $test_map{$func};
 +    
 +                # That's the reason for:   no strict 'refs';
 +                my $pass = $self-{builder}-$meth(
 Parrot::Test::slurp_file($out_fn), $output, $desc ); +              

That line works under strict 'refs'; all method lookups are symbolic in Perl 
5.

  unless ($pass) {
 +                    my $diag = '';
 +                    my $test_prog = join '  ', @test_prog;
 +                    $diag .= '$test_prog' failed with exit code
 $exit_code. if $exit_code; +                  
  $self-{builder}-diag($diag) if $diag;
 +                }
 +            }

I think this code eats segfaults, as per RT #39197.

There's a lot of opportunity for refactoring and cleanup in the Parrot::Test 
modules.  There's too much duplication as it is.

-- c


[perl #43246] [CAGE] Replace string_from_const_cstring() with string_from_cstring()

2007-06-20 Thread Nuno Carvalho via RT
Resolved in r19164, feel free to re-open if you find any problems.

Best regards, 
./smash


[perl #43269] [BUG] setline is tied to PIR source

2007-06-20 Thread via RT
# New Ticket Created by  Patrick R. Michaud 
# Please include the string:  [perl #43269]
# in the subject line of all future correspondence about this issue. 
# URL: http://rt.perl.org/rt3/Ticket/Display.html?id=43269 


The 'setline' opcode doesn't do what I expect it to do, which
is to associate runtime errors with lines in HLL source.

For example, suppose I have a program foo.p6 where
lines 123 and 124 contain the statements

$a = 9876;
nsf($a + 1);

A HLL compiler could then generate this as something like:

.sub anon
setfile foo.p6
setline 123
$P0 = new .Integer
assign $P0, 9876
set_global '$a', $P0

setline 124
$P0 = get_global '$a'
$P1 = clone $P0
add $P1, 1
'nsf'($P1)
.end

If the function 'nsf' doesn't exist, I expect get a runtime
exception of some sort that says that the error occurred on
line 124 of foo.p6.  Currently parrot reports back that
the error occurs in line 128, as in:

Null PMC access in invoke()
current instr.: 'anon' pc 27 (foo.p6:128)

It appears to me that setfile and setline are currently being
conflated with the PIR directive C #line file.ext nnn .
I think we need both capabilities -- one to relate PIR 
compilation errors relative to a known location in PIR source
(#line), and another to report runtime errors as a line number
in HLL source (setfile+setline).

RT #40806 has some related discussion for this.  I'm also
committing the above code as a test (currently failing).



Another possibility may be to simply deprecate setfile/setline 
altogether, and require other tools (e.g., PAST-pm) generate code
that sets global values somewhere for keeping track of the
HLL source locations.

Pm


question about t/operators/ternary.t

2007-06-20 Thread Patrick R. Michaud
Looking at t/operators/ternary.t...

At the bottom of the file, there is a test that reads:

{
# This parses incorrectly because it's parsed as Bool::True(!! Bool::False).
my $foo = eval q[ 1 ?? Bool::True !! Bool::False ];
is($foo, Bool::True, a statement with both ??!! and :: in it did 
compile), :todobug;
}


I'm not entirely certain what this test is intending to test.
Do we need it?  Does it perhaps belong somewhere else?

Thanks,

Pm


small fixup and question for pdb

2007-06-20 Thread pancake
I'm starting to work on pdb for fixing bugs, segfaults and so, and maybe
implement new commands listed in TODO.

I noticed that command arguments does not support spacing between command
and argument. I have written a small patch that uses nextarg() for getting
command arguments. This means that now works things like:

 (pdb) next 3
 (pdb) next   4

but will not run the old-fashion commands:

  (pdb) next3

imho the 'old' syntax is ugly, and we should relay on the new one checking for
spaces properly.

feel free to submit this patch if looks ok for you.

Thanks

  --pancake
Index: src/debug.c
===
--- src/debug.c	(revision 19192)
+++ src/debug.c	(working copy)
@@ -460,6 +460,8 @@
 if (!(pdb-state  PDB_RUNNING))
 PDB_init(interp, command);
 
+command = nextarg(command);
 /* Get the number of operations to execute if any */
 if (command  isdigit((int) *command))
 n = atol(command);
@@ -505,6 +507,7 @@
 if (!(pdb-state  PDB_RUNNING))
 PDB_init(interp, command);
 
+command = nextarg(command);
 /* if the number of ops to run is specified, convert to a long */
 if (command  isdigit((int) *command))
 n = atol(command);
@@ -772,6 +775,7 @@
 PDB_line_t   *line;
 long  ln, i;
 
+command = nextarg(command);
 /* If no line number was specified, set it at the current line */
 if (command  *command) {
 ln = atol(command);
@@ -909,6 +913,7 @@
 return;
 }
 
+	command = nextarg(command);
 ln = atol(command);
 PDB_skip_breakpoint(interp, ln);
 }
@@ -936,6 +941,7 @@
 PDB_breakpoint_t *breakpoint;
 long  n;
 
+command = nextarg(command);
 if (isdigit((int) *command)) {
 n  = atol(command);
 breakpoint = interp-pdb-breakpoint;
@@ -1971,6 +1977,7 @@
 return;
 }
 
+command = nextarg(command);
 /* set the list line if provided */
 if (isdigit((int) *command)) {
 line_number = atol(command) - 1;
@@ -2157,6 +2164,7 @@
 long   depth = 0;
 Stack_Chunk_t *chunk = CONTEXT(interp-ctx)-user_stack;
 
+command = nextarg(command);
 if (*command)
 depth = atol(command);
 


Re: question about t/operators/ternary.t

2007-06-20 Thread chromatic
On Wednesday 20 June 2007 15:53:59 Moritz Lenz wrote:

 Basically I think that
 - we need the test somewhere and
 - it is not a test that one would usually write unless he/she found a
 regression in one implementation.

 Therefore it would be good to have them somewhere separately, in an
 implementation-specific manner. That would reduce the wtf?-effect
 while reading the official tests.
 Of course all other implementations have to pass them as well...

 I'd suggest t/regression/$implementation/ in the pugs repository as the
 new location for such tests.

That reminds me of a Jarkko quote from p5p:

Crashes Perl (or Used To) is not a really useful classifying 
criterion, it's about as useful as the number of characters in 
the test is divisible by 73.

If the test exercises something that's easy or possible to get wrong in any 
implementation, it belongs in the appropriate classification for that feature 
type for all implementations.

-- c


Re: PMC Proxy high-level review

2007-06-20 Thread Jonathan Worthington

Hi,

Allison Randal wrote:
It looks like every low-level PMC is creating a proxy object for 
itself and these proxies are stored in the interpreter global 
parrot_interp_t.
That's what's implemented, yes. I pondered hanging them off the v-table 
too. That's perhaps more desirable.


I intended that proxies would only be created when they were needed by 
a subclassing Class PMC, and would only be stored in the Class PMC.

I don't think this is the way to go.

1) It'd be good to be able to use the get_class opcode with PMCs as well 
as PDD15 classes. For that to Just Work, you need something hanging off 
the class slot of the appropriate namespace. That something is the 
PMCProxy. Thus it needs to be there from the start.


2) It's desirable that there is only ever one instance of PMCProxy per 
PMC. Then is this the same class is just a case of checking the 
pointers, as with PDD15 classes. Plus memory issues.


3) At the moment method lookup (for non-vtable methods, of course) is 
done through the namespace. We moved away from that in PDD15 classes, 
and with PMCProxy can do the same for methods of PMCs too. If you want 
to be able to have a list of methods inside PMCProxy, you need it stored 
somewhere runtime-accessible. If you're going to hang that data 
somewhere, why not just make the PMCProxy in the first place and store 
it in there.


4) PMCProxy also allows introspection of PMCs, not just placing them in 
an inheritance hierarchy.


5) It's just less code complexity to create them up-front.

What was the motivation for having them instantiated lazily?

Looking at the code from another perspective, though, maybe what we've 
got here is the beginning of an HLLSubclassable role that adds a 
handful of Class methods to low-level PMCs.
I wander if we have different thoughts of what PMCProxy is supposed to 
achieve. Here's what I thought: when you have a PDD15 class, you have 
the instance of Class and you have the instance of Object. For PMCs, you 
have the second of these - an instance of the PMC. PMCProxy fills in the 
gap - it's like the Class PMC for PDD15, only for PMCs rather than PDD15 
classes.


Ultimately all PMCs need to be able to respond to inspect_str. 
Yeah, but there you're inspecting the object, not the class. Those are 
different, I think?


And ultimately, all PMCs need to have an entry in their NameSpace so 
the type IDs can go away entirely. 
They already do, and by hanging PMCProxy off the class slot in the 
NameSpace PMC, we're a step closer to that, if it's the Right Thing to do.


Thanks,

Jonathan


Re: pdd15 - How do I add a class method?

2007-06-20 Thread Jonathan Worthington

Hi,

Patrick R. Michaud wrote:

My first question is How do I add a class method? -- i.e.,
a method that operates on a class instance as opposed
to an object instance of that class.  Ideally the answer
would contain explanations/examples for defining such
methods in PIR and also as PMC methods.
  
I had to deal with this when working on the .Net translator, though I 
really fudged it. Basically, I just didn't have them as methods, but 
rather subs. That meant they didn't expect an invocant. And I translated 
the callmethod .Net op to do the Right Thing. Or something along those 
lines. The disadvantage is that they won't dispatch as methods on the 
instance of the object in Parrot-land (which is at least C# 
behavior...you can't call static methods using obj.meth, only 
class.meth, ignoring C# 3.0's extension methods). But that isn't Perl 6 
behavior, as I understand it.


How about writing the method without the :method modifier, but also 
addmethod'ing it to the class? Then it will be found by find_method, but 
won't think the first parameter is an invocant. Something here doesn't 
feel quite right to me, though I'm tired and can't put my finger on what.


Jonathan



Re: [perl #43269] [BUG] setline is tied to PIR source

2007-06-20 Thread Jonathan Worthington

Patrick R.Michaud (via RT) wrote:

The 'setline' opcode doesn't do what I expect it to do, which
is to associate runtime errors with lines in HLL source.
  
Currently HLL debug info stuff is spec'd, but not implemented. Well, OK, 
the storage of it in bytecode is spec'd, the exact PIR syntax for it 
isn't. So there are two tasks: implement the underlying storage model 
for this and sort out some PIR syntax for it.


How important/blocking is this to you? I can direct some tuits this way 
in the near future if you're needing it.


Jonathan



Re: [perl #43269] [BUG] setline is tied to PIR source

2007-06-20 Thread Patrick R. Michaud
On Thu, Jun 21, 2007 at 12:08:33AM +0100, Jonathan Worthington wrote:
 Patrick R.Michaud (via RT) wrote:
 The 'setline' opcode doesn't do what I expect it to do, which
 is to associate runtime errors with lines in HLL source.
  
 Currently HLL debug info stuff is spec'd, but not implemented. Well, OK, 
 the storage of it in bytecode is spec'd, the exact PIR syntax for it 
 isn't. So there are two tasks: implement the underlying storage model 
 for this and sort out some PIR syntax for it.
 
 How important/blocking is this to you? I can direct some tuits this way 
 in the near future if you're needing it.

Well, it's not too big a block for me personally.  But for
many other people who are now starting to work on testing
the perl6 compiler or building the compiler itself, it's
hugely frustrating (and I can understand that).

For example, consider something like:

$ cat foo.p6
use OtherModule;   # imports some functions

my $x = 1;
bar($x);
baz($x);

Someone who runs this program gets the very cryptic:

$ ../../parrot perl6.pbc foo.p6
Null PMC access in invoke()
current instr.: 'parrot;Perl6::Compiler;main' pc 138 (perl6.pir:98)
$

This doesn't give many clues about where the program is failing
(perl6.pir:98 is the location of the rethrown exception).

So, it's important (to others) but not currently a block (to me).
I'll probably come up with a workaround in PAST.pm of some sort
in the meantime.

Personally, unless fixing this is very easy/straightforward I'd
_much_ prefer to see some of the pdd15 items completed first.

Thanks!

Pm


Re: question about t/operators/ternary.t

2007-06-20 Thread Moritz Lenz
chromatic wrote:
 On Wednesday 20 June 2007 15:53:59 Moritz Lenz wrote:
 
 Basically I think that
 - we need the test somewhere and
 - it is not a test that one would usually write unless he/she found a
 regression in one implementation.

 Therefore it would be good to have them somewhere separately, in an
 implementation-specific manner. That would reduce the wtf?-effect
 while reading the official tests.
 Of course all other implementations have to pass them as well...

 I'd suggest t/regression/$implementation/ in the pugs repository as the
 new location for such tests.
 
 That reminds me of a Jarkko quote from p5p:
 
 Crashes Perl (or Used To) is not a really useful classifying 
 criterion, it's about as useful as the number of characters in 
 the test is divisible by 73.

There is a bit of a difference because there is just one Perl 5
implementation, but multiple Perl 6 implementations.

 If the test exercises something that's easy or possible to get wrong in any 
 implementation, it belongs in the appropriate classification for that feature 
 type for all implementations.

I agree, but on the other hand it raised questions for somebody
(Patrick) reading the test, although it was commented. How would you
address the readability issue if you don't tests like these to separate
files? Perhaps separate parse failure tests?

-- 
Moritz Lenz
http://moritz.faui2k3.org/ |  http://perl-6.de/



signature.asc
Description: OpenPGP digital signature


Re: Perl6 new features

2007-06-20 Thread cdumont

You should discuss that on p5p, not here. Only Perl 6 is on topic here.

Sure, but I've started from perl doc 5.8 in order to say that it could be nice 
to have the features I'm talking about in perl6 so it's not out of the scope I guess.




it seems to me that you already have this : in line of command you can

use perldoc -f split to get the split() doc, where there are

examples and return value and parameters are discussed at length, if

you prefer a modern format,

http://perldoc.perl.org/functions/split.html should content you, and

you can use Pod::POM::Web to get a small HTTP server where all Perl

doc (core and modules) can be browsed and searched, so what exactly

are you speaking about ?


As for the documentation, I've already watched this link 
and depending on the functions, informations are more or left complete.
In the case of split there are quite few examples but it's not the case for a lot of 
documentations.


http://perldoc.perl.org/functions/chop.html
http://perldoc.perl.org/functions/lc.html

You might say that it doesn't need more but 
Adding user comments within the doc could allow to get much more usefull examples
and 'tips' from other programmers. not a full blown oop cpan module but just a 
useful adding, transforming, real word use of the function.


http://perldoc.perl.org/functions/pack.html

This is an other function well documented.
But if in split, the result of the example is included below the code
with a sentence such as 'produces...' here, it is a comment below the line,
or 'gives...'

There's no real common pattern to get in a glimpse the function use.
A kind of standardisation could help.
(what are the arguments names, i've just found : EXPR, VALUE, 
Y,X,VARIABLE,NUMBER,PLAINTEXT...)
there is a standard but it's not very as evident as it could be.

function parameters,flags
function return : .success:... .failure:...
Example :
...
Output :
...

Well i'm talking about the 5.8 but remember it's in order to know 
if there can be ways of improvement for perl6 doc.





Moritz Lenz wrote:


A: because it disrupts the natural way of thinking.
Q: Why is top posting frowned upon?

cdumont wrote:
 


Perl 6 is not yet finished, so the the list of core modules is not yet
specified.


I know that it is somehow not the subject,
but I think the actual 5.8 doc should be changed to some extents.
   



You should discuss that on p5p, not here. Only Perl 6 is on topic here.

 


Is there a place where we can add suggestions ? apart from the first one in...
2003 ? 4 years ago ?
   



You can write them here on p6l.


 




--
シリル・デュモン(Cyrille Dumont)
[EMAIL PROTECTED]
our work is the portrait of ourselves
tel: 03-5690-0230 fax: 03-5690-7366
http://www.comquest.co.j




Re: pdd15 - How do I add a class method?

2007-06-20 Thread Bob Rogers
   From: Jonathan Worthington [EMAIL PROTECTED]
   Date: Thu, 21 Jun 2007 00:05:00 +0100

   Hi,

   Patrick R. Michaud wrote:
My first question is How do I add a class method? -- i.e.,
a method that operates on a class instance as opposed
to an object instance of that class . . .

A method that operates on a class instance would be an instance method
of the class metaclass, wouldn't it?  But I think you meant on a
*particular* class [metaclass] instance, am I right?

   . . .

   How about writing the method without the :method modifier, but also 
   addmethod'ing it to the class? Then it will be found by find_method, but 
   won't think the first parameter is an invocant. Something here doesn't 
   feel quite right to me, though I'm tired and can't put my finger on what.

   Jonathan

But in order to be able to use class attributes, you would want the
invocant to be the class metaclass instance, wouldn't you?

   If so, then I think this should be handled by a mechanism for
defining a method on a particular object, which is useful for more than
just metaclasses.  I know of only two ways to define a method particular
to an instance X (though this may say something about my lack of breadth
in the language department):

   1.  In Ruby, the class of X is transparently subclassed into a
virtual class that becomes the class of X only, and the method is
defined (and dispatched) normally on the virtual class.

   2.  In Common Lisp, on can define a method for the object X, and this
is handled by the dispatch machinery.

   Since the consequences of these strategies are visible to the
programmer (foo.class in Ruby returns something different after
def foo.meth . . ., but the class remains unchanged in Lisp), it seems
like our hands are tied; both must be implemented in order to support
both languages.  But it's not clear to me that either needs to be in the
core, nor which one would make the better default.

   Does anyone know of other strategies?  For other languages with
metaobjects (and, again, I confess I am not familiar with any), how do
they do it?

-- Bob Rogers
   http://rgrjr.dyndns.org/


Re: Referring to source code within Perldoc: the new A code

2007-06-20 Thread Damian Conway

Mark Overmeer wrote:


This is exactly the form of documentation you do *not* want the
user to write, for various reasons:


Well, I agree it is the form that you (singular, specific) do not want; but 
I'm not sure it's bad for you (plural, generic) to write in all cases. ;-)




  * The explicit naming of the class name in method and attribute
descriptions is in general a bad idea: by inheritance, you get
sub-classes which also provide this method.  In the people's
mind (I mean normal people, not our perl guru), this
requires continuous translations which distracts from the message.


A dedicated OO documentation tool could certainly do a better job in that 
case, I heartily agree. I'm looking forward to using one.




  * How do you see this syntactically work in combination with the
item list? At least the POD(5) needed that.  I need a combined
example.


I'm not sure I understand what you're asking here. Can you describe the 
example you'd like to see?




  * Having aliases is pratical, for referencing.  However, in this
latter example it is used to help the programmer to shoot himself
in the foot.  If you allow people to say class each time they
mean role, or function where it is method, then on the long
run people will start making avoidable programming mistakes.

In the chosen approach, this abuse cannot be avoidable. But it
may be a wise not to promote it by using it as example.


A good point. I will remove the example.



  * Using ambient back-references this way probably requires a
two-pass document generator. AFAIK this is not required for the
design of POD6 so far.


Actually a two-pass generator is already required for Pod. A second pass is 
always necessary whenever there are any forward-targetted L#local link 
formatting codes in a document.




  * the A(..) syntax is nice, but has a few dangers.  Serious
problems.  Your examples are a bit brief.  A little larger:

 method eat(Food $meal) {...}

   =for DESCRIPTION
   The Amethod() method has the following argument list: A(..)

Now the method gets implemented:

 method eat(Food $meal) {
if($manger.isFull) { $manger.clean }
 }

   =for DESCRIPTION
   The Amethod() method has the following argument list: A(..)

Oops... now the argument list became (without warning)
$manger.isFull   So, either you impose a strict doc order, forcing
people into your style, or people have to use an alias everywhere,
bulking the file. More subtle examples of this problem can be
created, for instance when the method defines a return type


Sure. But this is true of any scheme that doesn't do full parsing of the 
ambient source code. Which Pod isn't going to do (but which, of course, you 
may well choose to do in another documentation mark-up layer built on top of Pod).




  * In the manual-page of my sub-class, I want to refer to the
documentation of specific attributes and methods.  How?
Can I also refer to elements in distributions which are not
mine, so where I cannot add X or such?  For instance,
when I inherit from a core Perl class?


This is not possible, using this mechanism, due to the lexical scoping of the 
aliases. An automatic documentation-generator tool (that produces Pod) is more 
appropriate for this task.




  * In my sub-class, I want to enlist automatically the methods
and attributes which are inherited.  Automatically of course,
because I want to avoid mistakes.  In case of multi-level
inheritance, some way I need to know and show where each is
defined. How?


An automatic documentation-generator tool is more appropriate for this task too.



For instance, if your look at IO::File in Perl5, it defines
some own method, but then simply says: see also IO::Handle
and IO::Seekable.  IO::Handle says: see also perlfunc and
perlvar.  The more extended your OO model is, (Perl6's
structure is probably much more extended), the more levels
of hierarchy you get.  Are users able to understand this?
Are developers able to maintain manual interface description
lists without mistakes?
Is the shown syntax sufficient for tools to create it
automatically?  As decided, of course without looking at
the perl code itself.


Of course not. Pod is static explicit documentation mark-up. That mark-up may 
be generated by humans or by clever documentation-from-code tools. Those 
clever tools are what you're looking for, and what I'm sure you will easily be 
able to create, using the Pod 6 and Perl 6 parsers as foundations, and perhaps 
the Pod syntax as a output format (targetting the wealth of Pod-to-Whatever 
translators we will provide).




Your design goal of A is to avoid replication of code information,
in which you succeeded.  Now your write

 method eat(Food $meal) {...}

 =for DESCRIPTION
 The Amethod() method has the following 

[svn:parrot-pdd] r19204 - trunk/docs/pdds

2007-06-20 Thread rgrjr
Author: rgrjr
Date: Wed Jun 20 19:02:42 2007
New Revision: 19204

Modified:
   trunk/docs/pdds/pdd15_objects.pod

Log:
* docs/pdds/pdd15_objects.pod:
   + Fix typo, canonicalize meta-classes.


Modified: trunk/docs/pdds/pdd15_objects.pod
==
--- trunk/docs/pdds/pdd15_objects.pod   (original)
+++ trunk/docs/pdds/pdd15_objects.pod   Wed Jun 20 19:02:42 2007
@@ -1195,7 +1195,8 @@
 
 =head2 Meta-classes
 
-Ruby: Ruby has meta classes.  It would be nice if classes were objects in 
Parrots OO model.
+Ruby: Ruby has meta-classes.  It would be nice if classes were objects in
+Parrot's OO model.
 
 =head2 Attributes
 


Re: pdd15 - How do I add a class method?

2007-06-20 Thread Patrick R. Michaud
On Wed, Jun 20, 2007 at 09:41:00PM -0400, Bob Rogers wrote:
From: Jonathan Worthington [EMAIL PROTECTED]
Date: Thu, 21 Jun 2007 00:05:00 +0100
 
Hi,
 
Patrick R. Michaud wrote:
 My first question is How do I add a class method? -- i.e.,
 a method that operates on a class instance as opposed
 to an object instance of that class . . .
 
 A method that operates on a class instance would be an instance method
 of the class metaclass, wouldn't it?  But I think you meant on a
 *particular* class [metaclass] instance, am I right?

Yes, I believe this is a better phrasing.  If I want to define a
new method or or override an existing method on a metaclass instance
[a class], then how do I do that?

The particular instance I'm looking at is a CStr class for
Perl 6, where I want the get_string vtable function for the
CStr metaclass instance is different from get_string of 
a CStr class object.

At the moment perl6 is handling this (in PMC classes) by 
checking the identify of the invocant when get_string is 
executed and then responding appropriately.  But I'm thinking
it's likely that CStr will be implemented using pdd15
objects, so I'm looking for the preferred approach 
for doing things like this.

Thanks,

Pm


Re: pdd15 - How do I add a class method?

2007-06-20 Thread Bob Rogers
   From: Patrick R. Michaud [EMAIL PROTECTED]
   Date: Wed, 20 Jun 2007 21:02:54 -0500

   On Wed, Jun 20, 2007 at 09:41:00PM -0400, Bob Rogers wrote:
   From: Jonathan Worthington [EMAIL PROTECTED]
   Date: Thu, 21 Jun 2007 00:05:00 +0100

   Hi,

   Patrick R. Michaud wrote:
My first question is How do I add a class method? -- i.e.,
a method that operates on a class instance as opposed
to an object instance of that class . . .

A method that operates on a class instance would be an instance method
of the class metaclass, wouldn't it?  But I think you meant on a
*particular* class [metaclass] instance, am I right?

   Yes, I believe this is a better phrasing.  If I want to define a
   new method or or override an existing method on a metaclass instance
   [a class], then how do I do that?

AFAICS, there isn't currently a good way to do that.  (Depending, of
course, on whether you think Jonathan's suggestion qualifies.  ;-)
Nor does PDD15 seem to cover this; it actually says very little about
metaclasses, beyond just the fact that they exist (and even then only
mentions class metaclasses).

   The particular instance I'm looking at is a CStr class for
   Perl 6, where I want the get_string vtable function for the
   CStr metaclass instance is different from get_string of 
   a CStr class object.

To me, the phrases CStr metaclass instance and CStr class object
sound like the same thing.  Did you mean CStr object in the second
case?  If so, then get_string on the class metaclass would just affect
the way the class stringifies, and not any of the instances, but I don't
get the point of that.  So I'm sure I must be misunderstanding you.  Do
you have an example?  Maybe the perl6 code you mention?

-- Bob


Re: [svn:parrot-pdd] r19204 - trunk/docs/pdds

2007-06-20 Thread chromatic
On Wednesday 20 June 2007 19:02:43 [EMAIL PROTECTED] wrote:

 Modified:
trunk/docs/pdds/pdd15_objects.pod

 -Ruby: Ruby has meta classes.  It would be nice if classes were objects in
 Parrots OO model. +Ruby: Ruby has meta-classes.  It would be nice if
 classes were objects in +Parrot's OO model.

Classes are PMCs.  Are there benefits to pushing them one step further and 
making them Objects as well?

-- c


Re: pdd15 - How do I add a class method?

2007-06-20 Thread Patrick R. Michaud
On Wed, Jun 20, 2007 at 10:38:08PM -0400, Bob Rogers wrote:
From: Patrick R. Michaud [EMAIL PROTECTED]
On Wed, Jun 20, 2007 at 09:41:00PM -0400, Bob Rogers wrote:
Patrick R. Michaud wrote:
 My first question is How do I add a class method? -- i.e.,
 a method that operates on a class instance as opposed
 to an object instance of that class . . .
 
 A method that operates on a class instance would be an instance method
 of the class metaclass, wouldn't it?  But I think you meant on a
 *particular* class [metaclass] instance, am I right?
 
Yes, I believe this is a better phrasing.  If I want to define a
new method or or override an existing method on a metaclass instance
[a class], then how do I do that?
 
 AFAICS, there isn't currently a good way to do that.  (Depending, of
 course, on whether you think Jonathan's suggestion qualifies.  ;-)
 Nor does PDD15 seem to cover this; it actually says very little about
 metaclasses, beyond just the fact that they exist (and even then only
 mentions class metaclasses).

To somewhat see where I came from in this, pdd15 has a =head3
section titled Class Methods, where all of the methods appear to
be operations on classes, as opposed to instances of the
class.  There's also a line in pdd15 that reads:

=item - Classes are instances of a meta-class and have their 
own sets of class methods and class attributes

So, I was wondering how one would create a class method.

The particular instance I'm looking at is a CStr class for
Perl 6, where I want the get_string vtable function for the
CStr metaclass instance is different from get_string of 
a CStr class object.
 
 To me, the phrases CStr metaclass instance and CStr class object
 sound like the same thing.  Did you mean CStr object in the second
 case?  

I did.  Apologies for the ambiguity.

 If so, then get_string on the class metaclass would just affect
 the way the class stringifies, and not any of the instances, but I don't
 get the point of that.  So I'm sure I must be misunderstanding you.  Do
 you have an example?  Maybe the perl6 code you mention?

Well, after re-reading S12 this evening I've determined that
the perl6 example I was thinking of isn't precisely correct
for the current spec, and I think it's better not to confuse 
the issue (or myself) by trying to describe my incorrect example.
(Essentially, it had to do with the way the Str class stringifies 
as opposed to the way a Str object stringifies.)

But, I think I have another way to describe what I'm asking.  
In an earlier message [1] Allison wrote that the 'typeof' operator
will now return different values for class objects and instances of
the class.  For example:

$P0 = newclass Foo
$P1 = new $P0

$S0 = typeof $P0   # returns Class
$S1 = typeof $P1   # returns Foo

I was wanting to know how to do something similar, except with
get_string instead of typeof.  In particular, the example I've
been thinking of is:

$P0 = get_class Str  # get the Str class
$P1 = new $P0  # create a Str instance
assign $P1, XYZ  # give it a value

$S0 = $P0  # returns Str
$S1 = $P1  # returns XYZ

In short, I was wondering how I would get a class to stringify
to its name (or possibly some mocked value), while having 
the instances of that class continue to stringify to their values.  

As I mentioned above, my re-reading of S12 may make this
particular question moot, although it's important to note
that Jonathan apparently encountered something like it as
well.  :-)  At any rate, I hope the example here hopes to
clear up what I was looking for.

And thanks for being so patient as I try to get an accurate
description together.  :-)

Pm

[1] http://www.nntp.perl.org/group/perl.perl6.internals/2007/06/msg38608.html