caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Bug or feature?
@ 2003-03-06 23:18 Alessandro Baretta
  2003-03-06 23:43 ` Remi Vanicat
  0 siblings, 1 reply; 6+ messages in thread
From: Alessandro Baretta @ 2003-03-06 23:18 UTC (permalink / raw)
  To: Ocaml, Caml bugs

I'm not sure whether this is a bug or a feature.

I need to save the state of the Xcaml session between CGI 
executions. Thinking in terms of Jserv-compliant 
implementation, i used a Weak.Make(...).t hashtable to store 
  session data, so that old and no longer used data might be 
automatically reclaimed by the GC. However, I found that 
this implementation is buggy, because when I marshal and 
unmarshal the weak hashtable, I always get an empty 
hashtable back. Why is this?

I made a switch to Hashtbl.Make(...).t and now the session 
handling in Xcaml works fine, except that there is no 
automatic garbage collection. All other code, except for 
minor modifications due to incompatibilities between the 
output signatures of Hashtbl.Make and Weak.Make, has been 
left untouched.

One more remark concerning the Weak.Make functor. Why in the 
world are Hashtbl.Make and Weak.Make incompatible? It is 
only natural to think of the second as a particularly clever 
implementation of the first. Besides, the two modules are so 
similar that really deserve to have the same signatures. I 
strongly encourage the Caml Masters to think this over. Of 
course, I could reimplement the Weak.Make functor in a Weak2 
module for the ocamllib-addons package, but is it worth it?

Alex

-------------------
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] 6+ messages in thread

* Re: [Caml-list] Bug or feature?
  2003-03-06 23:18 [Caml-list] Bug or feature? Alessandro Baretta
@ 2003-03-06 23:43 ` Remi Vanicat
  2003-03-06 23:56   ` Alessandro Baretta
  0 siblings, 1 reply; 6+ messages in thread
From: Remi Vanicat @ 2003-03-06 23:43 UTC (permalink / raw)
  To: caml-list

Alessandro Baretta <alex@baretta.com> writes:

[...]


> One more remark concerning the Weak.Make functor. Why in the world are
> Hashtbl.Make and Weak.Make incompatible? It is only natural to think
> of the second as a particularly clever implementation of the
> first. Besides, the two modules are so similar that really deserve to
> have the same signatures. I strongly encourage the Caml Masters to
> think this over. Of course, I could reimplement the Weak.Make functor
> in a Weak2 module for the ocamllib-addons package, but is it worth
> it?

You might be interested by my hweak library
(http://aspellfr.free.fr/hweak/) which have a similar interface than
regular Hashtbl.

I've not tested it with regard of marshal.
-- 
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat

-------------------
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] 6+ messages in thread

* Re: [Caml-list] Bug or feature?
  2003-03-06 23:43 ` Remi Vanicat
@ 2003-03-06 23:56   ` Alessandro Baretta
  0 siblings, 0 replies; 6+ messages in thread
From: Alessandro Baretta @ 2003-03-06 23:56 UTC (permalink / raw)
  To: Ocaml



Remi Vanicat wrote:
> 
> You might be interested by my hweak library
> (http://aspellfr.free.fr/hweak/) which have a similar interface than
> regular Hashtbl.
> 
> I've not tested it with regard of marshal.


Thanks, I really think I need a weak replacement for the 
ordinary hashtable module. I'll drop you a line to tell you 
if I manage to get it to work with the Marshal module.

Alex


-------------------
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] 6+ messages in thread

* Re: [Caml-list] Bug or feature?
  2011-09-12 13:13 ` Jesper Louis Andersen
