These could use some documenting (and yes, I know the answer to many) for future use for folks generating PIR. (Hint, hint -- documentation is a good thing)
*) How do I declare an externally visible subroutine?
*) How do I store a global variable
*) How do I load a global variable
*) How do I call an external function
*) How do I get the sub pmc for a sub declared later (or earlier) in the file?
*) How do I (or even can I) have a file-scoped variable? (like .local, only for all code in the file)
Dan
--------------------------------------"it's like this"------------------- Dan Sugalski even samurai d...@sidhe.org have teddy bears and even teddy bears get drunk
Dan Sugalski wrote: > These could use some documenting (and yes, I know the answer to many) for > future use for folks generating PIR. (Hint, hint -- documentation is a > good thing)
> *) How do I declare an externally visible subroutine?
> *) How do I store a global variable
> *) How do I load a global variable
> *) How do I call an external function
> *) How do I get the sub pmc for a sub declared later (or earlier) in the > file?
> *) How do I (or even can I) have a file-scoped variable? (like .local, > only for all code in the file)
*) How do I do the following in PIR:
package Foo::Bar;
my $joe = 42;
sub new { bless {};
}
sub prnJoe { my $self = shift; print $self->jo;
}
package main;
$f = Foo::Bar->new(); $f->prnJoe();
Would also be *really* great (I'm trying to implement the IMC codegen in PHP for classes and objects right now :)
>These could use some documenting (and yes, I know the answer to many) for >future use for folks generating PIR. (Hint, hint -- documentation is a >good thing)
I will make an attempt at answering all of these regarding how it is today, as opposed to how it should/will be very soon; --- later tonight, that is, when I get back from playing golf =:)
On Sat, 2003-11-22 at 04:36, Sterling Hughes wrote: > Dan Sugalski wrote: > > These could use some documenting (and yes, I know the answer to many) for > > future use for folks generating PIR. (Hint, hint -- documentation is a > > good thing)
> > *) How do I declare an externally visible subroutine?
> > *) How do I store a global variable
> > *) How do I load a global variable
> > *) How do I call an external function
> > *) How do I get the sub pmc for a sub declared later (or earlier) in the > > file?
> > *) How do I (or even can I) have a file-scoped variable? (like .local, > > only for all code in the file)
> *) How do I do the following in PIR:
> package Foo::Bar;
> my $joe = 42;
> sub new { > bless {}; > }
> sub prnJoe { > my $self = shift; > print $self->jo; > }
> package main;
> $f = Foo::Bar->new(); > $f->prnJoe();
> Would also be *really* great (I'm trying to implement the IMC codegen in > PHP for classes and objects right now :)
>These could use some documenting (and yes, I know the answer to many) for >future use for folks generating PIR. (Hint, hint -- documentation is a >good thing)
>*) How do I declare an externally visible subroutine?
>*) How do I store a global variable
>*) How do I load a global variable
>*) How do I call an external function
>*) How do I get the sub pmc for a sub declared later (or earlier) in the >file?
>*) How do I (or even can I) have a file-scoped variable? (like .local, >only for all code in the file)
I just checked in an intial IMCC faq (parrot/imcc/docs/imcfaq.pod)
Hopefully we'll get it linked up in HTML format to the web site asap.
The FAQ is small, but it at least answers all of the above.
I did not go in too much depth about subs because I've got a wave of changes to commit soon, so I want to hold off on documenting syntax that is about to be deprecated.
Melvin Smith wrote: > I just checked in an intial IMCC faq (parrot/imcc/docs/imcfaq.pod)
Great job. Attached you'll find some corrections for typos.
> The FAQ is small, but it at least answers all of the above.
As I see it, the faq will grow fast... Maybe we'll have to split it in different parts (generalities, subs / calling conventions, variable declaration / access, etc.). But maybe later.
> Feel free to send me more questions for the FAQ.
Ok, here are some more (some questions are easy - but a faq should also have some easy items -, others are not yet possible, but anyway):
* How does one retrieve arguments given on the command-line? * How does one call a function? With arguments? With a variable number of arguments? Get the return value(s) of a sub? * How does one read from a file? stdin? unbuffered stdin? * How does one create socket and network stuff? * How does one launch an exception? trap an exception? * How does one create a class? instanciate an object?
Jerome Quelin wrote: > Melvin Smith wrote: > > I just checked in an intial IMCC faq (parrot/imcc/docs/imcfaq.pod) > Great job. Attached you'll find some corrections for typos.
And of course I forgot the patch file. Here it is.
At 06:48 PM 11/24/2003 +0100, Jerome Quelin wrote:
>Melvin Smith wrote: > > I just checked in an intial IMCC faq (parrot/imcc/docs/imcfaq.pod)
>Great job. Attached you'll find some corrections for typos.
Thanks. BTW Robert has linked the HTML FAQ to the site. You can get to it from the Resources tab, or just go straight to http://www.parrotcode.org/faq/imcc
I much prefer reading it in a browser.
> > Feel free to send me more questions for the FAQ.
>Ok, here are some more (some questions are easy - but a faq should also >have some easy items -, others are not yet possible, but anyway):
>* How does one retrieve arguments given on the command-line? >* How does one call a function? With arguments? With a variable number >of arguments? Get the return value(s) of a sub? >* How does one read from a file? stdin? unbuffered stdin? >* How does one create socket and network stuff? >* How does one launch an exception? trap an exception? >* How does one create a class? instanciate an object?
I'll get to work on these. Look for something tonight or tomorrow. Some of this refreshes my memory on things I need to implement.
On Mon, 24 Nov 2003, Jerome Quelin wrote: > Ok, here are some more (some questions are easy - but a faq should also > have some easy items -, others are not yet possible, but anyway):
> * How does one retrieve arguments given on the command-line? > * How does one call a function? With arguments? With a variable number > of arguments? Get the return value(s) of a sub? > * How does one read from a file? stdin? unbuffered stdin? > * How does one create socket and network stuff? > * How does one launch an exception? trap an exception? > * How does one create a class? instanciate an object?
With the exception of the second bullet item, these are generic parrot FAQs rather than IMCC/PIR specific ones, so ought to be put in a different FAQ or doc section...
Dan
--------------------------------------"it's like this"------------------- Dan Sugalski even samurai d...@sidhe.org have teddy bears and even teddy bears get drunk
Dan Sugalski wrote: > On Mon, 24 Nov 2003, Jerome Quelin wrote: > > * How does one retrieve arguments given on the command-line? > > * How does one call a function? With arguments? With a variable > > number of arguments? Get the return value(s) of a sub? > > * How does one read from a file? stdin? unbuffered stdin? > > * How does one create socket and network stuff? > > * How does one launch an exception? trap an exception? > > * How does one create a class? instanciate an object?
> With the exception of the second bullet item, these are generic > parrot FAQs rather than IMCC/PIR specific ones, so ought to be put in > a different FAQ or doc section...
Correct, but then someone new to parrot who wants to write a compiler targetting parrot will need to look for and read faqs in a lot of different places...
I think the real question is: do we want to promote imcc as _the_ target language for compilers targetting parrot? If the answer is yes (as I thought it was), then I don't think we need a pasm faq...
At 07:18 PM 11/24/2003 +0100, Jerome Quelin wrote:
>Dan Sugalski wrote: > > On Mon, 24 Nov 2003, Jerome Quelin wrote: > > > * How does one launch an exception? trap an exception? > > > * How does one create a class? instanciate an object?
> > With the exception of the second bullet item, these are generic > > parrot FAQs rather than IMCC/PIR specific ones, so ought to be put in > > a different FAQ or doc section...
The last 2 bullet items will also be specific to IMCC. The syntax for defining a class will trigger IMCC to construct and freeze the class with the bytecode at compile time which means it wont generate any Parrot instructions. That is how it currently does constant subs. Also, exceptions in IMCC will certainly be a briefer syntax, maybe even try/catch.
>I think the real question is: do we want to promote imcc as _the_ target >language for compilers targetting parrot?
The answer is yes.
>If the answer is yes (as I thought it was), then I don't think we need a >pasm faq...
We still need one but I do not want to maintain it, myself. Simon Cozens already wrote some stuff that could be used as a start. Of course there is also Perl6 Essentials. :)
We DO need a Parrot Programming FAQ. I propose the IMCC faq functions as just that. We can still have the current Parrot FAQ, which is great at answering generic questions for people who haven't swallowed the blue pill yet. (Or was it the red pill, I vaguely remember Dan in a black trenchcoat and glasses, and guns.....)
At 06:49 PM 11/24/2003 +0100, Jerome Quelin wrote:
>Jerome Quelin wrote: > > Melvin Smith wrote: > > > I just checked in an intial IMCC faq (parrot/imcc/docs/imcfaq.pod) > > Great job. Attached you'll find some corrections for typos.
>And of course I forgot the patch file. Here it is.
Thanks, applied!
Also I added another sample that might interest compiler writers that may be new to Parrot/IMCC syntax. It just shows one approach to compiling a class with fields, methods and instantiating them.
The syntax is a workaround for the lack of explicit class/object support in Parrot.
On Mon, 24 Nov 2003, Melvin Smith wrote: > We DO need a Parrot Programming FAQ. I propose the IMCC faq functions > as just that. We can still have the current Parrot FAQ, which is > great at answering generic questions for people who haven't swallowed > the blue pill yet. (Or was it the red pill, I vaguely remember Dan in a black > trenchcoat and glasses, and guns.....)
I think separating the IMCC and parrot programming FAQs, or making the IMCC faq a section of a larger Parrot FAQ, would be better. The IMCC FAQ really ought to be about syntax rather than semantics.
Dan
--------------------------------------"it's like this"------------------- Dan Sugalski even samurai d...@sidhe.org have teddy bears and even teddy bears get drunk
> I think separating the IMCC and parrot programming FAQs, or making the > IMCC faq a section of a larger Parrot FAQ, would be better. The IMCC FAQ > really ought to be about syntax rather than semantics.
<mrjoltc...@mindspring.com> wrote: >At 12:02 PM 11/27/2003 +0000, Pete Lomax wrote: >>Perl6 already does interpolation without special support from IMCC.
>>That's nice for it. Where do I go crib from?
>?
>-Melvin
I'll rephrase. Is there anything knocking about which would help with eg: printf (pFile, "Amount %12.3f [%-10.10s]\n",balance,name);
Or do I have to rip the string apart character-by-character, then throw all my variables about in registers, cutting, chopping and padding them into shape, and then dumping them in iddy little bits?
>On Thu, 27 Nov 2003 09:52:10 -0500, Melvin Smith ><mrjoltc...@mindspring.com> wrote:
>>At 12:02 PM 11/27/2003 +0000, Pete Lomax wrote: >>>Perl6 already does interpolation without special support from IMCC.
>>>That's nice for it. Where do I go crib from?
>>?
>>-Melvin
>I'll rephrase. Is there anything knocking about which would help with >eg: >printf (pFile, "Amount %12.3f [%-10.10s]\n",balance,name);
>Or do I have to rip the string apart character-by-character, then >throw all my variables about in registers, cutting, chopping and >padding them into shape, and then dumping them in iddy little bits?
Depends entirely on two things:
1) Whether we want printf-style functionality as part of the core 2) Whether you want to use it
I think the answer to #1 is a big yes. You can answer #2 as you need. :) -- Dan
--------------------------------------"it's like this"------------------- Dan Sugalski even samurai d...@sidhe.org have teddy bears and even teddy bears get drunk
>At 5:38 PM +0000 11/27/03, Pete Lomax wrote: >>On Thu, 27 Nov 2003 09:52:10 -0500, Melvin Smith >><mrjoltc...@mindspring.com> wrote:
>>>At 12:02 PM 11/27/2003 +0000, Pete Lomax wrote: >>>>Perl6 already does interpolation without special support from IMCC. >>I'll rephrase. Is there anything knocking about which would help with >>eg: >>printf (pFile, "Amount %12.3f [%-10.10s]\n",balance,name);
>>Or do I have to rip the string apart character-by-character, then >>throw all my variables about in registers, cutting, chopping and >>padding them into shape, and then dumping them in iddy little bits?
>Depends entirely on two things:
>1) Whether we want printf-style functionality as part of the core >2) Whether you want to use it
>I think the answer to #1 is a big yes. You can answer #2 as you need. :)
To me, variable interpolation means high-level language interpolation using the high-level symbol name. printf isn't the same. I'd call it "format interpolation", if that makes sense.
1) interpolation by the symbol name we don't need at the Parrot/IMC level, and this was what the FAQ addressed. I could be wrong, though.
2) printf/sprintf - we do need it (and implemented in C) since it is a staple and is the reasonable hook for HLL implementors to do interpolation without having to write a special native method or PMC for each language.
>2) printf/sprintf - we do need it (and implemented in C) since it is >a staple and is the >reasonable hook for HLL implementors to do interpolation without having >to write a special native method or PMC for each language.
Okay, once I get the object stuff finished I think this is the next thing to tackle. The one question is whether we should make the lead-in character for sequences settable at runtime, as not all languages will want to use % for interpolation. (I am, however, perfectly fine with choosing something otherwise unused and forcing languages to translate from their exposed form to our internal form) -- Dan
--------------------------------------"it's like this"------------------- Dan Sugalski even samurai d...@sidhe.org have teddy bears and even teddy bears get drunk
<mrjoltc...@mindspring.com> wrote: >2) printf/sprintf - we do need it (and implemented in C) since it is a >staple and is the >reasonable hook for HLL implementors to do interpolation without having >to write a special native method or PMC for each language.