Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/ml-nlffi-lib/Doc/mini-tutorial.txt
ViewVC logotype

Diff of /sml/trunk/src/ml-nlffi-lib/Doc/mini-tutorial.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 835, Wed May 23 18:30:31 2001 UTC revision 836, Fri May 25 19:28:51 2001 UTC
# Line 4  Line 4 
4  A very incomplete introduction  A very incomplete introduction
5  (by Matthias Blume (blume@research.bell-labs.com))  (by Matthias Blume (blume@research.bell-labs.com))
6    
7    !!! Warning:  this currently works on x86/Linux only! !!!
8    
9  The new NLFFI ("no-longer foreign function interface") is based on the  The new NLFFI ("no-longer foreign function interface") is based on the
10  idea of data-level interoperability:  ML code (a mixture of  idea of data-level interoperability:  ML code (a mixture of
# Line 253  Line 254 
254    
255     Arrays are second-class values.  Their (phantom) type is     Arrays are second-class values.  Their (phantom) type is
256    
257       type ('t, 'f, 'n) arr       type ('t, 'n) arr
258    
259     Here, 't is the type of the values stored in the array's individual     Here, 't is the type of the values stored in the array's individual
260     elements, 'f here is the same as the 'f in the case of obj or ptr,     elements, 'f here is the same as the 'f in the case of obj or ptr,
# Line 277  Line 278 
278    
279     The connection to array types is this:  An array of size N has type     The connection to array types is this:  An array of size N has type
280    
281        ('t, 'f, [N]) arr        ('t, [N]) arr
282    
283     iff "[N] dim" is the type assigned to N by our Dim construction.     iff "[N] dim" is the type assigned to N by our Dim construction.
284    
# Line 285  Line 286 
286    
287     The C type (int[312]) is encoded as     The C type (int[312]) is encoded as
288    
289        (sint, unit, dec dg3 dg1 dg2) arr        (sint, dec dg3 dg1 dg2) arr
290    
291     In other words, if you "squint away" the "dec", the "dg"s, and the     In other words, if you "squint away" the "dec", the "dg"s, and the
292     spaces, then the array dimension gets spelled out in decimal.     spaces, then the array dimension gets spelled out in decimal.
# Line 293  Line 294 
294     4.2. Operations over arrays:     4.2. Operations over arrays:
295    
296     Since array types are second-class, there are no operations that     Since array types are second-class, there are no operations that
297     produce or consume values of type (?, ?, ?) arr.  Instead, we use     produce or consume values of type (?, ?) arr.  Instead, we use
298     array objects of type ((?, ?, ?) arr, ?, ?) obj.     array objects of type ((?, ?) arr, ?, ?) obj.
299    
300     Most operations related to array objects are in substructure Arr.     Most operations related to array objects are in substructure Arr.
301    
# Line 317  Line 318 
318    
319     Function pointers have type 'f fptr where 'f is always instantiated     Function pointers have type 'f fptr where 'f is always instantiated
320     to (A -> B) for some A and B.  This instantiation for 'f propagates     to (A -> B) for some A and B.  This instantiation for 'f propagates
321     through all those 'f components of obj-, ptr-, or arr-types whose     through all those 'f components of obj-, ptr-, or T.typ-types whose
322     't component somehow involves the fptr-type.     't component somehow involves the fptr-type.
323    
324     A function pointer of type (A -> B) fptr can be invoked with an     A function pointer of type (A -> B) fptr can be invoked with an
# Line 419  Line 420 
420     upon) for most operations.     upon) for most operations.
421    
422     Light-weight versions of these types (constructors carry a prime in     Light-weight versions of these types (constructors carry a prime in
423     their names): "obj'", "ptr'", "fptr'") do not use RTI in their     their names: "obj'", "ptr'", "fptr'") do not use RTI in their
424     concrete representations.  This is more efficient for all     concrete representations.  This is more efficient for all
425     operations that don't need access to RTI.  On the downside, it     operations that don't need access to RTI.  On the downside, it
426     means that RTI must be passed in explicitly by the programmer for     means that RTI must be passed in explicitly by the programmer for
# Line 434  Line 435 
435     Array subscript, to name one example, on light-weight array objects     Array subscript, to name one example, on light-weight array objects
436     enforces correct usage of RTI using ML's static typing:     enforces correct usage of RTI using ML's static typing:
437    
438          Arr.sub' : (('t, 'f, 'n) arr, 'f) T.typ ->          Arr.sub' : (('t, 'n) arr, 'f) T.typ ->
439                     (('t, 'f, 'n) arr, 'f, 'c) obj' * int -> ('t, 'f, 'c) obj'                     (('t, 'n) arr, 'f, 'c) obj' * int -> ('t, 'f, 'c) obj'
440    
441     7.1 Light vs. heavy:     7.1 Light vs. heavy:
442    

Legend:
Removed from v.835  
changed lines
  Added in v.836

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0