Nicolai Schaffroth | 20 May 12:48
Picon
Favicon

Accessing a representation of types

Hello,
 
I am currently working on integrating the QCheck/SML automatic unit testing library with the theorem prover Isabelle at TU München and automating the construction of random value generators.
It would be very helpful to know if there is an internal representation of value and function types that can be accessed in some way other than parsing the string returned upon creation.
 
Thank you for any helpful information,
 
Nicolai
_______________________________________________
polyml mailing list
polyml@...
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
Ramana Kumar | 7 May 14:37
Picon
Gravatar

assertion failed in r1520

I keep running into this kind of problem in svn revision 1520.

> hol.builder: gc_mark_phase.cpp:433: virtual void MTGCProcessMarkPointers::ScanAddressesInObject(PolyObject*, POLYUNSIGNED): Assertion `gMem.SpaceForAddress(wordAt.AsCodePtr()) != 0' failed.
Aborted

I'm guessing it's a known problem in unstable, but if not I'd be happy to provide more information as necessary.
If it is known, is it likely to be fixed in svn soon?

Thanks,
Ramana

_______________________________________________
polyml mailing list
polyml@...
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
Jeremy Singer | 26 Apr 18:06
Picon

gcbench in SML

Hi David,

I am trying to create something like Hans Boehm's GC benchmark -
http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_bench.html
in SML. My current attempt is at:
http://pastebin.com/2RW9jpCJ

Sorry - I forgot all my ML years ago. Here are some things I'm not sure how to do nicely in Poly/ML:

* printf without lots of String.concat
* is there a runtime API call to get the totalMem (current heap size?) and the free mem (currently unused
blocks in heap?)
* Are all my ephemeral objects being created properly, or is the compiler optimizing away their
allocation? How could I tell?
* So far, I have been checking gc activity with --debug gc flag. Are there any more powerful tools for GC profiling/checking?

Thanks,
Jeremy

The University of Glasgow, charity number SC004401
Phil Clayton | 27 Mar 23:41

Poly/ML and SML/NJ warn inconsistently about using op for an infix constructor

For example, given

   infix &
   datatype t = &

Poly/ML (5.4) reports:

   Warning-(&) has infix status but was not preceded by op.

So Poly/ML seems to prefer the use of 'op' in a datatype declaration. 
However, if 'op' is present, i.e.

   datatype t = op &

SML/NJ (110.73) reports:

   stdIn:2.14-2.16 Warning: unnecessary `op'

Generally, it is a good principle to avoid warnings but, in this 
particular respect, that isn't possible for code that is shared between 
Poly/ML and SML/NJ.  Note that MLton (20100608) doesn't warn either way.

Does the Standard provide any guidance about the use of op here?  Can 
anything be done to align the warnings from Poly/ML and SML/NJ in this 
respect?

Thanks,
Phil
Phil Clayton | 15 Feb 14:38

Calling C functions

I thought it could be useful to mention the approach that I have been 
taking for calling C functions.  In particular, it avoids the need to 
have a family of callN functions.  For example, instead of writing

   call2 (load_sym lib "sum") (DOUBLE, DOUBLE) DOUBLE

operators --> and &&> are used to construct function specifications that 
are given to a single call function:

   call (load_sym lib "sum") (DOUBLE &&> DOUBLE --> DOUBLE)

The resulting function takes nested pair arguments rather than an 
n-tuple, so we would give the argument e.g. (x & y), where & is an 
infixr constructor for a pair type, rather than (x, y).  See example 1 
in attached.

I didn't extend this scheme for passing parameters by reference because 
that was easily dealt with elsewhere (still avoiding the family of 
callNretX functions): in my approach, each C function binding has two 
levels: a low-level as above and a high-level wrapper that is introduced for
   - converting between abstract types and concrete C types
   - controlling ownership of C allocated memory
These high level wrappers can also perform the required address/deref 
operations for passing parameters by reference.  At the lower-level, 
parameters passed by reference are just pointers:

   val swap_ =
     call (get_sym lib "swap") (POINTER &&> POINTER --> VOID);

Then this is wrapped, using operators ---> and &&&>, as follows:

   val swap = (withRef INT &&&> withRef INT ---> I) swap_;

The resulting function takes/returns nested pair arguments, so we could 
write e.g.

   val x & y & () = swap (2 & 3)

See example 2 in attached.  For the attached examples, the C library 
shared object is built with 'make bin'.  Don't forget to include the 
example directory in LD_LIBRARY_PATH when invoking poly.

Phil

P.S. The same high-level binding wrappers can be used for both Poly/ML 
and MLton by creating a common interface, so reducing compiler specific 
code.

Attachment (c_ffi_call-20120215-1.tar.gz): application/x-gzip, 1389 bytes
_______________________________________________
polyml mailing list
polyml@...
http://lists.inf.ed.ac.uk/mailman/listinfo/polyml
Phil Clayton | 3 Feb 16:44

Overloaded operators for Time.time

It appears that Poly/ML overloads operators + - < <= >= > for Time.time 
but they shouldn't be, according to the Basis Library.
http://www.standardml.org/Basis/top-level-chapter.html#section:3
Perhaps they were overloaded once upon a Time.time...

