| 1 | ;;; Copyright 2007 William D Clinger. |
|---|
| 2 | ;;; |
|---|
| 3 | ;;; Permission to copy this software, in whole or in part, to use this |
|---|
| 4 | ;;; software for any lawful purpose, and to redistribute this software |
|---|
| 5 | ;;; is granted subject to the restriction that all copies made of this |
|---|
| 6 | ;;; software must include this copyright notice in full. |
|---|
| 7 | ;;; |
|---|
| 8 | ;;; I also request that you send me a copy of any improvements that you |
|---|
| 9 | ;;; make to this software so that they may be incorporated within it to |
|---|
| 10 | ;;; the benefit of the Scheme community. |
|---|
| 11 | ;;; |
|---|
| 12 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 13 | ;;; |
|---|
| 14 | ;;; The code in this file is derived from code that was placed |
|---|
| 15 | ;;; in the public domain by Aubrey Jaffer. William D Clinger |
|---|
| 16 | ;;; rewrote it for Larceny. This file follows Larceny's coding |
|---|
| 17 | ;;; guidelines, not SLIB's, because it is maintained by Larceny's |
|---|
| 18 | ;;; implementors as part of Larceny's code base. |
|---|
| 19 | ;;; |
|---|
| 20 | ;;; SRFI 96 (and SLIB in general) is deprecated in Larceny |
|---|
| 21 | ;;; because SLIB redefines require. That redefinition makes |
|---|
| 22 | ;;; SLIB incompatible with Larceny's support for other SRFIs. |
|---|
| 23 | ;;; |
|---|
| 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 25 | ;;; |
|---|
| 26 | ;;; $Id$ |
|---|
| 27 | ;;; |
|---|
| 28 | ;;; SRFI 96: SLIB Prerequisites |
|---|
| 29 | ;;; |
|---|
| 30 | ;;; See <http://srfi.schemers.org/srfi-96/> |
|---|
| 31 | |
|---|
| 32 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 33 | ;;; |
|---|
| 34 | ;;; Larceny-specific initialization. |
|---|
| 35 | ;;; |
|---|
| 36 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 37 | |
|---|
| 38 | (require 'srfi-0) ; cond-expand |
|---|
| 39 | |
|---|
| 40 | (require 'srfi-59) ; Vicinity |
|---|
| 41 | |
|---|
| 42 | (require 'defmacro) ; defmacro |
|---|
| 43 | |
|---|
| 44 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 45 | ;;; |
|---|
| 46 | ;;; Configuration |
|---|
| 47 | ;;; |
|---|
| 48 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 49 | |
|---|
| 50 | ;;; (software-type) should be set to the generic operating system type. |
|---|
| 51 | ;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported. |
|---|
| 52 | ;;; |
|---|
| 53 | ;;; Linux counts as 'unix, so Darwin probably does too. |
|---|
| 54 | |
|---|
| 55 | (define (software-type) |
|---|
| 56 | (let ((os (cdr (assq 'os-name (system-features))))) |
|---|
| 57 | (cond ((string=? os "Win32") |
|---|
| 58 | 'ms-dos) |
|---|
| 59 | (else 'unix)))) |
|---|
| 60 | |
|---|
| 61 | ;;; (scheme-implementation-type) should return the name of the scheme |
|---|
| 62 | ;;; implementation loading this file. |
|---|
| 63 | |
|---|
| 64 | (define (scheme-implementation-type) |
|---|
| 65 | (let ((arch (cdr (assq 'arch-name (system-features))))) |
|---|
| 66 | (cond ((string=? arch "Standard-C") |
|---|
| 67 | 'petit-larceny) |
|---|
| 68 | ((string=? arch "CLR") |
|---|
| 69 | 'common-larceny) |
|---|
| 70 | (else |
|---|
| 71 | 'larceny)))) |
|---|
| 72 | |
|---|
| 73 | ;;; (scheme-implementation-version) should return a string describing |
|---|
| 74 | ;;; the version the scheme implementation loading this file. |
|---|
| 75 | |
|---|
| 76 | (define (scheme-implementation-version) |
|---|
| 77 | (let ((features (system-features))) |
|---|
| 78 | (string-append (number->string |
|---|
| 79 | (cdr (assq 'larceny-major-version features))) |
|---|
| 80 | "." |
|---|
| 81 | (number->string |
|---|
| 82 | (cdr (assq 'larceny-minor-version features)))))) |
|---|
| 83 | |
|---|
| 84 | ;;; (scheme-implementation-home-page) should return a (string) URI |
|---|
| 85 | ;;; (Uniform Resource Identifier) for this scheme implementation's home |
|---|
| 86 | ;;; page; or false if there isn't one. |
|---|
| 87 | |
|---|
| 88 | (define (scheme-implementation-home-page) |
|---|
| 89 | "http://larceny.ccs.neu.edu/") |
|---|
| 90 | |
|---|
| 91 | ; FIXME: This should really be ".sch", but then SLIB wouldn't work. |
|---|
| 92 | |
|---|
| 93 | (define (scheme-file-suffix) ".scm") |
|---|
| 94 | |
|---|
| 95 | ;;; SLIB:FEATURES is a list of symbols naming the (SLIB) features |
|---|
| 96 | ;;; initially supported by this implementation. |
|---|
| 97 | |
|---|
| 98 | (define slib:features |
|---|
| 99 | '( |
|---|
| 100 | vicinity |
|---|
| 101 | |
|---|
| 102 | srfi-59 |
|---|
| 103 | |
|---|
| 104 | source ;can load scheme source files |
|---|
| 105 | ;(SLIB:LOAD-SOURCE "filename") |
|---|
| 106 | compiled ;can load compiled files |
|---|
| 107 | ;(SLIB:LOAD-COMPILED "filename") |
|---|
| 108 | ;;; object-hash ;has OBJECT-HASH and OBJECT-UNHASH |
|---|
| 109 | |
|---|
| 110 | full-continuation ;can return multiple times |
|---|
| 111 | |
|---|
| 112 | ieee-floating-point ;conforms to IEEE Standard 754-1985 |
|---|
| 113 | ;IEEE Standard for Binary |
|---|
| 114 | ;Floating-Point Arithmetic. |
|---|
| 115 | |
|---|
| 116 | ;;; sicp ;runs code from Structure and |
|---|
| 117 | ;Interpretation of Computer |
|---|
| 118 | ;Programs by Abelson and Sussman. |
|---|
| 119 | |
|---|
| 120 | ;;; ed ;(ED) is editor |
|---|
| 121 | |
|---|
| 122 | system ;posix (system <string>) |
|---|
| 123 | |
|---|
| 124 | getenv ;posix (getenv <string>) |
|---|
| 125 | |
|---|
| 126 | program-arguments ;returns list of strings (argv) |
|---|
| 127 | |
|---|
| 128 | current-time ;returns time in seconds since 1/1/1970 |
|---|
| 129 | |
|---|
| 130 | ;; Scheme report features |
|---|
| 131 | ;; R5RS-compliant implementations should provide all 9 features. |
|---|
| 132 | |
|---|
| 133 | r5rs ;conforms to |
|---|
| 134 | |
|---|
| 135 | eval ;R5RS two-argument eval |
|---|
| 136 | |
|---|
| 137 | values ;R5RS multiple values |
|---|
| 138 | |
|---|
| 139 | dynamic-wind ;R5RS dynamic-wind |
|---|
| 140 | |
|---|
| 141 | macro ;R5RS high level macros |
|---|
| 142 | |
|---|
| 143 | delay ;has DELAY and FORCE |
|---|
| 144 | |
|---|
| 145 | multiarg-apply ;APPLY can take more than 2 args. |
|---|
| 146 | |
|---|
| 147 | char-ready? ;has char-ready? |
|---|
| 148 | |
|---|
| 149 | rev4-optional-procedures ;LIST-TAIL, STRING-COPY, |
|---|
| 150 | ;STRING-FILL!, and VECTOR-FILL! |
|---|
| 151 | |
|---|
| 152 | ;; These four features are optional in both R4RS and R5RS |
|---|
| 153 | |
|---|
| 154 | multiarg/and- ;/ and - can take more than 2 args. |
|---|
| 155 | |
|---|
| 156 | rationalize |
|---|
| 157 | |
|---|
| 158 | ;;; transcript ;TRANSCRIPT-ON and TRANSCRIPT-OFF |
|---|
| 159 | |
|---|
| 160 | with-file ;has WITH-INPUT-FROM-FILE and |
|---|
| 161 | ;WITH-OUTPUT-TO-FILE |
|---|
| 162 | |
|---|
| 163 | ieee-p1178 ;conforms to |
|---|
| 164 | |
|---|
| 165 | ;;; r4rs ;conforms to (FIXME: not sure) |
|---|
| 166 | |
|---|
| 167 | ;;; r3rs ;conforms to (FIXME: not sure) |
|---|
| 168 | |
|---|
| 169 | ;;; rev2-procedures ;SUBSTRING-MOVE-LEFT!, |
|---|
| 170 | ;SUBSTRING-MOVE-RIGHT!, |
|---|
| 171 | ;SUBSTRING-FILL!, |
|---|
| 172 | ;STRING-NULL?, APPEND!, 1+, |
|---|
| 173 | ;-1+, <?, <=?, =?, >?, >=? |
|---|
| 174 | |
|---|
| 175 | ;; FIXME: The following features are not described by SRFI 96. |
|---|
| 176 | |
|---|
| 177 | ;; Other common features |
|---|
| 178 | |
|---|
| 179 | ;;; srfi ;srfi-0, COND-EXPAND finds all srfi-* |
|---|
| 180 | ; |
|---|
| 181 | ;not supported in Larceny because |
|---|
| 182 | ;SLIB's redefinition of require |
|---|
| 183 | ;will break srfi-0 and cond-expand |
|---|
| 184 | |
|---|
| 185 | defmacro ;has Common Lisp DEFMACRO |
|---|
| 186 | |
|---|
| 187 | record ;has user defined data structures |
|---|
| 188 | ;FIXME: ERR5RS/R6RS procedural API |
|---|
| 189 | |
|---|
| 190 | string-port ;has CALL-WITH-INPUT-STRING and |
|---|
| 191 | ;CALL-WITH-OUTPUT-STRING |
|---|
| 192 | |
|---|
| 193 | ;;; sort |
|---|
| 194 | |
|---|
| 195 | ;;; pretty-print |
|---|
| 196 | |
|---|
| 197 | ;;; object->string |
|---|
| 198 | |
|---|
| 199 | ;;; format ;Common-lisp output formatting |
|---|
| 200 | |
|---|
| 201 | ;;; trace ;has macros: TRACE and UNTRACE |
|---|
| 202 | |
|---|
| 203 | fluid-let |
|---|
| 204 | |
|---|
| 205 | ;; Implementation Specific features |
|---|
| 206 | |
|---|
| 207 | )) |
|---|
| 208 | |
|---|
| 209 | ;;; Implements SLIB's record package. |
|---|
| 210 | |
|---|
| 211 | (define record-modifier record-mutator) |
|---|
| 212 | |
|---|
| 213 | ;;; Implements SLIB's current-time package. |
|---|
| 214 | |
|---|
| 215 | (define (current-time) |
|---|
| 216 | (current-seconds)) |
|---|
| 217 | |
|---|
| 218 | (define (difftime t1 t0) (- t1 t0)) |
|---|
| 219 | |
|---|
| 220 | (define (offset-time t1 offset) (+ t1 offset)) |
|---|
| 221 | |
|---|
| 222 | ;;; most-positive-fixnum is used in modular.scm |
|---|
| 223 | ;;; |
|---|
| 224 | ;;; SRFI 96 says it must be within the range of exact integers |
|---|
| 225 | ;;; that may result from computing the length of a list, vector, |
|---|
| 226 | ;;; or string. |
|---|
| 227 | |
|---|
| 228 | (define most-positive-fixnum (- (expt 2 (- 24 2)) 3)) |
|---|
| 229 | |
|---|
| 230 | ;;; char-code-limit is one greater than the largest integer which can |
|---|
| 231 | ;;; be returned by char->integer. |
|---|
| 232 | |
|---|
| 233 | (define char-code-limit #x110000) |
|---|
| 234 | |
|---|
| 235 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 236 | ;;; |
|---|
| 237 | ;;; File-System |
|---|
| 238 | ;;; |
|---|
| 239 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 240 | |
|---|
| 241 | ;;; with-load-pathname is defined in srfi-59.sch |
|---|
| 242 | |
|---|
| 243 | ;;; (tmpnam) makes a temporary file name. |
|---|
| 244 | |
|---|
| 245 | (define tmpnam |
|---|
| 246 | (let ((cntr 100)) |
|---|
| 247 | (lambda () |
|---|
| 248 | (set! cntr (+ 1 cntr)) |
|---|
| 249 | (string-append "slib_" (number->string cntr))))) |
|---|
| 250 | |
|---|
| 251 | ;;; file-exists? is predefined by Larceny |
|---|
| 252 | |
|---|
| 253 | ;;; delete-file is predefined by Larceny |
|---|
| 254 | |
|---|
| 255 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 256 | ;;; |
|---|
| 257 | ;;; Input/Output |
|---|
| 258 | ;;; |
|---|
| 259 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 260 | |
|---|
| 261 | (define (open-file filename modes) |
|---|
| 262 | (case modes |
|---|
| 263 | ((r) (open-input-file filename)) |
|---|
| 264 | ((rb) (open-file-input-port filename)) |
|---|
| 265 | ((w) (open-output-file filename)) |
|---|
| 266 | ((wb) (open-file-output-port filename)) |
|---|
| 267 | (else (slib:error 'open-file 'mode? modes)))) |
|---|
| 268 | |
|---|
| 269 | ;;; port? is predefined by Larceny |
|---|
| 270 | |
|---|
| 271 | ;;; close-port is predefined by Larceny |
|---|
| 272 | |
|---|
| 273 | (define (call-with-open-ports proc0 . ports0) |
|---|
| 274 | (define proc (car ports)) |
|---|
| 275 | (cond ((procedure? proc) (set! ports (cdr ports))) |
|---|
| 276 | (else (set! ports (reverse ports)) |
|---|
| 277 | (set! proc (car ports)) |
|---|
| 278 | (set! ports (reverse (cdr ports))))) |
|---|
| 279 | (let ((ans (apply proc ports))) |
|---|
| 280 | (for-each close-port ports) |
|---|
| 281 | ans)) |
|---|
| 282 | |
|---|
| 283 | ;;; current-error-port is predefined by Larceny |
|---|
| 284 | ;;; beginning with v0.96 |
|---|
| 285 | |
|---|
| 286 | (define current-error-port |
|---|
| 287 | (if (string<=? (scheme-implementation-version) "0.95") |
|---|
| 288 | current-output-port |
|---|
| 289 | current-error-port)) |
|---|
| 290 | |
|---|
| 291 | ;;; force-output flushes any pending output on optional arg output port |
|---|
| 292 | |
|---|
| 293 | (define (force-output . args) |
|---|
| 294 | (if (null? args) |
|---|
| 295 | (flush-output-port (current-output-port)) |
|---|
| 296 | (for-each flush-output-port args))) |
|---|
| 297 | |
|---|
| 298 | ;;; (file-position <port> . <k>) |
|---|
| 299 | |
|---|
| 300 | (define (file-position . args) |
|---|
| 301 | (define (complain) |
|---|
| 302 | (assertion-violation 'file-position "illegal arguments" args)) |
|---|
| 303 | (cond ((null? args) |
|---|
| 304 | (complain)) |
|---|
| 305 | ((null? (cdr args)) |
|---|
| 306 | (let ((p (car args))) |
|---|
| 307 | (if (port-has-port-position? p) |
|---|
| 308 | (port-position p) |
|---|
| 309 | #f))) |
|---|
| 310 | ((null? (cddr args)) |
|---|
| 311 | (let ((p (car args)) |
|---|
| 312 | (k (cadr args))) |
|---|
| 313 | (if (port-has-set-port-position!? p) |
|---|
| 314 | (set-port-position! p k)) |
|---|
| 315 | #f)) |
|---|
| 316 | (else |
|---|
| 317 | (complain)))) |
|---|
| 318 | |
|---|
| 319 | ;;; (output-port-width <port>) |
|---|
| 320 | |
|---|
| 321 | (define (output-port-width . arg) 79) |
|---|
| 322 | |
|---|
| 323 | ;;; (output-port-height <port>) |
|---|
| 324 | |
|---|
| 325 | (define (output-port-height . arg) 24) |
|---|
| 326 | |
|---|
| 327 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 328 | ;;; |
|---|
| 329 | ;;; Defmacro |
|---|
| 330 | ;;; |
|---|
| 331 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 332 | |
|---|
| 333 | ;;; FIXME: |
|---|
| 334 | ;;; SLIB appears to need these things, even though SRFI 96 doesn't |
|---|
| 335 | ;;; specify them or indicate that implementations of SRFI 96 must |
|---|
| 336 | ;;; define them. |
|---|
| 337 | |
|---|
| 338 | (define (macro:eval . args) (apply slib:eval args)) |
|---|
| 339 | |
|---|
| 340 | (define (macro:load . args) (apply load args)) |
|---|
| 341 | |
|---|
| 342 | ;;; |
|---|
| 343 | |
|---|
| 344 | ;;; Public stuff. |
|---|
| 345 | |
|---|
| 346 | ;;; defmacro is defined by Larceny's defmacro package |
|---|
| 347 | |
|---|
| 348 | (define gentemp |
|---|
| 349 | (let ((*gensym-counter* -1)) |
|---|
| 350 | (lambda () |
|---|
| 351 | (set! *gensym-counter* (+ *gensym-counter* 1)) |
|---|
| 352 | (string->symbol |
|---|
| 353 | (string-append "slib:G" (number->string *gensym-counter*)))))) |
|---|
| 354 | |
|---|
| 355 | ;;; FIXME: With Larceny's implementation of defmacro, |
|---|
| 356 | ;;; macros that have been defined using defmacro are |
|---|
| 357 | ;;; indistinguishable from macros that have been defined |
|---|
| 358 | ;;; using Larceny's low-level explicit-renaming facility. |
|---|
| 359 | ;;; |
|---|
| 360 | ;;; For SLIB, however, it's probably good enough to pretend |
|---|
| 361 | ;;; that all low-level macros were defined using defmacro. |
|---|
| 362 | ;;; |
|---|
| 363 | ;;; FIXME: This is terribly representation-dependent, |
|---|
| 364 | ;;; and will break when (not if) the representation of |
|---|
| 365 | ;;; macros changes. |
|---|
| 366 | |
|---|
| 367 | (define (defmacro? m) |
|---|
| 368 | (let ((x (environment-get-macro (interaction-environment) m))) |
|---|
| 369 | (and x (procedure? (cadr x))))) |
|---|
| 370 | |
|---|
| 371 | (define (defmacro:eval x) (slib:eval (defmacro:expand* x))) |
|---|
| 372 | |
|---|
| 373 | ;;; FIXME: The specification of defmacro:eval says it |
|---|
| 374 | ;;; has to use slib:eval, but the definition of |
|---|
| 375 | ;;; defmacro:load says no such thing. |
|---|
| 376 | |
|---|
| 377 | (define defmacro:load load) |
|---|
| 378 | |
|---|
| 379 | ;;; FIXME: There doesn't seem to be any analogue of |
|---|
| 380 | ;;; macroexpand-1 in Larceny. |
|---|
| 381 | |
|---|
| 382 | (define (macroexpand-1 e) (macro-expand e)) |
|---|
| 383 | |
|---|
| 384 | (define macroexpand macro-expand) |
|---|
| 385 | |
|---|
| 386 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 387 | ;;; |
|---|
| 388 | ;;; R5RS Macros |
|---|
| 389 | ;;; |
|---|
| 390 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 391 | |
|---|
| 392 | (define macro:expand macro-expand) |
|---|
| 393 | |
|---|
| 394 | (define (macro:eval exp) |
|---|
| 395 | (eval exp (interaction-environment))) |
|---|
| 396 | |
|---|
| 397 | (define macro:load load) |
|---|
| 398 | |
|---|
| 399 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 400 | ;;; |
|---|
| 401 | ;;; System |
|---|
| 402 | ;;; |
|---|
| 403 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 404 | |
|---|
| 405 | (define slib:load-source load) |
|---|
| 406 | |
|---|
| 407 | (define slib:load-compiled load) |
|---|
| 408 | |
|---|
| 409 | (define slib:load load) |
|---|
| 410 | |
|---|
| 411 | ;;; SLIB:EVAL is single argument eval using the top-level (user) environment. |
|---|
| 412 | |
|---|
| 413 | (define (slib:eval x) |
|---|
| 414 | (eval x (interaction-environment))) |
|---|
| 415 | |
|---|
| 416 | (define (slib:eval-load filename eval) |
|---|
| 417 | (if (file-exists? filename) |
|---|
| 418 | (call-with-input-file |
|---|
| 419 | filename |
|---|
| 420 | (lambda (p) |
|---|
| 421 | (do ((x (read p) (read p))) |
|---|
| 422 | ((eof-object? x)) |
|---|
| 423 | (eval x)))))) |
|---|
| 424 | |
|---|
| 425 | (define slib:warn |
|---|
| 426 | (lambda args |
|---|
| 427 | (let ((cep (current-error-port))) |
|---|
| 428 | (display "SLIB:warn: " cep) |
|---|
| 429 | (for-each (lambda (x) (display #\space cep) (write x cep)) args)))) |
|---|
| 430 | |
|---|
| 431 | (define slib:error |
|---|
| 432 | (lambda args |
|---|
| 433 | (error #f "SLIB:error:" args))) |
|---|
| 434 | |
|---|
| 435 | (define slib:exit |
|---|
| 436 | (lambda args |
|---|
| 437 | (apply exit args))) |
|---|
| 438 | |
|---|
| 439 | ;;; FIXME |
|---|
| 440 | |
|---|
| 441 | (define (browse-url url) |
|---|
| 442 | (slib:warn "Larceny provides no browser") |
|---|
| 443 | #f) |
|---|
| 444 | |
|---|
| 445 | ;;; getenv and system are predefined by Larceny. |
|---|
| 446 | |
|---|
| 447 | (define (program-arguments) |
|---|
| 448 | (cons "larceny" (vector->list (command-line-arguments)))) |
|---|
| 449 | |
|---|
| 450 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 451 | ;;; |
|---|
| 452 | ;;; Miscellany |
|---|
| 453 | ;;; |
|---|
| 454 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 455 | |
|---|
| 456 | (define (identity x) x) |
|---|
| 457 | |
|---|
| 458 | (define slib:tab #\tab) |
|---|
| 459 | |
|---|
| 460 | (define slib:form-feed #\page) |
|---|
| 461 | |
|---|
| 462 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 463 | ;;; |
|---|
| 464 | ;;; Mutual Exclusion |
|---|
| 465 | ;;; |
|---|
| 466 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 467 | |
|---|
| 468 | (define (make-exchanger obj) |
|---|
| 469 | (let ((v (vector obj))) |
|---|
| 470 | (define (exchange new) |
|---|
| 471 | (let* ((old0 (vector-ref v 0)) |
|---|
| 472 | (old1 (vector-like-cas! v 0 old0 new))) |
|---|
| 473 | (if (eq? old0 old1) |
|---|
| 474 | old0 |
|---|
| 475 | (exchange new)))) |
|---|
| 476 | (lambda (new) (exchange new)))) |
|---|
| 477 | |
|---|
| 478 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 479 | ;;; |
|---|
| 480 | ;;; Legacy |
|---|
| 481 | ;;; |
|---|
| 482 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 483 | |
|---|
| 484 | (define t #t) |
|---|
| 485 | |
|---|
| 486 | (define nil #f) |
|---|
| 487 | |
|---|
| 488 | ;;; last-pair is predefined by Larceny |
|---|
| 489 | |
|---|
| 490 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 491 | ;;; |
|---|
| 492 | ;;; Deployment |
|---|
| 493 | ;;; |
|---|
| 494 | ;;; In Larceny, the SLIB distribution usually goes in lib/SLIB. |
|---|
| 495 | ;;; If it is placed somewhere else, then the location of SLIB |
|---|
| 496 | ;;; in the startup.sch file should be edited. Alternatively, |
|---|
| 497 | ;;; users of SLIB could just use the -path command-line option |
|---|
| 498 | ;;; to specify the location of SLIB. |
|---|
| 499 | ;;; |
|---|
| 500 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
|---|
| 501 | |
|---|
| 502 | ;;; FIXME: the following line redefines Larceny's require |
|---|
| 503 | ;;; procedure, which breaks Larceny's support for SRFIs, |
|---|
| 504 | ;;; cond-expand, ERR5RS, R6RS, and a lot of other things. |
|---|
| 505 | ;;; |
|---|
| 506 | ;;; Workaround: Don't require srfi-96 until all other |
|---|
| 507 | ;;; libraries that your program needs have been required. |
|---|
| 508 | |
|---|
| 509 | (slib:load (in-vicinity (library-vicinity) "require")) |
|---|
| 510 | |
|---|
| 511 | ; eof |
|---|