From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p8OJWAZf022766 for ; Sat, 24 Sep 2011 21:32:10 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkcBAA4vfk6flYLKl2dsb2JhbABCqBwUAQEBAQEIFgc6ggGBNU8MiA2ZNp4whwsEk1KFEBKMEw X-IronPort-AV: E=Sophos;i="4.68,435,1312149600"; d="ml'?scan'208";a="121275236" Received: from smtp.dico.unimi.it ([159.149.130.202]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 24 Sep 2011 21:32:05 +0200 Received: from [192.168.1.100] (dynamic-adsl-94-36-56-5.clienti.tiscali.it [94.36.56.5]) (authenticated bits=0) by smtp.dico.unimi.it (8.14.4/8.14.4) with ESMTP id p8OJVxdM009464 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 24 Sep 2011 21:31:59 +0200 Date: Sat, 24 Sep 2011 21:31:54 +0200 (CEST) From: Walter Cazzola To: OCaML Mailing List Message-ID: User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-1254480806-1316892720=:2944" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0 (smtp.dico.unimi.it [159.149.130.202]); Sat, 24 Sep 2011 21:32:00 +0200 (CEST) X-DSI-MailScanner-Information: Please contact the staff for more information X-DSI-MailScanner-ID: p8OJVxdM009464 X-DSI-MailScanner: Found to be clean X-DSI-MailScanner-From: cazzola@dico.unimi.it Subject: [Caml-list] polymorphic stack This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-1254480806-1316892720=:2944 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII Hi all, thanks a lot for your help in this travel through OCaML but I have still a question. I have tried to write a polymorphic stack code attached but I don't understand its behavior: # open Stack;; # let s = empty;; val s : '_a Stack.stack = {c = []} # push s 7;; - : unit = () # push s 25;; - : unit = () # let s1 = empty;; val s1 : int Stack.stack = {c = [25; 7]} # push s1 "Hello";; Error: This expression has type string but an expression was expected of type int Apparently seems that I can have only a variable of type stack and any other call to its constructor links the new variable to the old one. This means that once I have put an int inside I can't have a second stack for characters or what else? This behavior is completely unexpected and I can't explain it. I'm sure I'm doing something wrong but I can't say what it is. Do you have any idea about? TIA Walter -- --8323328-1254480806-1316892720=:2944 Content-Type: TEXT/PLAIN; charset=US-ASCII; name=adtstack.ml Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename=adtstack.ml bW9kdWxlIFN0YWNrID0gc3RydWN0DQogIHR5cGUgJ2Egc3RhY2sgPSB7IG11 dGFibGUgYyA6ICdhIGxpc3QgfQ0KICBleGNlcHRpb24gRW1wdHlTdGFja0V4 Y2VwdGlvbg0KIA0KICBsZXQgZW1wdHkgPSB7IGMgPSBbXSB9DQoNCiAgbGV0 IHB1c2ggcyB4ID0gcy5jIDwtIHggOjogcy5jDQogDQogIGxldCBwb3AgcyA9 DQogICAgbWF0Y2ggcy5jIHdpdGgNCiAgICAgIGhkOjp0bCAtPiBzLmMgPC0g dGwNCiAgICB8IFtdICAgICAtPiByYWlzZSBFbXB0eVN0YWNrRXhjZXB0aW9u DQogDQogIGxldCB0b3AgcyA9DQogICAgbWF0Y2ggcy5jIHdpdGgNCiAgICAg IGhkOjpfIC0+IGhkDQogICAgfCBbXSAgICAtPiByYWlzZSBFbXB0eVN0YWNr RXhjZXB0aW9uDQogDQogIGxldCBpc19lbXB0eSBzID0gKHMuYyA9IFtdKQ0K ZW5kOzsNCg== --8323328-1254480806-1316892720=:2944--