@ 2011-09-12 13:19   ` Philippe Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Philippe Wang @ 2011-09-12 13:19 UTC (permalink / raw)
  To: Jesper Louis Andersen; +Cc: Andrej Bauer, caml-list

# let a = 32 ;; let b = 42 ;;
val a : int = 32
# b;;
Error: Unbound value b

Yeah... it's a little bit weird... not so great, actually. :-/

-- 
Philippe Wang
   mail@philippewang.info



On Mon, Sep 12, 2011 at 3:13 PM, Jesper Louis Andersen
<jesper.louis.andersen@gmail.com> wrote:
> On Mon, Sep 12, 2011 at 14:56, Andrej Bauer <andrej.bauer@andrej.com> wrote:
>> Would anyone wish to comment on this particular "feature" of toplevel?
>>
>>
>>        Objective Caml version 3.12.1
>>
>> # let a = 12 ;; I CAN PUT ANY GARBAGE HERE AND IT GETS IGNORED
>> val a : int = 12
>>
>
> It is a bug when you want to enter multiple statements, like in:
>
> # let a = 12;; a + 30;;
> val a : int = 12
>
> But it is a feature when you want to use the toplevel as a way to
> comment on what you are doing
>
> # let prod x = List.fold_left (fun x y -> x*y) 1 x;; DEAR STUDENTS,
> USE THIS DEFINITION TO DEFINE THE FACTORIAL FUNCTION
>
> where the helpful feature of the top level makes it easier for the
> student to just paste the whole line into the top level (except for
> the # at the beginning, you can't have everything, can you?).
>
> To conclude: It is a bug and a feature at the same time. Which is
> quite peculiar, since it does not have mutual exclusivity in this case
> (contrast to evaluation order where there is a right and a wrong one,
> your mileage may vary - but you can't have both at the same time for
> the same expression, though you can have both at different times for
> the same expression :).
>
> --
> J.
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
>


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

* Re: [Caml-list] Bug or feature?
  2011-09-12 12:56 Andrej Bauer
@ 2011-09-12 13:13 ` Jesper Louis Andersen
  2011-09-12 13:19   ` Philippe Wang
  0 siblings, 1 reply; 6+ messages in thread
From: Jesper Louis Andersen @ 2011-09-12 13:13 UTC (permalink / raw)
  To: Andrej Bauer; +Cc: caml-list

On Mon, Sep 12, 2011 at 14:56, Andrej Bauer <andrej.bauer@andrej.com> wrote:
> Would anyone wish to comment on this particular "feature" of toplevel?
>
>
>        Objective Caml version 3.12.1
>
> # let a = 12 ;; I CAN PUT ANY GARBAGE HERE AND IT GETS IGNORED
> val a : int = 12
>

It is a bug when you want to enter multiple statements, like in:

# let a = 12;; a + 30;;
val a : int = 12

But it is a feature when you want to use the toplevel as a way to
comment on what you are doing

# let prod x = List.fold_left (fun x y -> x*y) 1 x;; DEAR STUDENTS,
USE THIS DEFINITION TO DEFINE THE FACTORIAL FUNCTION

where the helpful feature of the top level makes it easier for the
student to just paste the whole line into the top level (except for
the # at the beginning, you can't have everything, can you?).

To conclude: It is a bug and a feature at the same time. Which is
quite peculiar, since it does not have mutual exclusivity in this case
(contrast to evaluation order where there is a right and a wrong one,
your mileage may vary - but you can't have both at the same time for
the same expression, though you can have both at different times for
the same expression :).

-- 
J.


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

* [Caml-list] Bug or feature?
@ 2011-09-12 12:56 Andrej Bauer
  2011-09-12 13:13 ` Jesper Louis Andersen
  0 siblings, 1 reply; 6+ messages in thread
From: Andrej Bauer @ 2011-09-12 12:56 UTC (permalink / raw)
  To: caml-list

Would anyone wish to comment on this particular "feature" of toplevel?


        Objective Caml version 3.12.1

# let a = 12 ;; I CAN PUT ANY GARBAGE HERE AND IT GETS IGNORED
val a : int = 12

With kind regards,

Andrej

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

end of thread, other threads:[~2011-09-12 13:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-06 23:18 [Caml-list] Bug or feature? Alessandro Baretta
2003-03-06 23:43 ` Remi Vanicat
2003-03-06 23:56   ` Alessandro Baretta
2011-09-12 12:56 Andrej Bauer
2011-09-12 13:13 ` Jesper Louis Andersen
2011-09-12 13:19   ` Philippe Wang

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