Eduardo Cavazos | 1 Dec 2010 02:37
Picon

Top-level R6RS libraries

Hello,

If I put this R6RS library:

#!r6rs

(library (xyz abc)

  (export abc)

  (import (rnrs))

  (define abc 10))

in the file '~/scheme/xyz/abc.sls', Racket can find it.

However, if I put this library:

#!r6rs

(library (abc)

  (export abc)

  (import (rnrs))

  (define abc 10))

in the file '~/scheme/abc.sls', Racket doesn't seem to find it.

(Continue reading)

Hendrik Boom | 1 Dec 2010 03:39

Re: syntax, differently

On Tue, Nov 30, 2010 at 05:56:08PM -0600, Eduardo Cavazos wrote:
> Hi Matthias,
> 
> On Wed, 2010-08-18 at 10:52 -0400, Matthias Felleisen wrote:
> 
> > Eduardo is providing a macro that helps you abbreviate complex 
> > selector and mutator chains. The BENFIT you get is that instead
> > of writing 
> > 
> >   (posn-x (bird-posn (sky-bird (world-sky some-world))))
> > 
> > you can write -- in Racket -- 
> > 
> >   some-world.sky.bird.posn.x 
> > 
> > and make Racket programs look as short as C program selectors 
> > or Java dots or Javascript dots etc. 
> > 
> > The PRICE you pay is that you annotate variables and fields
> > with struct information. That is, you have to say somewhere that 
> > some-world is a variable that always stands for a world struct. 
> > And the sky field in world has to come with information that it 
> > always is a sky-struct. And so on. 

This looks as if it might be a better match with Typed Scheme/Racket.

-- hendrik

Richard Lawrence | 1 Dec 2010 04:07
Picon
Favicon

Re: Exploratory programming?

Hi Matthias,

> It isn't clear to me whether you have tried 
>
>   > (help "lambda") 
>
> in your emacs repl. If so, do you object to the browser coming up with intensively hyperlinked
documentation? Or do you not like the format? 

