Changeset 5014 in project


Ignore:
Timestamp:
07/12/07 01:54:49 (13 years ago)
Author:
felix winkelmann
Message:

new fp release (tagged)

Files:
1 deleted
7 edited
3 copied

Legend:

Unmodified
Added
Removed
  • prometheus/prometheus.meta

    r1 r5014  
    66 (needs syntax-case)
    77 (license "GPL")
     8 (eggdoc "doc.scm")
    89 (egg "prometheus.egg")
    910 (files "prometheus.scm"
  • unix-sockets/unix-sockets.html

    r1270 r5014  
    4848<h3>Version:</h3>
    4949<ul>
     50<li>1.3
     51Applied bugfix by Shawn Wagner
    5052<li>1.2
    5153Added include for sys/time.h, which is needed on some systems [Thanks to Kon Lovett]
  • unix-sockets/unix-sockets.meta

    r2189 r5014  
    55 (category net)
    66 (needs easyffi)
     7 (platform unix)
    78 (license "BSD")
    8  (author
    9    "<a href=\"mailto:felix@call-with-current-continuation.org\">felix</a>"))
     9 (author "felix winkelmann") )
  • unix-sockets/unix-sockets.scm

    r852 r5014  
    6262{
    6363  int sock;
    64   size_t size;
     64  socklen_t size;
    6565     
    6666  /* Create the socket. */
     
    8787{
    8888  int sock;
     89  socklen_t size;
    8990     
    9091  /* Create the socket. */
     
    9697  strncpy(socket_name.sun_path, filename, sizeof(socket_name.sun_path));
    9798  socket_name.sun_path[sizeof (socket_name.sun_path) - 1] = '\0';
     99  size = SUN_LEN(&socket_name);
    98100
    99101  /* Connect to the server. */
    100   if (connect(sock, (struct sockaddr *) &socket_name, strlen(socket_name.sun_path) + sizeof(socket_name.sun_family)) < 0)
     102  if (connect(sock, (struct sockaddr *) &socket_name, size) < 0)
    101103    return -1;
    102104
     
    108110accept_connection(int sock, char *filename)
    109111{
    110   int s2, size;
    111 
    112   size = sizeof(socket_name);
     112  int s2;
     113  socklen_t size;
     114
    113115  socket_name.sun_family = AF_LOCAL;
    114116  strncpy(socket_name.sun_path, filename, sizeof(socket_name.sun_path));
    115117  socket_name.sun_path[sizeof (socket_name.sun_path) - 1] = '\0';
     118  size = SUN_LEN(&socket_name);
    116119  s2 = accept(sock, (struct sockaddr *)&socket_name, &size);
    117120
  • unix-sockets/unix-sockets.setup

    r1706 r5014  
    44(compile -s -O2 -d1 ,@(if easyffi? '(-extend easyffi) '()) unix-sockets.scm)
    55(install-extension 'unix-sockets '("unix-sockets.so" "unix-sockets.html")
    6                    '((version 1.2) (documentation "unix-sockets.html")))
     6                   '((version 1.3) (documentation "unix-sockets.html")))
  • wiki/fp

    r3930 r5014  
    3333only appear at toplevel.
    3434
    35 Identifiers may consist of lowercase letters, digits, an underscore or
     35Identifiers may consist of letters, digits, an underscore or
    3636a single quote and must begin with a lowercase letter. Alternatively
    3737any single non-whitespace, non-alphanumeric character that does not
     
    7070  bu f o      "binary-to-unary"
    7171  catch h f   exception handler
     72  _           "bottom"
    7273
    7374''insert'' takes as argument a sequence and inserts the specified
     
    8485applied to the corresponding element. The special pattern {{#}} is equivalent
    8586to {{~T}}, the pattern {{...}} discards all remaining elements and returns true.
     87A pattern can be preceded by a binding declaration of the form {{ID=}}. This creates
     88a temporary local function named {{ID}} that can be used in place of the
     89numerical selector that would normally be used to access the sequence element at
     90that position, so for example:
     91
     92  swap{x=number, y=number}=[y,x].   NB. accept two numbers and swap their position.
     93
     94A pattern binding of the form {{ID=#}} can be abbreviated to {{ID=}}.
    8695
    8796''constant'' ignores its argument and returns the specified object.
     
    118127  name = { <pattern> } -> <body>; <raise error>.
    119128
     129A definition of the form
     130
     131  (name) = ...
     132
     133represents a ''memoizing'' function: after the first invocation, the result is
     134saved and will be returned on any subsequent invocation (regardless of the
     135argument value).
     136
     137A toplevel expression of the form
     138
     139  <ATOM, ...>
     140
     141will load and execute the files named by {{ATOM, ...}} as if they were directly
     142included in the currently compiled/executed program.
     143
     144''bottom'' ignores its argument and signals an error.
     145
    120146Further, a bit of syntactic sugar:
    121147
    122148  f & g      ==>      f -> g; ~F
    123   f | g      ==>      f -> ~T; g
     149  f | g      ==>      (1 -> 1; g 2) [f, id]
     150  `O         ==>      bu eq O
     151  *f         ==>      apndl[f 1, -1]
    124152
    125153
     
    133161== Objects
    134162
    135 An object is an atom (a symbol consisting of uppercase characters or
    136 {{_}} or a string of characters enclosed by double quotes), a
     163An object is an atom (a symbol consisting of letters or
     164{{_}} and beginning with an uppercase letter or a string of characters enclosed by double quotes), a
    137165sequence ({{<x1, ...>}}), or a number. The
    138166atom {{F}} is also used as the boolean false value. Any object different
     
    200228Returns one of the atoms {{ATOM}}, {{NUMBER}} or {{SEQUENCE}}, depending on the type of {{x}}.
    201229
    202   tl:<x1 x2, ...> -> <x2, ...>
    203 
    204 Returns the arguments list with its first element removed.
    205 
    206230  null:x -> bool
    207231
     
    230254  forget:<a, ...>
    231255
    232 Removes stored the code representation of the named functions (the functions themselves are still available).  If called with a non-sequence argument, then all stored code representations are removed.
     256Removes the stored code representation of the named functions (the
     257functions themselves are still available). If called with a
     258non-sequence argument, then all stored code representations are
     259removed.
    233260
    234261  compile:<a, x>
     
    236263Compiles a new global function from the code representation {{x}} with the name {{a}}.
    237264
    238   load:a
    239 
    240 Loads and executes a file containing FP code.
    241 
    242265  pack:<n, ...> -> a
    243266
     
    258281  read:n -> <c, ...>
    259282
    260 Read {{n}} characters or all remaining (if {{n}} is not a number).
    261 
    262   write:x
     283Read {{n}} characters, or the next line of input (if {{n}} is the atom {{LINE}})
     284or all remaining (if {{n}} is not a number).
     285
     286  write:x -> x
    263287
    264288Write sequence of characters or a single character.
    265289
     290  writef:<a, <c, ...>>
     291
     292Writes a string to a given file.
     293
     294  readf:a -> <c, ...>
     295
     296Reads the contents of a file returning a sequence of character codes.
     297
     298  existsf:a -> bool
     299
     300Returns a boolean indicating whether a file with the given name exists.
     301
     302  statf:a -> <n, ...>
     303
     304Returns a 13-element sequence with the following contents: inode-number,
     305permissions, number of hard links, uid of owner, gid of owner, size,
     306access-, change- and modification-time, device id, device type,
     307blocksize and blocks allocated.
     308
     309  system:a
     310
     311Executes a shell command and throws an error if the exit status is non-zero.
     312
     313  readp:a -> <c, ...>
     314
     315Executes shell command and return output as a string.
     316
     317  writep:<a, <c, ...>>
     318
     319Executes shell command feeding it second argument as input.
     320
    266321  throw:x
    267322
     
    269324
    270325As a special case an integer number in function position selects the
    271 Nth item of a sequence:
     326Nth item of a sequence, or the Nth tail of a sequence, if negative:
    272327
    273328  first_and_third = [1, 3]
    274329  first_and_third:<A, B, C, D>          --> <A, C>
     330
     331As a special case, the selector {{0}} always returns the empty sequence.
    275332
    276333
     
    295352evaluates an FP expression (and furter processes any following arguments).
    296353
     354  % fp -t ...
     355
     356will enable trace mode by instrumenting the generated code with
     357trace output code.
     358
     359  % fp -m ...
     360
     361will invoke a user-defined function called {{main}} after all files
     362have been processed with a sequence holding any command-line arguments.
     363The result should be an integer which will be treate as the exit status
     364of the program.
     365
     366Arguments following {{--}} will be ignored.
     367
    297368Any other argument will be treated as a FP source file and loaded/executed.
    298369
     
    307378 [procedure] (fp-parse PORT-OR-STRING)
    308379
    309 Takes FP sourcecode from a string or port and returns an s-expression
    310 representation of the parsed code.
     380Takes FP sourcecode from a string or port and returns a list of s-expressions
     381representating each toplevel form of the parsed code.
    311382
    312383=== fp->scheme
    313384
    314  [procedure] (fp->scheme CODE)
     385 [procedure] (fp->scheme CODE [TRACE])
    315386
    316387Returns a Scheme expression from translating the parsed FP code given
    317388in {{CODE}}. Evaluating the Scheme expression will run the originally
    318 parsed FP program.
     389parsed FP program. if {{TRACE}} is given and true, then the generated
     390Scheme code will be instrumented to display function entry- and exit
     391messages to stdout.
    319392
    320393
     
    371444  toplevel --> definition ["where" program "end"]
    372445           --> application
     446           --> sequence
    373447           --> verbatim
    374448 
    375449  application --> expression ":" object
    376450 
    377   definition --> identifier "==" expression
     451  definition --> head "==" expression
     452 
     453  head --> "(" id ")"
     454       --> id
    378455 
    379456  expression --> expr1 "->" expr1 ";" expression
     
    390467        --> "\" expr2
    391468        --> "@" expr2
     469        --> "*" expr2
    392470        --> "(" expression ")"
    393471        --> "bu" value object
     
    398476  value --> number
    399477        --> "~" object
     478        --> "`" object
    400479        --> identifier
    401480        --> "debug" atom
     
    408487        --> "{" pattern "," ... "," "..." "}"
    409488 
    410   pattern --> "#"
     489  pattern --> identifier "=" pattern
     490          --> identifier "="
     491          --> "#"
    411492          --> expression
    412493 
     
    425506 NB. stdlib.fp - Standard library
    426507 
    427  zero = eq[id, ~0].
     508 zero = `0.
    428509 succ = +[id, ~1].
    429510 pred = -[id, ~1].
    430511 heads = @1.
    431  tails = @tl.
     512 tails = @-1.
    432513 not = id -> ~F; ~T.
    433  
    434514 trans = null 1 -> []; apndl[heads, trans tails].
    435  compress = cat @listify trans.
    436  listify = 1 -> tl; [].
     515 compress = cat @listify trans where listify = 1 -> -1; [] end.
    437516 make = zero 1 -> []; apndl[2, make [pred 1, 2]].
    438  distl = trans[buildl, 2].
    439  buildl = make[length 2, 1].
    440  distr = trans[1, buildr].
    441  buildr = make[length 1, 2].
    442  and = null -> ~T; not 1 -> ~F; and tl.
    443  or = null -> ~F; 1 -> 1; or tl.
    444  e = or @eq distl.
     517 distl = trans[buildl, 2] where buildl = make[length 2, 1] end.
     518 distr = trans[1, buildr] where buildr = make[length 1, 2] end.
     519 and = null -> ~T; not 1 -> ~F; and -1.
     520 or = null -> ~F; 1 -> 1; or -1.
    445521 count = /+ @(eq -> ~1; ~2) distl.
    446  flatten = atom -> id; atom 1 -> apndl[1, flatten tl]; cat[flatten 1, flatten tl].
    447  take = null 2 -> []; zero 1 -> []; apndl[1 2, take[pred 1, tl 2]].
    448  drop = null 2 -> []; zero 1 -> 2; drop[pred 1, tl 2].
     522 flatten = atom -> id; atom 1 -> apndl[1, flatten -1]; cat[flatten 1, flatten -1].
     523 take = null 2 -> []; zero 1 -> []; apndl[1 2, take[pred 1, -1 2]].
     524 drop = null 2 -> []; zero 1 -> 2; drop[pred 1, -1 2].
    449525 pair = atom -> ~F; eq[length, ~2].
    450  ge = eq -> ~T; gt.
    451  le = eq -> ~T; lt.
     526 ge = eq | gt.
     527 le = eq | lt.
    452528 iota = zero -> []; apndr[iota pred, id].
    453 
     529 member = null 2 -> ~F; eq[1, 1 2] -> ~T; member[1, -1 2].
     530 merge = pack cat @unpack.
     531 n2a = pack unpack.
    454532
    455533 NB. tak.fp - the venerable "tak" benchmark
     
    458536 tak = not lt[2, 1] -> 3;
    459537       tak[tak[pred 1, 2, 3],
    460           tak[pred 2, 3, 1],
    461           tak[pred 3, 1, 2]].
     538          tak[pred 2, 3, 1],
     539          tak[pred 3, 1, 2]].
    462540 
    463541 tak:<18, 12, 6>
    464 
    465542
    466543 NB. palindrome.fp
     
    517594 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    518595
     596
    519597== Version History
    520598
     599; 2.1 : pattern bindings, bugfixes, extended selectors, removed {{tl}}
    521600; 2.0 : complete re-write, many simplifications and enhancements
    522601; 1.1 : Added some builtin functions, extended atom syntax
  • wiki/lua

    r4988 r5014  
    108108<table>
    109109<tr><th>Lua</th><th>Scheme</th></tr>
    110 <tr><td>nil</td><td>nil (a symbol)</td></tr>
     110<tr><td>nil</td><td>{{(void)}}</td></tr>
    111111<tr><td>number</td><td>number</td></tr>
    112112<tr><td>boolean</td><td>boolean</td></tr>
     
    123123<table>
    124124<tr><th>Scheme</th><th>Lua</th></tr>
    125 <tr><td>nil (the symbol)</td><td>nil</td></tr>
     125<tr><td>{{(void)}}</td><td>nil</td></tr>
    126126<tr><td>number</td><td>number</td></tr>
    127127<tr><td>boolean</td><td>boolean</td></tr>
     
    135135<tr><td>vector or a-list</td><td>table</td></tr>
    136136</table>
    137 
    138137
    139138== Authors
     
    168167  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    169168  THE SOFTWARE.
     169
     170== Version history
     171
     172; 0.2 : Lua {{nil}} is handled as {{(void)}} [suggested by John Cowan]
     173; 0.1 : initial release
Note: See TracChangeset for help on using the changeset viewer.