Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: CSL questions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xleroy@p...>
Subject: Re: CSL questions
> 1) Why cslc and cslopt don't print part of the source
> to explain where is error.

Correct. I finally noticed that during batch compilation it's
basically useless to print source fragments with the errors
underlined: since you're compiling from a file, you'll have to open it
with an editor and go to the line with the error anyway; you'll locate
the error inside the editor, not on the output of the compiler.

For Emacs users, the best solution is still to compile under Emacs
with M-x compile, then use find-next-error to jump to the error
location.

> How can I recursivly define modules ? I need SetExpr to define
> the type expr and I need the type expr to define SetExpr.

You can't. That's one of the most annoying restrictions of SML-style
module systems. Unfortunately, compiling mutually recursive module
definitions is hard. Some workarounds are described in the user's
manual (chapter "Batch compilation", section "Common errors". I'm
afraid they won't apply in your example, though.

> 3) If I suppress the case AC_op in my definition I still have some problems.

The Set.Make functor requires a type named "t" in its argument; just
provide it:

  type expr = V of int
            | Binop of expr * expr
            | A_op of expr list

  module SetExpr =
    Set.Make(struct type t = expr  let compare = compare end)

By the way, there's no need to write all these signature constraints
by hand, the system will do the right thing if you don't put them;
moreover, over-constraining may cause some types to become abstract
when you don't want them to.

> So I try to use the "with" constuct

There is a misunderstanding here: "with" does not rename type fields,
it adds an equality over an existing type field. So if S is

        sig type t ... end

then S with t = expr is

        sig type t=expr ... end

but not

        sig type expr ... end

- Xavier Leroy