From: Raffael Cavallaro on
On 2010-03-16 11:38:45 -0400, Tamas K Papp said:

> I don't think that there are existing libraries for this, since the
> intersection of Pascal and Lisp programmers should be very, very
> small.

In general I would agree. However, the OP might consider asking on the
the openmcl-devel mailing list. openmcl/Clozure CL began life as Coral
Common Lisp on the Mac in the days when Pascal was Apple's official
language for Mac development (i.e., the mid-late '80s). It's a bit of a
long shot, but it's conceivable that one of the Clozure pricipals might
have some old code that translates/compiles form s-expressions to
pascal...

warmest regards,

Ralph


--
Raffael Cavallaro

From: Pillsy on
On Mar 16, 11:17 am, dc <creelman.da...(a)gmail.com> wrote:
[...]
> I'm hoping there's something like Parenscript for Pascal. My hope is
> to be able to write and test routines in CL and (so long as I'm not
> relying on too many CL features) create Pascal code from CL code.

You might want to look at the first section of "Some Useful Lisp
Algorithms: Part 2"[1], which contains an extended example on how to
use CL's built-in pretty printer to convert a subset of Lisp to a
subset of Pascal.

> My motivation for doing this is that in the code I'm dealing with
> there are numerous boilerplate code sections that need to be written
> for the architecture I'm using (not my choice) and I wondered how
> useful it would be to generate some of it from CL, rather than type it
> in myself.

This is not such a bad idea at all, and I have a feeling that the
referenced paper above is a bit closer to what you might be looking
for than something like the Scheme -> C compiler in /LiSP/ or the CL -
> C compiler provided by ECL. In both cases, they're making C do the
backflips necessary to implement things like closures. It sounds like
that would be a lot of work that wouldn't get you any closer to your
goal, and would possibly even be counterproductive, since the code
emitted by those compiilers is not super-easy to read.

Cheers,
Pillsy

[1] http://www.merl.com/reports/docs/TR93-17.pdf
From: Thomas A. Russ on
dc <creelman.david(a)gmail.com> writes:

> Hi,
> Does anyone know of a reasonable version of a CL lib that will create
> (relatively) standard pascal code?

Well, I certainly don't know of any Pascal code generator. But we have
developed Stella, a restricted, lisp-like language that we translate
into Common Lisp, Java and C++. With a bit of work, someone could
extend the translator to translate a subset of Stella into Pascal.

Stella requires an object model, so there are things you would not be
able to translate, but it would work for functions and procedures. One
could just start with the Java or C++ translator (which are similar to
one another) and just change that. It wouldn't be a trivial task, but
it might be simpler than building the entire infrastructure yourself.

<http://www.isi.edu/isd/LOOM/Stella/>

Here's a quick sample with the C++ translator:


(cpptrans
(defun (add float) ((x float) (y float))
(return (+ x y))))

==>

double add(double x, double y) {
return (x + y);
}



--
Thomas A. Russ, USC/Information Sciences Institute
From: vanekl on
Thomas A. Russ wrote:
> Here's a quick sample with the C++ translator:
>
>
> (cpptrans
> (defun (add float) ((x float) (y float))
> (return (+ x y))))
>
> ==>
>
> double add(double x, double y) {
> return (x + y);
> }

Transitive property FTW.

==> <C to Pascal converter program>


CL => C => Pascal


From: dc on
On Mar 17, 6:07 am, "vanekl" <va...(a)acd.net> wrote:
> Thomas A. Russ wrote:
> > Here's a quick sample with the C++ translator:
>
> > (cpptrans
> >  (defun (add float) ((x float) (y float))
> >     (return (+ x y))))
>
> > ==>
>
> > double add(double x, double y) {
> >  return (x + y);
> > }
>
> Transitive property FTW.
>
> ==> <C to Pascal converter program>
>
> CL => C => Pascal

Hmm, that would work, but it feels a little clumsy. C and Pascal are
quite close, but I don't know.


Thanks to everyone else who passed on information. The pretty printer
translator is quite amazing. I'll have a look at Stella too.

Cheers
DC