[Prev][Next][Index][Thread]

Re: Dylan Features



Enter your Notes name here <firstname_lastname@lotus.com> wrote:
> I seem to remember that back in the old days, when Dylan had
> Scheme-style syntax, that you could add slots to individual instances.
> Can you do this in the current version of Dylan? 

No -- it was probably too hard to implement efficiently. 

> Also, does Dylan have something like call/cc from Scheme? Thanks!

Sort of. Dylan has first-class continuations, but they have dynamic
extent rather than unlimited extent like in Scheme. You can create
them with the block statement:

  block(dynamic-continuation)
    // dynamic-continuation is a bound to a first-class continuation
    // function, but it is only legal to invoke it within the scope of
    // this block. Attempts to call it outside the block will return an
    // error. 
  end;

An examples of use:

  // This will search an unsorted binary tree for a value, and
  // abort the computation to return #t if it finds it:
  
  define method find-symbol(tree, id) => (answer :: <boolean>);
    local method find-cc(tree, id, k)
  	    select (tree by instance?)
  	      <node>
  		=> find-cc(tree.left, id, ) | find-cc(tree.right, id, k);
  	      <leaf>
  		=> if (id = tree.key)
  		     k(#t)
  		   else
  		     #f
  		   end if;
  	    end select;
  	  end method find-cc;
    block(return)
      find-cc(tree, id, return)
    end block;
  end method find-symbol;

Hope this helps.


Neel



References: