Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oleg Trott <oleg_trott@columbia.edu>
To: Basile STARYNKEVITCH <basile@starynkevitch.net>,
	Ed L Cashin <ecashin@uga.edu>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] my first questions about camlp4
Date: Thu, 22 May 2003 15:48:19 -0400	[thread overview]
Message-ID: <200305221548.19503.oleg_trott@columbia.edu> (raw)
In-Reply-To: <16077.1526.521835.393248@hector.lesours>

On Thursday 22 May 2003 01:16 pm, Basile STARYNKEVITCH wrote:
> >>>>> "Ed" == Ed L Cashin <ecashin@uga.edu> writes:
>
>     Ed> "Dont Bother" <dont_bother@whoever.com> writes:
>     >> 1. It's been said that Camlp4 is not as easy to use as Lisp
>     >> macros, but is it as powerful? Is there anything that can be
>     >> done with Lisp macros that can not be done using Camlp4 in the
>     >> context of their respective languages?
>
>     Ed> You might get a better answer to that question on
>     Ed> comp.lang.lisp. [...]
>
>
> I do know a tiny bit CL, and I do practice Ocaml with Camlp4. It seems
> to me that CommonLisp macros can -for example- interact with CL object
> system, while Camlp4 is purely syntactic (in that sense, it is more
> like Scheme macros). For example, I tend to believe that you can make
> a commonlisp macro which, given a class name C, extract all the fields
> F of this class C such that F name ends with a suffix S and generate a
> printing routine which prints only those fields. I think that this is
> not possible in Camlp4 (unless you redefine in Camlp4 the syntax
> defining Ocaml classes).

I think Lisp is too huge for anyone to make statements as to what's NOT in it 
with certainty, but I suspect that to do what you are describing, one would 
need a non-standard function like CLASS-SLOTS. In any event, whether this is 
the case is incidental. More interestingly, if you were to have to augment 
DEFCLASS with this functionality, would it be easier than redefining OCaml 
class syntax in Camlp4? The former is fairly easy, because you know exactly 
where to find field names within DEFCLASS form :

      - take the fourth element of the form, which has to be a list;
      - for each of its elements, do:
             - if the element is a list, its head is one of the field names
             - otherwise, it's a field name itself

I imagine this would probably be harder to do with OCaml & Camlp4 (Unless, 
perhaps, you happen to be the author of "camlp4/meta/pa_o.ml" )

> In a more general way, I do think that Ocaml still lacks some
> reflective abilities (which could help for other things,
> e.g. persistency).

It does seem like integrating Camlp4 into the compiler could offer interesting 
possibilities. 

> Also, macros are an essential part of CommonLisp; for example, they
> are repeatedly used for CommonLisp advocacy,

:-)


-- 
Oleg Trott <oleg_trott@columbia.edu>

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2003-05-22 19:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-22  2:51 Dont Bother
2003-05-22 16:00 ` Ed L Cashin
2003-05-22 17:16   ` Basile STARYNKEVITCH
2003-05-22 19:48     ` Oleg Trott [this message]
2003-05-22 19:50     ` [Caml-list] Camlp4 and hashtable Lukasz Lew

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200305221548.19503.oleg_trott@columbia.edu \
    --to=oleg_trott@columbia.edu \
    --cc=basile@starynkevitch.net \
    --cc=caml-list@inria.fr \
    --cc=ecashin@uga.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox