Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] kprintf with user formatters
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Pierre Weis <pierre.weis@i...>
Subject: Re: [Caml-list] kprintf with user formatters
[...]
> Well, I suppose you don't want to imply that I should refrain from using
> modules Printf and Format?  They are full of Obj.magic!

I certainly not want to imply that you should refrain from using
Printf, Format, Scanf, and also the ocaml interactive system,
given that they all use Obj.magic.

However, all those uses of Obj.magic have a strong theoretical
justification. In the best case they have been proved to be perfectly sound.

In any case, we certainly never have a proof that some of those
Obj.magic uses can lead to a wrong value (as a closure supposed to
have type unit would be).

> I have definitely given it some thought whether there could be some
> kind of unsound use of return values, but I didn't find anything,
> because unit-values are always ignored.

Thank you for given some thought about unsound use of Obj.magic on the
compiler. If you ever discover one (out of Marshall), please let us
know, we will be glad to modify it :)

However, I'm glad that you ``didn't find anything''. I should say that
this is not, as you guessed, ``because unit-values are always
ignored'': the reason is more likely to be that we always have strong
evidence that those Obj.magic occurrences are harmless and extremely
hard to eliminate.

> Any other solution I have seen so far is much more complicated: it either
> requires the use of a preprocessor, thunking or the use of lazy values
> (I had already used them before - very unwieldy) or forces unnecessary
> computations even if some action at the current log level shouldn't
> be logged.
> 
> The only sufficiently efficient, elegant and safe solution would be to
> introduce some kind of flag into the fprintf_out function in Printf so
> that it doesn't call string conversion functions.  Or provide a dummy
> function that just parses the format string and removes arguments.
> This way a zprintf-function could be put into the interface.

Once more you do not solve the problem of arguments useless
evaluation. I'm convinced that the more elegant way is to introduce
some support for logging into the system.

Regards,

Pierre Weis

INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/


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