(Evidently I had not.  Now that is embarrassing.  I could swear I had
tried it before, maybe back when I just had the PLT Scheme packages
installed, with only an unbound name error as the result...Is this
perhaps a recent addition?  Or could I have inadvertently done some
configuration that makes "help" available in my Racket REPL when it
wasn't before?)

> Let us know what's wrong with that. 

There's nothing wrong with it; it's great!  Thanks for pointing this out
to me.

If I had my druthers, the help function would also be a tool for
introspection.  (Is there another function designed for this?  (help
"introspection") doesn't turn up any results... :) [See examples below]
But I realize that this may be asking for precisely the kind of REPL
interaction that Racket has consciously chosen to avoid.

> I have done a lot of bottom up programming in Emacs (Scheme and Lisp) and I still do in DrRacket. But I learned
that bottom-up programming is the norm and that what makes it successful is some amount of top-down
planning. If you meet somewhere in the middle and explore from there, you can grow into a
(Continue reading)

Matthias Felleisen | 1 Dec 2010 04:21
Favicon

Re: Exploratory programming?


On Nov 30, 2010, at 10:07 PM, Richard Lawrence wrote:

> If I had my druthers, the help function would also be a tool for
> introspection. 

Programs are either throw away or deserve a full-fledged, indexed documentation. 

Is Python's documentation properly (scoped) hyperlinked? 

-- Matthias

Nadeem Abdul Hamid | 1 Dec 2010 04:32
Picon
Favicon

equal? with classes and contracts

I think something like this has come up before but I can't find the
thread. Given:

(define A%
  (class object% (inspect #f) (super-new)))
(define/contract B%
  (class/c )
  (class object% (inspect #f) (super-new)))

How can I get around the problem that:
    (equal? (new A%) (new A%))
but
    (not (equal? (new B%) (new B%)))

I want to be able to compare objects of the same contracted class for
structural equality.

And another question: is there something similar to struct-copy for
objects? Or a way to easily clone them?

--- nadeem
Eli Barzilay | 1 Dec 2010 07:20
Favicon
Gravatar

Re: Exploratory programming?

9 hours ago, prad wrote:
> 
> i like the incremental search system for the documentation, though
> it doesn't have an apropos feature like emacs.

The incremental search can be used more effectively as a kind of
apropos if you limit the search to a specific module, for example
searching for "cons M:racket" will show you only matches that are
bindings from a module that has "racket" in its name.

But if you want a more traditional repl apropos feature, see my
interactive hack -- it has an ,apropos command.

Three hours ago, Richard Lawrence wrote:
> > It isn't clear to me whether you have tried 
> >
> >   > (help "lambda") 
> >
> > in your emacs repl. If so, do you object to the browser coming up
> > with intensively hyperlinked documentation? Or do you not like the
> > format?

BTW, if you tried just that, then note that you can also an identifier
to jump directly to its definition:

  (help lambda)

This uses the *syntactic* information from the system, for example:

  (define kons cons)
(Continue reading)

Matthias Felleisen | 1 Dec 2010 17:02
Favicon

Re: Exploratory programming?


On Dec 1, 2010, at 1:20 AM, Eli Barzilay wrote:

>> 
>> Examples: comparing Python's help function to Racket's as a tool for
>> introspecting objects at the REPL
>> [...]
>>> (define (f x y)
>>    (+ x y))
>>> (help f)
>> Not found in any library's documentation: f
> 
> This is because you didn't document it. 

I wonder whether help could display contracts if the module use provide/contract to export f. 
Stevie Strickland | 1 Dec 2010 17:36
Favicon
Gravatar

Re: equal? with classes and contracts

On Nov 30, 2010, at 10:32 PM, Nadeem Abdul Hamid wrote:
> I think something like this has come up before but I can't find the
> thread. Given:
> 
> (define A%
>  (class object% (inspect #f) (super-new)))
> (define/contract B%
>  (class/c )
>  (class object% (inspect #f) (super-new)))
> 
> How can I get around the problem that:
>    (equal? (new A%) (new A%))
> but
>    (not (equal? (new B%) (new B%)))
> 
> I want to be able to compare objects of the same contracted class for
> structural equality.

This is indeed a problem with the current implementation of class/c.  I'm currently working on
reimplementing parts of our contract system to take advantage of the new chaperone and impersonator
wrappers.  Once class/c is rewritten, I believe that this problem will just go away, since all the
information about which inspectors have access (or that all inspectors have access, in this case) should
be preserved.  Feel free to submit a bug in the meantime, so that I'll have a reminder to check that this has
indeed been solved once I've finished.

> And another question: is there something similar to struct-copy for
> objects? Or a way to easily clone them?

No, though this has been a requested feature before; I know that Ryan has done some work in this area before,
but I haven't had a chance at incorporating what he's done, or something similar, into the core class
(Continue reading)

YC | 1 Dec 2010 20:26
Picon
Gravatar

metacircular interpreter, lexical scope, environment

Hi all - 


a question for those who have experiences with metacircular interpreters: 

How do you represent the lexical variables?  Since lexical variables can be optimized away so they won't show up on a call to eval, it seems putting them into the environment (I am using a struct holding an immutable hash for environment) isn't the right approach.  It feels like I need my own call-stack to represent them, but that sounds "heavy" for a metacircular interpreter. 

Any thoughts are appreciated, thanks. 
yc


<div>
<p>Hi all -&nbsp;
</p>
<div><br></div>
<div>a question for those who have experiences with metacircular interpreters:&nbsp;</div>
<div><br></div>
<div>How do you represent the lexical variables? &nbsp;Since lexical variables can be optimized away so they won't show up on a call to eval, it seems putting them into the environment (I am using a struct holding an immutable hash for environment) isn't the right approach. &nbsp;It feels like I need my own call-stack to represent them, but that sounds "heavy" for a metacircular interpreter.&nbsp;</div>
<div><br></div>
<div>Any thoughts are appreciated, thanks.&nbsp;</div>
<div>yc</div>
<div><br></div>
<div><br></div>
</div>
richard.lawrence | 1 Dec 2010 20:33
Picon
Favicon

Re: Exploratory programming?

>
> On Dec 1, 2010, at 1:20 AM, Eli Barzilay wrote:
>
>>>
>>> Examples: comparing Python's help function to Racket's as a tool for
>>> introspecting objects at the REPL
>>> [...]
>>>> (define (f x y)
>>>    (+ x y))
>>>> (help f)
>>> Not found in any library's documentation: f
>>
>> This is because you didn't document it.

Yes, right.  This was perhaps not the best illustration.  I don't think it
would be terribly useful to read documentation (per se) about functions
defined at the REPL.  I meant to illustrate that calling help on a
procedure object in Python gives you a certain amount of information
(regardless of whether the author has documented it or not), including the
module it is defined in and its required and optional arguments.  Is there
a way to get this kind of information in Racket at the REPL, regardless of
whether or not the author has been scrupulous in documenting her work?

> I wonder whether help could display contracts if the module use
> provide/contract to export f.

This is exactly the kind of thing I would find useful.  Or perhaps I
should say: it is the kind of thing I have found useful in the past.  The
spirit of my original question was meant to be: given that I found this
useful in the past, what's the right way of translating that experience to
programming in Racket?  Should I be looking for a way to do similar things
in Racket, or should I be revising the way I think about and use the
documentation system?  It seems like the answer is, "both."

Best,
Richard


Gmane