Phil
Florian Weimer | 29 Jan 19:47
Picon

Add --error-exit option

The patch below adds an --error-exit option and uses it in the
makefile.  This avoids replacing the compiler with something that
doesn't work at all due to compilation errors.

diff --git a/Makefile.am b/Makefile.am
index af5853d..51372ad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -104,7 +104,7 @@ polytemp.txt: $(POLYIMPORT)
 # This builds the compiler but does not update the files in the imports directory.
 # It then builds a version of poly containing the new compiler.
 compiler: all
-	./poly $(BOOTSTRAP_OPTIONS) < mlsource/BuildExport.sml
+	./poly $(BOOTSTRAP_OPTIONS) --error-exit < mlsource/BuildExport.sml
 	$(MAKE)

 reboot: compiler
diff --git a/basis/FinalPolyML.sml b/basis/FinalPolyML.sml
index 0480aba..651f573 100644
--- a/basis/FinalPolyML.sml
+++ b/basis/FinalPolyML.sml
@@ -250,6 +250,8 @@ local
         if ! useMarkupInOutput then prettyPrintWithIDEMarkup(stream, lineWidth)
         else PolyML.prettyPrint(stream, lineWidth)

+    val exitOnError = ref false
+
     (* Top-level prompts. *)
     val prompt1 = ref "> " and prompt2 = ref "# ";

@@ -706,7 +708,10 @@ local
             fun handledLoop () : unit =
             (
                 (* Process a single top-level command. *)
-                readEvalPrint() handle _ => ();
+                readEvalPrint() handle _ =>
+				       if !exitOnError
+				       then OS.Process.exit OS.Process.failure
+				       else ();
                 (* Exit if we've seen end-of-file or we're in the debugger
                    and we've run "continue". *)
                 if !endOfFile orelse exitLoop() then ()
@@ -873,6 +878,7 @@ local
             (* Generate mark-up in IDE code when printing if the option has been given
                on the command line. *)
             useMarkupInOutput := List.exists(fn s => s = "--with-markup") (CommandLine.arguments());
+	    exitOnError := List.exists(fn s => s = "--error-exit") (CommandLine.arguments());
             topLevel false (globalNameSpace, fn _ => false)
         )
     end
diff --git a/basis/TopLevelPolyML.sml b/basis/TopLevelPolyML.sml
index 405d5ae..0a18243 100644
--- a/basis/TopLevelPolyML.sml
+++ b/basis/TopLevelPolyML.sml
@@ -1121,6 +1121,7 @@ in
                 print "--help         Print this message and exit\n";
                 print "-q             Suppress the start-up message\n";
                 print "--use FILE     Executes 'use \"FILE\";' before the ML shell starts\n";
+		print "--error-exit   Exit shell on unhandled exception\n";
                 print "--with-markup  Include extra mark-up information when printing\n";
                 print "--ideprotocol  Run the IDE communications protocol\n";
                 print "\nRun time system arguments:\n";
Phil Clayton | 27 Jan 18:47

Lifespan of pointers to callback functions passed via C FFI

I have been assuming that the pointer back to an ML function passed to a 
foreign C function will still be valid after the C function has 
returned, so the callback can occur sometime later (from a different C 
function).  Is that a valid assumption?

I made this assumption based on some tests in which one such callback 
pointer remained valid for the life of the application.  It would be 
nice to know I wasn't just being (un)lucky!

Phil
Ian Zimmerman | 17 Jan 06:53
Gravatar

Exception- Empty unexpectedly raised while compiling


Getting this one.  WTH?
Code is here:

git@...:nobrowser/easylib.git

just do 'use "load-all";' from the top level directory ...

PolyML 5.4.1 (release), Linux i386 (32-bit), 2G RAM.

--

-- 
Ian Zimmerman
gpg public key: 1024D/C6FF61AD
fingerprint: 66DC D68F 5C1B 4D71 2EE5  BD03 8A00 786C C6FF 61AD
Rule 420: All persons more than eight miles high to leave the court.
Ian Zimmerman | 5 Jan 21:03
Gravatar

Exceptions and standalone executables


 [17]matica:~$ poly
Poly/ML 5.4.1 Release
> fun main () = raise Domain ;
val main = fn: unit -> 'a
> PolyML.export ("foo", main);
val it = (): unit

 [19]matica:~$ cc -o foo foo.o -lpolymain -lpolyml
 [20]matica:~$ ./foo
 [21]matica:~$ echo $?
0

I find this quite surprising, am I the only one?

I know that I can easily work around it by including an exception
catching wrapper in main, but it seems to me that wrapper should be in
libpolymain ..

--

-- 
Ian Zimmerman
gpg public key: 1024D/C6FF61AD
fingerprint: 66DC D68F 5C1B 4D71 2EE5  BD03 8A00 786C C6FF 61AD
Rule 420: All persons more than eight miles high to leave the court.
Phil Clayton | 13 Dec 15:56

Sourceforge tracker

David,

I have started adding minor issues to the Sourceforge tracker, rather 
than bother the mailing list with mundane matters.  I hope that is all 
right.

Phil

Gmane