caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: caml-list@inria.fr (OCAML)
Subject: ocamlyacc and polymorphic variants
Date: Sat, 8 Jan 2000 19:14:28 +0100 (MET)	[thread overview]
Message-ID: <200001081814.TAA30033@miss.wu-wien.ac.at> (raw)

Hello,

I have just tried in how far it is possible to use ocamlyacc together with
polymorphic variants. As it seems, this is a somewhat dangerous
combination, because ocamlyacc-generated code requires Obj.magic internally
to cast values to the appropriate type.

I am not sure in which order the data constructors are generated, i.e. what
internal representation the polymorphic variants get. I thought that they
would be generated in order of appearance, but when I implemented the
parser, the code behaved more than strangely, namely differently for byte-
and native code. This is an indication that the returned values do not
fully correspond to the type they are supposed to be of, possibly because
the internal tags of the data constructors are not in the right order.

The result type enumerated the data constructors exactly in the same order
as they appeared in the parser specification, but this does not seem to
work.

Is it possible at all to return polymorphic variants from the parser?  If
yes, how do I have to specify the return type?

A workaround would be to not use polymorphic variants in the parser and to
use a conversion function outside to convert the "normal" into polymorphic
ones.

Regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl




             reply	other threads:[~2000-01-08 18:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-08 18:14 Markus Mottl [this message]
2000-01-11 10:03 ` Jacques Garrigue
2000-01-11 15:59   ` Markus Mottl
     [not found] <200001110852.JAA16936@ithif20.inf.tu-dresden.de>
2000-01-11 17:23 ` Markus Mottl

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=200001081814.TAA30033@miss.wu-wien.ac.at \
    --to=mottl@miss.wu-wien.ac.at \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).