<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.11" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Omnigia: Scheme, web applications, tech</title>
	<link>http://www.omnigia.com/news</link>
	<description>Scheme, web applications, tech</description>
	<pubDate>Thu, 01 Jan 2009 11:26:17 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.11</generator>
	<language>en</language>
			<item>
		<title>CPSCM: interfacing Javascript and Scheme</title>
		<link>http://www.omnigia.com/news/2007/09/10/cpscm-native-calls/</link>
		<comments>http://www.omnigia.com/news/2007/09/10/cpscm-native-calls/#comments</comments>
		<pubDate>Tue, 11 Sep 2007 00:52:52 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<category>cpscm</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/09/10/cpscm-native-calls/</guid>
		<description><![CDATA[Calling Javascript from Scheme just got easier in CPSCM:
(define v 10)
(define (f x) (+ x v))
(%cpscm:native "alert (" v ")")
;; Can pass Scheme variables and computations
(%cpscm:native "alert (" (f 5) ")")
All string arguments to %cpscm:native are copied verbatim to the output. Inner computations are still compiled as any normal Scheme code, and their results are [...]]]></description>
			<content:encoded><![CDATA[<p>Calling Javascript from Scheme just got easier in <a href="http://www.omnigia.com/scheme/cpscm/home/">CPSCM</a>:</p>
<pre>(define v 10)
(define (f x) (+ x v))
(%cpscm:native "alert (" v ")")
;; Can pass Scheme variables and computations
(%cpscm:native "alert (" (f 5) ")")</pre>
<p>All string arguments to <kbd>%cpscm:native</kbd> are copied verbatim to the output. Inner computations are still compiled as any normal Scheme code, and their results are passed to the native call via temporary variables. Each native call must correspond to a single JS statement.</p>
<p>The old method was to provide a CPS wrapper with the correct mangled name, e.g. to create a function callable as <kbd>(fun 1 2)</kbd> from Scheme:</p>
<pre>var cpscmjsfun = cpscm__cpswrap (
  function fun (x, y) { return x + y; }
);</pre>
<p>This still works, of course (as demonstrated in the <a href="http://www.omnigia.com/scheme/cpscm/bs-demo/">DHTML bubble-sort</a> example), but the new method adds convenience.</p>
<p>The main reason for <kbd>native</kbd> is the anticipated Emacs Lisp backend: users will surely want to call a myriad of elisp functions from Scheme, and writing a CPS stub for each of them would be impractical.</p>
<p><strong>Note</strong>: the new code is in <a href="http://code.google.com/p/cpscm/source">SVN</a>, but the I haven&#8217;t updated the <a href="http://www.omnigia.com/scheme/cpscm/">online compiler</a> demo webapp yet.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/09/10/cpscm-native-calls/feed/</wfw:commentRss>
		</item>
		<item>
		<title>More on R6RS ratification</title>
		<link>http://www.omnigia.com/news/2007/08/27/r6rs-post-voting/</link>
		<comments>http://www.omnigia.com/news/2007/08/27/r6rs-post-voting/#comments</comments>
		<pubDate>Tue, 28 Aug 2007 04:24:57 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/08/27/r6rs-post-voting/</guid>
		<description><![CDATA[Given the preliminary results, it looks like R6RS will pass with a 66% margin (I predicted 70% a while ago). Strangely, official results haven&#8217;t been announced yet, in violation of the announced schedule. More strangely, everyone seems to be quiet on this delay; I suspect that the nays are hoping for some last-minute deliverance handed [...]]]></description>
			<content:encoded><![CDATA[<p>Given the <a href="http://www.r6rs.org/ratification/preliminary-results.html">preliminary results</a>, it looks like R6RS will pass with a 66% margin (I <a href="http://www.omnigia.com/news/2007/07/25/r6rs-guesstimate-ratification-result/">predicted 70%</a> a while ago). Strangely, official results haven&#8217;t been announced yet, in violation of the <a href="http://www.r6rs.org/ratification/">announced schedule</a>. More strangely, everyone seems to be quiet on this delay; I suspect that the nays are hoping for some last-minute deliverance handed down from the Steering Committee, but I&#8217;m surprised that the ayes aren&#8217;t becoming impatient at this point.</p>
<p>The comments section provides a glimpse into the disastrous effects of a biased electoral process that requires justification from dissenters, but not from approvers. While most of the nays provide a detailed analysis of the draft (usually acknowledging its virtues where applicable), the &#8220;yes&#8221; camp, where it bothers at all to comment, seems to employ a pretty lax standard (including a few pearls that I won&#8217;t quote in order not to offend the authors).</p>
<p>One comment that I found sad, yet funny states that &#8220;&#8230;Scheme needs a splash of &#8216;<a href="http://en.wikipedia.org/wiki/Worse_is_better">worse is better</a>&#8216; to move the language standard forward&#8221; &mdash; coming from a voter from New Jersey, no less.</p>
<p>On a personal note, I almost messed up my ballot. I sent my vote just before the deadline from my registered voter address, but I forgot to change the default <em>email-address</em> field of the ballot. My vote was rejected; I sent a corrected ballot, but only after the deadline, so it wouldn&#8217;t count. I e-mailed Alan Bawden, who mentioned that &#8220;I did fix a lot of people&#8217;s ballots in trivial ways&#8230; [including]&#8230; unbalanced parentheses, but I drew the line at actually altering people&#8217;s claimed identities&#8221; (the email-address field apparently taking precedence over the originating address in the email envelope). Luckily, my vote was accepted after a short back-and-forth.</p>
<p><strong>Update</strong>: the Steering Committee has ratified R5.97RS.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/08/27/r6rs-post-voting/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Emacs Lisp vs. Scheme: scoping and globals</title>
		<link>http://www.omnigia.com/news/2007/08/07/emacs-lisp-scoping-globals/</link>
		<comments>http://www.omnigia.com/news/2007/08/07/emacs-lisp-scoping-globals/#comments</comments>
		<pubDate>Tue, 07 Aug 2007 09:46:52 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<category>cpscm</category>

		<category>emacs</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/08/07/emacs-lisp-scoping-globals/</guid>
		<description><![CDATA[I&#8217;ve been considering an elisp back-end for CPSCM (so that we can program Emacs in R5RS Scheme). I thought the lack of lexical scoping would prove a major stumbling block, but in the end it turns out that Elisp will be somewhat easier to support than Common Lisp. Here are the twists and turns (to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been considering an elisp back-end for <a href="http://www.omnigia.com/scheme/cpscm/home/">CPSCM</a> (so that we can program Emacs in R5RS Scheme). I thought the lack of lexical scoping would prove a major stumbling block, but in the end it turns out that Elisp will be somewhat easier to support than Common Lisp. Here are the twists and turns (to evaluate Elisp code, go to the *scratch* buffer, paste the code and type <kbd>C-x C-e</kbd>):</p>
<ul>
<li>Elisp has dynamic scope by default:
<pre>(defun f () y)
(let ((y 10)) (f))  ;; 10
;; lambda arguments are also dynamic
(funcall (lambda (y) (f)) 11)  ;; 11
</pre>
</li>
<li>However, with <kbd>(require &apos;cl)</kbd> you get access to the (lexical-let &#8230;) macro, which does exactly what the name says (there is also a <kbd>lexical-let*</kbd>)</li>
<li>Using <kbd>lexical-let</kbd>, one can easily define <kbd>lexical-lambda</kbd> &mdash; here&#8217;s a simple version (optimized for minimal line lengths, not Lisp-ness)
<pre>(defmacro lexical-lambda (args &#038;rest body)
  (lexical-let* ((r '&amp;rest) (g (lambda (x) (if (eq x r) x (gensym))))
                 (gvars (mapcar g args))
                 (bnd (mapcar* #'list args gvars)))
    `(lambda ,gvars
       (lexical-let ,(delete-if (lambda (b) (eq (car b) r)) bnd)
         ,@body))))</pre>
</li>
</ul>
<p>OK, so we&#8217;ve played catch up with Common Lisp and managed to work around dynamic scoping; here&#8217;s the beautiful part:</p>
<ul>
<li>Elisp has sane(r) globals (from a Schemer&#8217;s POV, at least)</li>
</ul>
<p>To those who haven&#8217;t bashed their heads against this problem, Common Lisp&#8217;s &#8220;normal&#8221; way of declaring globals (<kbd>defvar</kbd> / <kbd>defparameter</kbd>) makes variables &#8220;pervasively special&#8221; (i.e. dynamic) &mdash; meaning that</p>
<pre>(defvar myvar 10)
(defun (f) myvar)
(defun g () (let ((myvar 1)) (f)))
(g)  ;; => 1, not 10</pre>
<p>This is not such a problem for Lisp, but what with Scheme being a Lisp-1, translation of global functions is problematic:</p>
<pre>(define (f x) x)  ;; Scheme
;; Lisp translation -- broken
(defvar f (lambda (x) x))</pre>
<p>There&#8217;s another standard-compliant way to simulate globals in Lisp (using symbol macros &mdash; search comp.lang.lisp for <kbd>deflex</kbd>); however this method requires you to define each global before referencing it, which would preclude mutually-recursive global functions:</p>
<pre>(deflex f (lambda (x) (funcall g (- x 1))))  ;; broken: g undefined
(deflex g (lambda (x) (if (> x 0) (funcall f x) 0)))</pre>
<p>There are other, more convoluted ways to implement &#8220;non-special&#8221; globals that have elicited endless (and inconclusive, as far as I could tell) threads on comp.lang.lisp, e.g. using <kbd>(locally (declare (special myvar)))</kbd>.  Finally, in many Lisp&apos;s one can simply use <kbd>(setq myvar &#8230;)</kbd> and at most get a warning, but this is not standards-compliant.</p>
<p>As luck would have it, <kbd>setq</kbd> globals work in Elisp too, and the manual seems to indicate that this is intended semantics, not accident. So this will save me the pain of working around Common Lisp&#8217;s &#8220;special&#8221; variable rules (I&#8217;ve never found a satisfactory solution), which is why I&#8217;m happy about Elisp.</p>
<p>Of course there are areas that need work, e.g. an easier &#8220;FFI&#8221; to access Elisp functions from Scheme (currently, one has to define a CPS-style wrapper in the back-end with the proper mangled name to make a function callable from CPSCM). But I find the prospect of programming Emacs in Scheme a pretty good motivation&#8230;
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/08/07/emacs-lisp-scoping-globals/feed/</wfw:commentRss>
		</item>
		<item>
		<title>R6RS ratification guesstimate results</title>
		<link>http://www.omnigia.com/news/2007/07/25/r6rs-guesstimate-ratification-result/</link>
		<comments>http://www.omnigia.com/news/2007/07/25/r6rs-guesstimate-ratification-result/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 17:42:56 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/07/25/r6rs-guesstimate-ratification-result/</guid>
		<description><![CDATA[I have gone through the R6RS electorate and tried to guess each elector&#8217;s vote based on their statement of interest. It&#8217;s been a fun exercise. Most of the statements give clear hints (such as sentences like &#8220;R6RS will&#8221; + positive action, or Felix&#8217;s all-caps screaming battle cry). Other statements offer partial clues (such as insisting [...]]]></description>
			<content:encoded><![CDATA[<p>I have gone through the <a href="http://www.r6rs.org/ratification/electorate.html">R6RS electorate</a> and tried to guess each elector&#8217;s vote based on their statement of interest. It&#8217;s been a fun exercise. Most of the statements give clear hints (such as sentences like &#8220;R6RS will&#8221; + positive action, or Felix&#8217;s all-caps <a href="http://www.r6rs.org/ratification/electorate.html#X41">screaming battle cry)</a>. Other statements offer partial clues (such as insisting on minimalism, or deploring the lack of a standard library). Yet others are completely opaque (some of them reading like CVs packed with the author&#8217;s numerous accomplishments), in which case I ignored them.</p>
<p>OK, the results: R6RS will probably <strong>pass</strong> with a <strong>70%</strong> approval rate.</p>
<p>I&#8217;d be interested in seeing any other predictions, especially if anybody has closely followed the r6rs-discuss list and has some time to burn. The official results are still more than a month off.</p>
<p>As most of you know, I strongly oppose R6RS. I will limit myself to asking those electors who complained about Scheme&#8217;s lack of structs and hash tables to go read the <a href="http://srfi.schemers.org/final-srfis.html">SRFI list</a> and pay attention to <a href="http://srfi.schemers.org/srfi-9/">SRFI-9</a> and <a href="http://srfi.schemers.org/srfi-69/">SRFI-69</a>. If your Scheme does not support one of the widespread SRFIs, you should ask your friendly implementor to reconsider. Also, the fact that R6RS brings some good things does not mean we need to compromise on the bad things; it&#8217;s always possible to restart the standardization effort and pick the gems out of the brown stuff.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/07/25/r6rs-guesstimate-ratification-result/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BurryFS: a file system written in Scheme</title>
		<link>http://www.omnigia.com/news/2007/06/06/duggfs-scheme-file-system/</link>
		<comments>http://www.omnigia.com/news/2007/06/06/duggfs-scheme-file-system/#comments</comments>
		<pubDate>Thu, 07 Jun 2007 04:27:12 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<category>linux</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/06/06/duggfs-scheme-file-system/</guid>
		<description><![CDATA[I&#8217;ve released BurryFS, a file system based on Fuse and implemented in Chicken Scheme. BurryFS interacts with Fuse (the userspace filesystem API — merged into the Linux kernel since 2.6.14) to organize Digg content as a file system. Since the Fuse API relies on callbacks to deliver file system requests, and Scheme functions cannot serve [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve released <a href="http://www.omnigia.com/scheme/burryfs/">BurryFS</a>, a file system based on Fuse and implemented in Chicken Scheme. BurryFS interacts with <a href="http://fuse.sourceforge.net">Fuse</a> (the userspace filesystem API — merged into the Linux kernel since 2.6.14) to organize Digg content as a file system. Since the Fuse API relies on callbacks to deliver file system requests, and Scheme functions cannot serve as C callbacks, I have written a simple inversion-of-control layer that serializes Fuse requests over an internal socket and waits for replies from Scheme. At the other end, Scheme sits in an event loop, unpacking requests, reading information via the Digg API and sending replies. Since Chicken implements cooperative (lightweight) threads, complete with TCP support, BurryFS performance should be high even with multiple parallel requests.</p>
<p>For more information (and downloads), see the <a href="http://www.omnigia.com/scheme/burryfs/">BurryFS homepage</a>.
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/06/06/duggfs-scheme-file-system/feed/</wfw:commentRss>
		</item>
		<item>
		<title>SWIG, Chicken and TinyCLOS</title>
		<link>http://www.omnigia.com/news/2007/05/20/swig-tinyclos-chicken/</link>
		<comments>http://www.omnigia.com/news/2007/05/20/swig-tinyclos-chicken/#comments</comments>
		<pubDate>Mon, 21 May 2007 01:33:56 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<category>oop</category>

		<category>ffi</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/05/20/swig-tinyclos-chicken/</guid>
		<description><![CDATA[Note: this is a fairly technical post; if you have no interest in FFI&#8217;s, you may still find the @ TinyCLOS macro useful.
When  dealing with large C libraries, SWIG (the wrapper generator) can be a mixed blessing. On the one hand, it&#8217;s a pleasure to work with wrapped C libraries from a dynamic language; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note:</strong> this is a fairly technical post; if you have no interest in FFI&#8217;s, you may still find the <a href="http://www.omnigia.com/news/2007/05/20/swig-tinyclos-chicken/#at-oop-macro-def"><code>@</code> TinyCLOS macro</a> useful.</p>
<p>When  dealing with large C libraries, SWIG (the wrapper generator) can be a mixed blessing. On the one hand, it&#8217;s a pleasure to work with wrapped C libraries from a dynamic language; on the other hand, generating the right wrappers can require significant time and effort, often with nothing to show for the plumbing work until the interface is complete.</p>
<p>In my case, the accessors and modifiers for C structures have been the most painful, initially at least. The library was full of complex, nested records of the following sort:</p>
<pre><code>struct msg {
  int op;
  struct {
    char *name;
    union {
      int start;
      char *dst;
    } args;
  } req;
}</code></pre>
<p>SWIG treats <code>struct msg</code> and its innards as separate objects; in Chicken, if you want to get to <code>msg.args.start</code>, you have to type a monstrosity like <code>(msg-req-args-start-get (msg-req-args-get (msg-req-get msg)))</code> (with bonus points for longer identifiers or deeper structures, of course).</p>
<p>The verbosity grows quadratically, and after a short while I started investigating the TinyCLOS mapping option. When invoked with the <kbd>-proxy</kbd> option, SWIG generates wrapper classes for C structures. This is enormously helpful: the previous incantation becomes <code>(slot-ref (slot-ref (slot-ref msg 'req) 'args) 'start)</code>, which in real cases is a lot shorter due to, um, linear verbosity. To modify fields, you use <code>slot-set!</code>.</p>
<p><a name="at-oop-macro-def"></a>This was still too much typing, so I introduced the <code>@</code> macro with which you can simply write (@ msg req args start), or (@ msg req name = &#8220;flush&#8221;):</p>
<pre><code> (define-syntax @
  (syntax-rules (=)
    ((_ o) o)
    ((_ o slot = v) (slot-set! o 'slot v))
    ((_ o slot . slots) (@ (slot-ref o 'slot) . slots))))
</code></pre>
<p>Finally, relief. In retrospect, I find it hard to believe that nobody solved this problem before; maybe there&#8217;s some &#8220;standard&#8221; macro for this purpose, but I haven&#8217;t found it.</p>
<p>This isn&#8217;t the end of the saga, though. As soon as I moved back from experimenting to the actual library, I was hailed by a salvo of errors indicating that SWIG/TinyCLOS has probably never been used for large applications. Specifically, SWIG translates a composite structure name such as <code>my_class</code> into either <code>&lt;my-class&gt;</code> or <code>&lt;my_class&gt;</code> depending on the context. Presumably, SWIG/TinyCLOS was only tested for the traditional OOP toy examples (<code>Shape</code>, <code>Pos</code> etc.)</p>
<p>Fortunately this is easily fixed with <code>perl -ne 'if (/&lt;.*&gt;/) { s/_/-/g; print } else { print }'</code>. Older versions of SWIG also add an unnecessary (and harmful) <code>(declare (uses tinyclos))</code> to the Scheme wrappers, but this is also easily excised.</p>
<p>The great news is that after all these machinations, as well as others not described here (involving callbacks and typemaps), SWIG/TinyCLOS seems to work without a hitch. I have had no problems using a large C library from a long-running Chicken program &mdash; writing the code was a lot of fun (compared to the SWIG saga), and, more importantly, there where no crashes. Has anybody else played with SWIG / Chicken / TinyCLOS?
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/05/20/swig-tinyclos-chicken/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Scheme object systems: POS</title>
		<link>http://www.omnigia.com/news/2007/04/30/scheme-object-systems-pos/</link>
		<comments>http://www.omnigia.com/news/2007/04/30/scheme-object-systems-pos/#comments</comments>
		<pubDate>Tue, 01 May 2007 03:35:42 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<category>oop</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/04/30/scheme-object-systems-pos/</guid>
		<description><![CDATA[I&#8217;m no OOP fan (much less a fan of single-dispatch OOP), but sometimes I miss the implicit lexical scope that single-dispatch provides for methods. Take something as simple as
class Rect {
  int top, left, bottom, right;
  int area () const {
    return (top - bottom) * (right - left);
  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m no OOP fan (much less a fan of single-dispatch OOP), but sometimes I miss the implicit lexical scope that single-dispatch provides for methods. Take something as simple as</p>
<pre><code>class Rect {
  int top, left, bottom, right;
  int area () const {
    return (top - bottom) * (right - left);
  }</code></pre>
<p><p>Most Scheme object systems (see for example the <a href="http://chicken.wiki.br/Eggs%20Unlimited#Object-oriented%20programming">Chicken OOP section</a>) turn the <code>area()</code> method body into something tedious along the lines of</p>
<pre><code>
(* (- (slot-ref self 'top) (slot-ref self 'bottom))
   (- (slot-ref self 'right) (slot-ref self 'left)))</code></pre>
<p>or, with objects implemented as closures,</p>
<pre><code>(* (- (self 'top) (self 'bottom) ...) ...)</pre>
<p></code></p>
<p>Until recently, I thought that short of codewalker-based macros, nothing could restore the terseness of single-dispatch methods.</p>
<p>Well, I&#8217;ve discovered Blake McBride&#8217;s <a href="http://algorithms.us/software/pos/index.html">POS</a> (portable object system). With POS, you can write</p>
<pre><code>(define-class Rect (ivars top left bottom right)
  (imeths
    (set-top! (self val) (set! top val)) ...
    (get-area (self) (* (- top bottom) (- right left)))))</code></pre>
<p>POS is a set of pure R5RS macros, and correctly interacts with other <code>syntax-rules</code> macros (e.g. macros can appear within method bodies). The trick is not only to represent the objects as closures, but to also expand method bodies inside the closure:</p>
<pre><code>;; not the actual POS expansion -- just an illustration
(define (make-rect)
  (let ((top #f) (left #f) (bottom #f) (right #f))
    (define self
      (lambda (meth-name . args)
        (case meth-name
          ((set-top!)
           (apply (lambda (self val) (set! top val))
                  (cons self args))) ...
          ((get-area)
           (apply (lambda (self)
                    (* (- top bottom) (- right left))
                  (cons self args)))))))

    self))</code></pre>
<p>This way, methods can access instance variables as simple literals. Each object is a dispatch function that closes over those variables.</p>
<p>POS is very useful, and I plan to add default getters and setters, as well as a way to convert between the closure representation and a-lists. This should help with persistence, among other things.</p>
<p>POS has a couple of extra features (inheritance, access to the parent object, class methods) but really is a light-weight system. The major downside is that methods (and instance variables) can no longer be added dynamically, since it&#8217;s impossible to inject code (or data) into a closure.</p>
<p><strong>Update</strong>: see the <a href="http://www.omnigia.com/news/2007/04/30/scheme-object-systems-pos#comments">comments </a> for yet another way of simulating an implicit &#8220;this&#8221; argument.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/04/30/scheme-object-systems-pos/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Scsh-regexp and SISCweb URLs</title>
		<link>http://www.omnigia.com/news/2007/02/21/scsh-regexp-match-cond-siscweb/</link>
		<comments>http://www.omnigia.com/news/2007/02/21/scsh-regexp-match-cond-siscweb/#comments</comments>
		<pubDate>Thu, 22 Feb 2007 01:52:51 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<category>scsh-regexp</category>

		<category>siscweb</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/02/21/scsh-regexp-match-cond-siscweb/</guid>
		<description><![CDATA[A new version of scsh-regexp, the SCSH regular expression API port to Chicken and SISC, is available. All API functions (except regexp manipulation such as uncase) are implemented, and there are a few bugfixes (including one that prevented compilation under SISC); there is still no SRE support.
For the moment, you will have to download this [...]]]></description>
			<content:encoded><![CDATA[<p>A new version of <a href="http://www.omnigia.com/scheme/scsh-regexp"><kbd>scsh-regexp</kbd></a>, the <a href="http://www.scsh.net/docu/html/man-Z-H-7.html#node_sec_6.4">SCSH regular expression API</a> port to Chicken and SISC, is available. All API functions (except regexp manipulation such as <code>uncase</code>) are implemented, and there are a few bugfixes (including one that prevented compilation under SISC); there is still no SRE support.</p>
<p>For the moment, you will have to <a href="http://code.google.com/p/scsh-regexp/source">download this release from Google Code</a>; the Chicken <a href="http://www.call-with-current-continuation.org/eggs/scsh-regexp.html">egg</a> should be updated to release 0.2 in a day or two.</p>
<p>If you&#8217;d like to see a port of <kbd>scsh-regexp</kbd> to your favorite Scheme, feel free to let me know (or contribute some code), as I am unlikely to make any further changes otherwise (save fixing potential bugs, should any surface). A Guile port would be the easiest.</p>
<p>And now, a fun exercise: scsh-regexp can handle pretty URLs in <a href="http://siscweb.sourceforge.net">SISCweb</a> applications. More specifically, we are going to sidestep the <code>publish</code> method by passing all requests to a single handler, which will discriminate between various URLs using the <code>match-cond</code> macro; here&#8217;s what a CMS application&#8217;s entry point might look like:</p>
<pre>(publish "/*" url-dispatcher)
(define (url-dispatcher request)
  (define path (request/get-path-info))
  (define (m url)
    (regexp-search (posix-string-&gt;regexp (string-append "^" url "$") path)))
  (match-cond
   ((m "/archives/([0-9]+)/([0-9]+)") (_ year month)
    (list-stories year month))
   ((m "/story/([^/]*)") (_ story-slug)
    (send-story story-slug))
   ...
   (else (send-404))))</pre>
<p><code>match-cond</code> is <a href="http://www.scsh.net/docu/html/man-Z-H-7.html#node_sec_6.4">described in the SCSH manual</a>, but briefly it goes through a list of clauses (just like <code>cond</code>), and when a match is found, it binds variables to the specified sub-matches (which correspond to paranthesized chunks in the regexp). Note that the URLs now contain regexp-style wildcards, instead of SISCweb&#8217;s usual servlet-style wildcards.</p>
<p>This approach can be made cleaner with macros, or, as I will describe in a future post, by using an upcoming feature of SISCweb 0.5 &mdash; <code>(publish "/some/url/.*" handler 'regexp)</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/02/21/scsh-regexp-match-cond-siscweb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sharing the same SISC (in SISCweb)</title>
		<link>http://www.omnigia.com/news/2007/01/06/sharing-sisc-in-siscweb/</link>
		<comments>http://www.omnigia.com/news/2007/01/06/sharing-sisc-in-siscweb/#comments</comments>
		<pubDate>Sat, 06 Jan 2007 11:40:58 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<category>siscweb</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2007/01/06/sharing-sisc-in-siscweb/</guid>
		<description><![CDATA[Over the past few days, I&#8217;ve been evaluating a new host (I&#8217;m looking at moving from shared hosting to a VPS). We have several applications running on SISCweb (the web framework that marries J2EE and SISC), and this blog runs on Wordpress, so there was the usual fun of configuring Apache, PHP, Tomcat and mod_proxy [...]]]></description>
			<content:encoded><![CDATA[<p>Over the past few days, I&#8217;ve been evaluating a new host (I&#8217;m looking at moving from shared hosting to a VPS). We have several applications running on <a href="http://siscweb.sourceforge.net">SISCweb</a> (the web framework that marries J2EE and <a href="http://sisc.sourceforge.net">SISC</a>), and this blog runs on Wordpress, so there was the usual fun of configuring Apache, PHP, Tomcat and mod_proxy / mod_jk. At the end of this, unsurprisingly, Tomcat used the largest single amount of memory, though not as much as some doomsayers predicted.</p>
<p>Seeing that memory is the main bottleneck, I set out to optimize the setup a bit. Previously, each web application ran its own private copy of SISC and SISCweb. The most obvious step is to share SISC between all web applications.</p>
<p>It turns out that SISC has the concept of running several Scheme &#8220;applications&#8221; in the same interpreter, with separate heaps and absolutely no interference. To do this, one must create multiple <a href="http://sisc.sourceforge.net/manual/html/ch08.html#appcontexts"><code>AppContext</code></a> instances and juggle them when calling Scheme from Java. This is a rather neat feature and one that I haven&#8217;t seen in other Schemes. It&#8217;s even possible to launch a new &#8220;application&#8221; from within Scheme.</p>
<p>When I tried to share SISC between multiple SISCweb instances, I ran into problems. It was clear that applications were stepping on each others&#8217; <code>AppContext</code>s and overwriting global SISCweb book-keeping structures. Looking at the code, I found that SISCweb was not designed with the possibility of a shared SISC interpreter in mind and relied on an implicit default AppContext whenever calling Scheme from a servlet.</p>
<p>To make a long story short, I made a few fixes and this is no longer the case. I can now run several web applications (even for different virtual hosts) in the same SISC instance. The patches will be in the official SISCweb repository as soon as Alessandro reviews and publishes them.</p>
<p>Oh yeah, I almost forgot. Happy New Year!
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2007/01/06/sharing-sisc-in-siscweb/feed/</wfw:commentRss>
		</item>
		<item>
		<title>CPSCM passes R5RS pitfalls</title>
		<link>http://www.omnigia.com/news/2006/12/23/cpscm-r5rs-pitfalls/</link>
		<comments>http://www.omnigia.com/news/2006/12/23/cpscm-r5rs-pitfalls/#comments</comments>
		<pubDate>Sat, 23 Dec 2006 08:53:08 +0000</pubDate>
		<dc:creator>Dan Muresan</dc:creator>
		
		<category>scheme</category>

		<category>cpscm</category>

		<guid isPermaLink="false">http://www.omnigia.com/news/2006/12/23/cpscm-r5rs-pitfalls/</guid>
		<description><![CDATA[After several fixes and tweaks, the CPSCM Javascript backend passes the R5RS Pitfalls test with a full score. The Lisp backend almost does, but since I decided to stick with Lisp&#8217;s convention of representing both false booleans and empty lists with NIL, it fails cases 5.1 - 5.3.
Additionally, I have tested the bubble sort example [...]]]></description>
			<content:encoded><![CDATA[<p>After several fixes and tweaks, the <a href="http://www.omnigia.com/scheme/cpscm/">CPSCM</a> Javascript backend passes the <a href="http://sisc.sourceforge.net/r5rs_pitfall.php">R5RS Pitfalls</a> test with a full score. The Lisp backend almost does, but since I decided to stick with Lisp&#8217;s convention of representing both false booleans and empty lists with <code>NIL</code>, it fails cases 5.1 - 5.3.</p>
<p>Additionally, I have tested the <a href="http://www.omnigia.com/scheme/cpscm/bs-demo/">bubble sort example</a> and the JS backend in general under IE 6, Firefox and Opera (the browsers I can access easily). I haven&#8217;t encountered any issues. If you are using IE 7 or Safari  and run into problems, please report. The <a href="http://www.omnigia.com/scheme/cpscm/">online compiler</a> now lets you execute compiled code directly in your browser, so it&#8217;s much easier to test than before.</p>
<p>On the negative side, some of you have noticed that the CPS code is more bloated than before. This is because I had to back out η-reduction for some cases, in the interest of correctness: <code>(lambda (x) (f x))</code> does not reduce to <code>f</code> automaticaly if <code>f</code> is mutable (and, of course, Scheme is not Erlang). The analysis module will catch up eventually&#8230;
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.omnigia.com/news/2006/12/23/cpscm-r5rs-pitfalls/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
