caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Using -dtypes output in conjunction with a preprocessor
@ 2003-08-22  7:39 art yerkes
  2003-08-22  9:05 ` Michal Moskal
  2003-08-24 15:14 ` [Caml-list] GlSurf 2.0 Christophe Raffalli
  0 siblings, 2 replies; 4+ messages in thread
From: art yerkes @ 2003-08-22  7:39 UTC (permalink / raw)
  To: caml-list

While I know it's not really intended for this, I've been giving some thought
to streamlining SWIG's Ocaml support.  To this end, I notice that -dtypes
has been added to ocamlc in order to support type browsing in emacs.

What I'm interested in finding out is if this output is expected to be stable,
or if there is another way to get this sort of deep type information from a
source file.  I intend to use this information as hints to a camlp4 module
that will recognize and rewrite references to C++ externals in order to emulate
C++ style overloading.  

As far as I can see, I will need the ocaml compiler to tell me what type is
expected for a certain application, then insert marshalling code that produces
and consumes the types indicated in the hint.

For example, I might produce:

let _ = print_endline 
  (string_of_int 
    (get_int (__swig__wrapped_foo (C_list [(C_int a) (C_int b)]))

from:

let _ = print_endline (string_of_int (foo 1 2))

Given that the detected type of foo will be "int -> int -> int"

Is using the -dtypes output the best way to get the right info?
-- 
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected
 without, I thought, proper consideration."
   - S. Kelly-Bootle

-------------------
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Using -dtypes output in conjunction with a preprocessor
  2003-08-22  7:39 [Caml-list] Using -dtypes output in conjunction with a preprocessor art yerkes
@ 2003-08-22  9:05 ` Michal Moskal
  2003-08-22 14:27   ` art yerkes
  2003-08-24 15:14 ` [Caml-list] GlSurf 2.0 Christophe Raffalli
  1 sibling, 1 reply; 4+ messages in thread
From: Michal Moskal @ 2003-08-22  9:05 UTC (permalink / raw)
  To: art yerkes; +Cc: caml-list

On Fri, Aug 22, 2003 at 02:39:49AM -0500, art yerkes wrote:
> While I know it's not really intended for this, I've been giving some thought
> to streamlining SWIG's Ocaml support.  To this end, I notice that -dtypes
> has been added to ocamlc in order to support type browsing in emacs.
> 
> What I'm interested in finding out is if this output is expected to be stable,
> or if there is another way to get this sort of deep type information from a
> source file.  I intend to use this information as hints to a camlp4 module
> that will recognize and rewrite references to C++ externals in order to emulate
> C++ style overloading.  
> 
> As far as I can see, I will need the ocaml compiler to tell me what type is
> expected for a certain application, 

Expected type? Hmm...

> then insert marshalling code that produces
> and consumes the types indicated in the hint.
> 
> For example, I might produce:
> 
> let _ = print_endline 
>   (string_of_int 
>     (get_int (__swig__wrapped_foo (C_list [(C_int a) (C_int b)]))
> 
> from:
> 
> let _ = print_endline (string_of_int (foo 1 2))
> 
> Given that the detected type of foo will be "int -> int -> int"
> 
> Is using the -dtypes output the best way to get the right info?

How about:

let f x y = foo x y

and:

let g x y = 
  let baz = foo x y in
  let qux = foo baz baz in
  x + 1

You probably should find out how type inference works.

-- 
: Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv
: When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h

-------------------
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] Using -dtypes output in conjunction with a preprocessor
  2003-08-22  9:05 ` Michal Moskal
@ 2003-08-22 14:27   ` art yerkes
  0 siblings, 0 replies; 4+ messages in thread
From: art yerkes @ 2003-08-22 14:27 UTC (permalink / raw)
  To: caml-list

On Fri, 22 Aug 2003 11:05:18 +0200
Michal Moskal <malekith@pld-linux.org> wrote:

> 
> How about:
> 
> let f x y = foo x y
> 
> and:
> 
> let g x y = 
>   let baz = foo x y in
>   let qux = foo baz baz in
>   x + 1

Yes, I know that it's not always possible for caml to predict the type, but
the user can resolve such a case with a type annotation.  Alternately, I can
write in the 'default' case that leaves the data unmarshalled.  In either
case it's just as much an error to try to have the language guess what types
C++ needs as it would be in C++.  

In addition, I have done several experiments which show that Ocaml does
correctly type polymorphic applications that have no other possible types.

If you examine the -dtypes output for this code fragment, you'll notice that
the expression at character 78 (as recokoned by -dtypes) is correctly typed,
even though the real type is unspecified:

external ___swig___make_point1 : 'a -> 'b -> 'c = "make_point"
                                                                                
let _ = match ___swig___make_point1 3 3 with
    (a,b) -> print_endline ((string_of_int a) ^ "," ^ (string_of_int b))
  | _ -> ()

If it interests you, here is how Ocaml's type inference *actually* works:

"typefoo.ml" 3 64 78 "typefoo.ml" 3 64 99
type(
  int -> int -> int * int
)

The reason why Ocaml can do this, in my recokoning is that any other
signature given for this expression would be an error.  As far as I can
tell, Ocaml will always place a concrete type on an unambiguous expression.
Perhaps Mr. Leroy or one of the other gurus can set me straight, however.

My goal is not necessarily any philosophical purity.  I know that some cases
do fail to unify, and I believe thats OK.  What I'm fighting is a basic
disconnect between the notion of a statically typed overloaded application
in C++, and the Ocaml rule that a certain named value has exactly one type.

I've looked at gcaml for this same reason, B.T.W, but since I'm trying to
balance practical with not, I believe that making the most of the standard
Ocaml is best.
-- 
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected
 without, I thought, proper consideration."
   - S. Kelly-Bootle

-------------------
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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Caml-list] GlSurf 2.0
  2003-08-22  7:39 [Caml-list] Using -dtypes output in conjunction with a preprocessor art yerkes
  2003-08-22  9:05 ` Michal Moskal
@ 2003-08-24 15:14 ` Christophe Raffalli
  1 sibling, 0 replies; 4+ messages in thread
From: Christophe Raffalli @ 2003-08-24 15:14 UTC (permalink / raw)
  Cc: caml-list

[-- Attachment #1: Type: text/plain, Size: 1277 bytes --]


I am pleased to announce the release 2.0 of GlSurf
<http://www.lama.univ-savoie.fr/~raffalli/glsurf>.

It now works under Windows (I distribute binary version :-)
Feel free to test it and reports problem.

--
GlSurf is a program (similar to Surf (http://surf.sourceforge.net)) to
draw 3D surfaces and 3D curves from their implicit equations (that is
drawing the set of points (x,y,z) such that f(x,y,z) = 0).

It offers an intuitive and simple syntax to construct your functions,
it can draw multiple surfaces simultaneously and it can use all the
power of OpenGl to animate the surface, use transparency, etc ...

GlSurf is a ``command interpreter'': you type some commands and it
executes them !

A good way to use GlSurf is to write a sequence of command in a file
and the type "glsurf file" to execute all the commands.

-- 
Christophe Raffalli
Université de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tél: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature
---------------------------------------------

[-- Attachment #2: Type: application/pgp-signature, Size: 252 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-08-24 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-22  7:39 [Caml-list] Using -dtypes output in conjunction with a preprocessor art yerkes
2003-08-22  9:05 ` Michal Moskal
2003-08-22 14:27   ` art yerkes
2003-08-24 15:14 ` [Caml-list] GlSurf 2.0 Christophe Raffalli

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).