PERL PERL6 INTERNALS 18 PERL 34258 TODO HERE DOCUMENTS FOR PIR
Date: Thu, 24 Feb 2005 13:53:08 -0800

Subject: [perl #34258] [TODO] Here documents for PIR
From: parrotbug-followup@no-spam (Bernhard Schmalhofer)

# New Ticket Created by Bernhard Schmalhofer # Please include the string: [perl #34258]
# in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34258 >

Hi,

in the near, or far, future there will be test scripts and compiler input in PIR.
For that it would be nice, if long text doesn't have to be crammed into a single line.

So some kind of HERE document syntax is needed for PIR. Suggestions for syntax elements are welcome. '<<' is already taken for the left shift operator.

CU, Bernhard
-- /* Bernhard.Schmalhofer@no-spam */

DSL Komplett von GMX +++ Superg�nstig und stressfrei einsteigen!
AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl

Date: Thu, 24 Feb 2005 22:53:29 -0500

Subject: Re: [perl #34258] [TODO] Here documents for PIR
From: mrjoltcola@no-spam (MrJoltCola)
This should actually be titled "Where are all the compilers?"
-----
I haven't ranted in a couple of years, so I'm due. Ranting is nothing more than broadcasting my emotions from a soapbox but it is so fun, I love to do it.

Let me respectfully give my opinion. In no way am I criticizing your suggestion of here documents, nor am I ranting at the originator of the suggestion.

I feel that this feature is for higher level languages. I did not even want macros, but there was a lot of griping when I removed them, so I relented and Leo reversed the patch.

What really is the problem here is the lack of a decent alternative.

It is not PIR that is lacking features. PIR, by definition should lack features. It stands for "Pick-your-P-word Intermediate Representation."
What is missing is a good implementation language that compiles to PIR. PIR is for compilers, not people, and I don't want to see PIR turn into "PIRL".

What I always wanted to do was implement a C subset for Parrot, and write all "low-level" things in that language. C is very good for close translation to underlying "hardware" and it doesn't take a full-time=
think-tank to implement a compiler for it. I'd like to see thin drivers written for things (ala JDBC Thin SQL drivers), with VERY limited use of native interfaces. I actually have a pretty nice compiler sitting in my archives,
but got too busy with life to finish it. The little "Cola" language that is=
=20
in languages right now is a hack job that was a quick prototype to see if people would actually write C like code for Parrot. Cola got very little interest, so I=
=20
shelved my work on it and IMCC2.

Years after I dumped much work into Parrot, I've seen no progress or support from other language camps (Python, Scheme) and Perl 6 seems to be such a daunting goal to implement, I'm afraid we won't a full, commercial-free=20
implementation for years. (I've written a couple of fully featured compilers in a matter=20
of weeks, and I won't even begin to tackle Perl6 unless someone offered to fund me=
full-time).
Heck, what happened to the Pony project? Is there anybody out there? Or did=
we all find that we were happier with Perl 5 than we realized. Or were we so=20
slow with Perl 6
that everyone had time to swallow the .NET pill?

I feel better now,

-Melvin
At 04:53 PM 2/24/2005, via RT wrote:
># New Ticket Created by Bernhard Schmalhofer ># Please include the string: [perl #34258]
># in the subject line of all future correspondence about this issue.
># <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=3D34258 >
>
>
>Hi,
>
>in the near, or far, future there will be test scripts and compiler input=
in >PIR.
>For that it would be nice, if long text doesn't have to be crammed into a >single line.
>
>So some kind of HERE document syntax is needed for PIR. Suggestions for >syntax elements >are welcome. '<<' is already taken for the left shift operator.
>
>CU, Bernhard >
>
>--
>/* Bernhard.Schmalhofer@no-spam */
>
>DSL Komplett von GMX +++ Superg=EF=BF=BDnstig und stressfrei einsteigen!
>AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl

Subject: Re: [perl #34258] [TODO] Here documents for PIR
Date: Fri, 25 Feb 2005 09:03:29 +0100

From: lt@no-spam (Leopold Toetsch)
Bernhard Schmalhofer <parrotbug-followup@no-spam> wrote:

> Hi,

> in the near, or far, future there will be test scripts and compiler > input in PIR. For that it would be nice, if long text doesn't have to > be crammed into a single line.

> So some kind of HERE document syntax is needed for PIR. Suggestions > for syntax elements are welcome. '<<' is already taken for the left > shift operator.

Yeah. I came to the same conclusion, while hacking the Z translator.
While the syntax extension isn't really necessary, it can produce much more readable code.

WRT syntax:

$S0 = <<_EOT_
...
_EOT_

will work, because the token "<<_EOT_" is longer then the token "<<". The only thing that will stop working is:

.local int _EOT_
$I0 = $I1 <<_EOT_ # space needed then
Not much of a problem. We don't need and don't support nested HERE docs,
so one fix-defined "<<_EOT_" or some such will do it.

> CU, Bernhard
leo

Subject: Re: [perl #34258] [TODO] Here documents for PIR
Date: Fri, 25 Feb 2005 09:21:15 +0100

From: lt@no-spam (Leopold Toetsch)
MrJoltCola <mrjoltcola@no-spam> wrote:

> I feel that this feature is for higher level languages.

[ snip ]

> ... PIR is for compilers, not people,

PIR is foremost Parrot's primary assembly language. If it were for compiles only, it wouldn't have needed "a = b + c" in the first place,
the "add" opcode is doing the same.

PIR has nice constructs for function and method calls. I don't see any reason, why people shouldn't write PIR code directly. A HERE document syntax allows to write more readable code.

leo

Subject: Re: [perl #34258] [TODO] Here documents for PIR
Date: Fri, 25 Feb 2005 13:03:55 +0000

From: roger@no-spam (Roger Browne)
MrJoltCola wrote:
> This should actually be titled "Where are all the compilers?"

The compilers will come! Loads of people, myself included, are quietly working away on compilers that target IMC.

It takes time for people to discover and adopt new platforms -
especially when you are so modest about Parrot. The FAQ says:

"Parrot is in the early phases of its implementation. The primary way to use Parrot is to write Parrot assembly code"

when it could say something like:

"Although parrot is not yet complete, and indeed the design is still being refined, it already offers an elegant, powerful,
feature-rich, solidly-designed (though poorly documented)
environment that makes it amazingly easy to implement a wide range of scripting languages. The primary way to use parrot is to generate code for its intermediate language compiler (IMC) which handles all of the following things (and more) for you: numbers, bignums, objects, multiple inheritance,
closures, garbage collection, strings, polymorphic feature dispatch, regular expressions, exception handling, and more!"

> ... here documents ...

I don't care strongly either way about here-documents, and they're not going to make-or-break parrot. Lots of folks like to use here-documents,
and lots of folks get by just fine using languages that don't support anything like here-documents.

(Would I would like, though, is for the ".include" macro to find .../runtime/parrot/include like it says it does in the documentation :-)

But these things are mere details, minor bumps along the road.

> Years after I dumped much work into Parrot, I've seen no progress or support > from other language camps (Python, Scheme) and Perl 6 seems to be such a > daunting goal to implement, I'm afraid we won't a full, commercial-free > implementation for years...

It would be ironic indeed if the standard Perl 6 implementation ended up being written in Haskell! But Melvin's work on IMC is one of the core things that will ensure Parrot's success. Many people wouldn't want to manually generate code that satisfies the parrot assembly language calling conventions, but they can cope with generating $P1."foo"($P2).

> . Or were we so slow with Perl 6 that everyone had time to swallow the .NET pill?


Naaah! Parrot is the scripting platform for the next few decades, so it doesn't matter if it takes a few years for it to catch on.

Sorry that I can't help out more myself - I'm not fluent in either C or Perl (I'm getting pretty good at IMC though!). But I'll at least help out bringing the compilers that Melvin craves.

Regards,
Roger
-- Roger Browne <roger@no-spam>


Date: Fri, 25 Feb 2005 11:01:16 -0500

Subject: Re: [perl #34258] [TODO] Here documents for PIR
From: mrjoltcola@no-spam (MrJoltCola)
At 03:21 AM 2/25/2005, Leopold Toetsch wrote:
>MrJoltCola <mrjoltcola@no-spam> wrote:
>
> > I feel that this feature is for higher level languages.
>
>[ snip ]
>
> > ... PIR is for compilers, not people,
>
>PIR is foremost Parrot's primary assembly language. If it were for >compiles only, it wouldn't have needed "a = b + c" in the first place,
>the "add" opcode is doing the same.

It filled a need at the time I wrote it, because there was pretty much nothing else to write code in except PASM and Jako. It was supposed to be a thin layer (register allocation and instruction choosing and subs) over PASM.
Nowadays we have a hoard of little toy compilers.

>PIR has nice constructs for function and method calls. I don't see any >reason, why people shouldn't write PIR code directly. A HERE document >syntax allows to write more readable code.

...and adds another straw to the Camel's back of IMCC maintainability ...and encourages people to stay complacent and keep writing PIR code by hand,
which was the main point of my note.

-Melvin

Date: Fri, 25 Feb 2005 13:10:46 -0500

Subject: Re: [perl #34258] [TODO] Here documents for PIR
From: mrjoltcola@no-spam (MrJoltCola)
At 11:48 AM 2/25/2005, Bernhard Schmalhofer wrote:
>MrJoltCola wrote:
>>At 03:21 AM 2/25/2005, Leopold Toetsch wrote:
>>
>>>MrJoltCola <mrjoltcola@no-spam> wrote:
>>>
>>> > I feel that this feature is for higher level languages.
>>>
>>>[ snip ]
>>>
>>> > ... PIR is for compilers, not people,
>My impression was that the target for compilers should be a yet >non-existent abstract syntax tree. Though I'm somewhat confused about the >distinction between parse trees and AST.
>
>PIR and PAST could be considered as being just some languages. Why don't >they take the some route, and generate an AST that gets compiled into PBC?
>
>However most compilers I have seen so far are generating PIR and go from >there.

Text mode IR is easier to debug with the naked eye than an AST.
ASTs are great if you have supporting tools to browse the tree, dump things out and translate things back to IR. Virtually all compilers start with an IR and mature into AST usage, but many successful compilers are built with completely separate layers. See Muchnicks's work at Sun Microsystems. He has been the main influence on me as a compiler writer.

>>>PIR is foremost Parrot's primary assembly language. If it were for >>>compiles only, it wouldn't have needed "a = b + c" in the first place,
>>>the "add" opcode is doing the same.
>>
>>It filled a need at the time I wrote it, because there was pretty much >>nothing else to write code in except PASM and Jako. It was supposed >>to be a thin layer (register allocation and instruction choosing and >>subs) over PASM.
>
>It is certainly possible to write code in PIR. But it is even more certain >that this is no fun. Adding HERE documents remedies an immediate need, >especially for playing with compilers and test scripts.

I agree. Why not write a pre-processor that will handles things like this and then merge them forwards towards a front-end compiler rather than backwards into the mess of IMCC? Trust me, I know the IMCC code, and it is BAD BAD BAD. And I fully share the blame with Leo and Angel, bless their hearts. :)

> > Nowadays we have a hoard of little toy compilers.
>Which language of that hoard should be promoted to become THE standard >language for writing test scripts and the Parrot standard library?
>PIR is too hard on people, and a scripting language like Ruby, Perl or >Python is propably to hard on Parrot.
>It propably shouldn't a newly invented language either, because all >language designers are having fun with designing Perl6.

You echo my feelings, PIR is too hard on people, and I feel that Parrot's growth suffers for it, not because of PIR, but because that is all we use. I'm appalled that 3 years after I submitted IMCC to the project, everyone is still writing in PIR. Parrot need's its own version of "C" or "C#" to empower more people to contribute. If every new feature for Parrot is thought of in terms of PIR & IMCC, then IMCC will just become more of a tangled mess that nobody wants to touch, and high-level development will continue to drag as it has for years.

>How about ECMAScript? It has an specification, it has objects and no pointers.

No complaints from me, I don't vote much anyway, but I have strong feelings regarding this project.
The mixing of the VM team and the compiler team is a mistake. It is a problem for commercial development, much less open-source. One pumpking making decisions for such a wide scope doesn't leave much room for alternate points of view and unimpeded movement. This is why I urged Dan long ago to form a parrot-compilers list and split the project into separate decision making teams.

Speaking of Dan, where is he?

-Melvin

Subject: [perl #34258] [TODO] Here documents for PIR
Date: Wed, 28 Sep 2005 15:44:58 -0700

From: parrotbug-followup@no-spam (Will Coleda via RT)
Leo's proposed syntax is fine with me.

> [leo - Fri Feb 25 01:34:24 2005]:
> > Bernhard Schmalhofer <parrotbug-followup@no-spam> wrote:
> > > Hi,
> > > in the near, or far, future there will be test scripts and compiler > > input in PIR. For that it would be nice, if long text doesn't have to > > be crammed into a single line.
> > > So some kind of HERE document syntax is needed for PIR. Suggestions > > for syntax elements are welcome. '<<' is already taken for the left > > shift operator.
> > Yeah. I came to the same conclusion, while hacking the Z translator.
> While the syntax extension isn't really necessary, it can produce much > more readable code.
> > WRT syntax:
> > $S0 = <<_EOT_
> ...
> _EOT_
> > will work, because the token "<<_EOT_" is longer then the token "<<". The > only thing that will stop working is:
> > .local int _EOT_
> $I0 = $I1 <<_EOT_ # space needed then > > Not much of a problem. We don't need and don't support nested HERE docs,
> so one fix-defined "<<_EOT_" or some such will do it.
> > > CU, Bernhard > > leo > > >

Subject: [perl #34258] [TODO] Here documents for PIR
Date: Tue, 04 Oct 2005 15:03:04 -0700

From: parrotbug-followup@no-spam (Jonathan Worthington via RT)
Hi,

After a show of demand for here docs on IRC (and leo's approval), I've now modified to lexer to support them. The syntax for introducing a heredoc is <<"XXX", and it ends on the line containing (only) XXX. For example:-

$ cat example.pir .sub _main $S0 = <<"quotage"
Blah blah Oh happy days...
I love my pink highlighter pen...
quotage print $S0
.end $ parrot example.pir Blah blah Oh happy days...
I love my pink highlighter pen...
$
Have fun,

Jonathan

Subject: [perl #34258] [TODO] Here documents for PIR
Date: Fri, 07 Oct 2005 10:42:28 -0700

From: parrotbug-followup@no-spam (Bernhard Schmalhofer via RT)
> [jonathan - Di 04. Okt 2005, 15:03:03]:
> > After a show of demand for here docs on IRC (and leo's approval), I've > now modified to lexer to support them. The syntax for introducing a > heredoc is <<"XXX", and it ends on the line containing (only) XXX. For > example:-
>
Thanks a lot Jonathan. Here docs are alive and kicking.
The ticket is resolved.