4 ms·
I'm new to LISP (only a little over a year) but I already feel the same way about R*RS as I do about ANSI SQL: You'd be crazy to target it instead of making the
by kogir 13y ago
I'm new to LISP (only a little over a year) but I already feel the same way about R*RS as I do about ANSI SQL: You'd be crazy to target it instead of making the most of the runtime you've chosen.
Has anyone here ever deployed to multiple runtimes? Why did you do it? I'm curious.
- jchan 13y agoAFAIK most of the major Scheme implementors are involved in the development of the Revised Reports, and most implementations implement the report to such an extent that libraries can and are written for multiple runtime with little modification (many SRFIs specify standard Scheme implementations of the APIs they suggest). SRFIs (which specify additional functionality like binary io and more complex list functions etc.) are more pick and choose, but the ones that are implemented are pretty standardized. (srfi 1 for lists, srfi 13 for strings, etc.) I think there was a bit of disagreement over R6RS in that many implementors felt it was too bulky and un Scheme, which is why there is a R7RS small and a R7RS large. Because of that some implementations decided to stay on R5RS and extend it with sometimes de facto standards. I think most people will write for only one scheme implementation if it is for a project and not a library, though. Racket for example seems like a sort of extended scheme, though they still participate in the standards process. Libraries supply notes on how to adapt them to various implementations and it is normally trivial to do so as long as the required SRFIs or extensions are available in some form.
- waterhouse 13y agoSince RnRS doesn't prescribe any graphics library procedures, or any foreign function interface that could be used to link to C libraries, it is impossible to write a pure RnRS program that draws to the screen. (Likewise if you replace "graphics" with "audio", "GPU operations", or anything else that isn't provided by the standard.) If you want to write a graphical program in Scheme, you must work with a particular implementation. Either one that provides a graphics library itself, or one that provides a foreign function interface, which you use to load a C graphics library. If you want your program to run on multiple implementations, then it must somehow use implementation X's FFI when running on implementation X, but use implementation Y's FFI when running on implementation Y. (Either that, or you use a uniform interface to someone's "multi-platform FFI" library, which itself will run different code depending on what implementation it's on.) Therefore, if you hope to write multi-platform code, your code or a library you use must detect what implementation it's on, and execute different code depending. Ideally, it would even execute code that says "Sorry, don't know about this implementation's FFI" when appropriate. Incidentally, Common Lisp provides the #+ and #- notations, which provide for code that runs conditionally on whether the implementation defines a certain symbol. And incidentally, there is a Common Lisp "Common Foreign Function Interface" library that works in exactly this way: #-(or openmcl mcl sbcl cmu scl clisp lispworks ecl allegro cormanlisp abcl) (error "Sorry, this Lisp is not yet supported. Patches welcome!") ... (#+openmcl (:file "cffi-openmcl") #+mcl (:file "cffi-mcl") #+sbcl (:file "cffi-sbcl") #+cmu (:file "cffi-cmucl") #+scl (:file "cffi-scl") #+clisp (:file "cffi-clisp") --cffi.asd As it happens, a new item in R7RS-small is "cond-expand", which is equivalent to #+ and #-. Implementations will probably provide their own names as a feature. Thus, you could write multiple-platform FFI code that looked something like this... (cond-expand (chicken load-foreign-library) (racket get-ffi-lib) ...) So, as of now, it would be possible for someone to write a multi-platform Scheme FFI library, which would use standard features of R7RS to select the correct interfaces to foreign libraries on supported Scheme implementations, and would gracefully error out on unsupported R7RS Scheme implementations. Then you could use this to write R7RS code that did graphical stuff and would work on multiple implementations. I don't know of anyone who has done this so far. (There are multiple-platform graphics programs written in Common Lisp that use CFFI; they can generally be installed with Quicklisp. This appears to show proof of concept.)
- JoachimSchipper 13y agoE.g. libraries that can be implemented in pure Scheme should arguably target R*RS rather than any particular implementation, to save on reimplementation efforts.