On Feb 23, 2009, at 11:13 PM, Derick Eddington wrote:
On Mon, 2009-02-23 at 21:54 +0200, leppie wrote:
From: (import (psyntax system $all))

read-annotated
annotation?
annotation-expression
annotation-source
annotation-stripped

Those are also exported from (ikarus).

Correct.  I'd rather people not use any system libraries
since these are there for system purposes and not for
general consumption.  The (ikarus) bindings are more
stable, but you should, in general, use the documented
features only.


(define x (read-annotated (open-string-input-port "blah")))
x
#["annotation" blah ("*string-input-port*" . 1) blah]
(annotation-expression x)
blah
(annotation-source x)
("*string-input-port*" . 1)
(annotation-stripped x)
blah


I'm not sure what the difference between the expression and stripped
fields is.  You could probably infer what it is by searching for how
they're used in Ikarus.

annotation-expression returns the expression part of an
annotation by stripping only (the immediate) one level
of annotations and keeping the inner annotations as they
are.  annotation-stripped returns the expressions after
removing all annotations.  So, you can think of
annotation-stripped as the "deep" or "*" version of
annotation-expression, but the current implementation
does not do any traversal at all.  The annotation object
has three fields: expression, source, and stripped, and
all three procedures are simple accessors to these fields.


> (define x
    (read-annotated
      (open-string-input-port
        "(hello world)")))
> x
#["annotation"
   (#["annotation" hello ("*string-input-port*" . 2) hello]
    #["annotation" world ("*string-input-port*" . 8) world])
  ("*string-input-port*" . 1)
  (hello world)]

> (annotation-expression x)
(#["annotation" hello ("*string-input-port*" . 2) hello]
 #["annotation" world ("*string-input-port*" . 8) world])

> (annotation-source x)
("*string-input-port*" . 1)

> (annotation-stripped x)
(hello world)

You might not want to build on these too seriously unless
Aziz tells you it's a stable interface.

Relying on annotation-source returning a pair of port-name
and character position is likely to change.  Is it important
to know the source position, or is it only needed in order
to construct a proper condition object?

Also, I know that all of psyntax-based schemes, chez, and
plt have the source information organized in more-or-less
the same way.  Does anyone who is familiar with other
systems confirm/deny that they utilize similar structure?
(this is a good candidate for a srfi since it has many
utilities)

Aziz,,,



Reply via email to