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

Re: Diversity - existence, value, and pursuit.



Michael Vanier wrote:

> best:  After an initial period of confusion, a few "canonical" syntaxes
>        develop which are each adopted by a large pool of users (e.g. scheme
>        syntax, pythonish syntax, c-ish, etc.).  All can be translated into
>        each other, and the syntaxes all are translated into some base
>        representation (e.g. S-expressions).  Projects can even mix modules
>        using different syntaxes, since the underlying semantics are the
>        same.

I believe the Scheme 48 module system permitted something like this.

Last year, Robby Findler added some hooks to DrScheme, and Paul
Fernhout wrote an indentation-based reader for Scheme.  He even got
some help from DrScheme's source correlating error reporting subsystem
to display errors.  This code likely hasn't been ported to DrScheme
v200, but I imagine that it wouldn't take much work to write something
like this.  I think these examples he posted are all legal fragments
he could handle (looks like there's some missing lib code, though):

----------

define
 foo x 
 let
  (y 10) (z 20) 
  print (* x y z) 

----------

define
 stack%
 class*
  object%
  (stack<%>) 
  ()
  private (stack null) 
  public
   name 'stack 
   push!
    lambda
     (v) 
     set! stack (cons v stack) 
   pop!
    lambda
     ()
     let
      ((v (car stack))) 
      set! stack (cdr stack) 
      v
   empty? (lambda () (null? stack)) 
   print-name
    lambda () (display name) (newline) 
  sequence (super-init) 

----------

defmethod
 update-records-from-instance
 (obj standard-db-object) &key (database *default-database*) 
 labels
  .
   slot-storedp
    (slot) 
    and
     member
      view-class-slot-db-kind slot 
      quote (:base :key) 
     mop::slot-boundp obj (mop::slot-definition-name slot) 
   slot-value-list
    (slot) 
    let
     ((value (slot-value obj (mop:slot-definition-name slot)))) 
     check-slot-type slot value 
     list
      sql-expression :attribute (view-class-slot-column slot) 
      db-value-from-slot slot value database 
  let*
   (view-class (class-of obj))
    view-class-table (view-table view-class) 
    slots
     remove-if-not 'slot-storedp (mop::class-slots view-class) 
    record-values (mapcar 'slot-value-list slots) 
   if (not record-values) (error "No settable slots.") 
   if
    view-database obj 
    update-records
     :table
     sql-expression :table view-class-table 
     :av-pairs
     record-values
     :where
     key-qualifier-for-instance obj :database database 
     :database
     view-database obj 
    progn
     insert-records
      :into
      sql-expression :table view-class-table 
      :av-pairs
      record-values
      :database
      database
     setf (view-database obj) database 
   t

----------

Shriram