Re: [racket-dev] problem with require and frtime

2012-01-20 Thread Matthew Flatt
At Fri, 20 Jan 2012 13:45:35 +0100, Marijn wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> 
> On 19-01-12 14:13, Matthew Flatt wrote:
> > The `frtime' language exports an `=' that isn't the same as `=' in 
> > `racket', so that's why the pattern doesn't match. (This seems like
> > a further weakness of the `frtime' docs to specify the exports 
> > precisely.)
> > 
> > You could avoid bound names like `=' as literals in the macro. 
> > Normally, it works best for a form-exporting macro to also export 
> > bindings for any literals in the form. Otherwise, this kind of 
> > confusion is common.
> 
> I think I will change the `=' to `!' for now. What kind of binding
> should I use for `?' and `!'? There is no sensible meaning to be bound
> to them...
> What do you use to bind `else'?

The `else' from `racket/base' is bound to a macro that always complains
that `else' isn't an expression. For the implementation, see
"collects/racket/private/cond.rkt".


> When cond starts using #:else I might consider this more seriously.

For what it's worth, if I were tweaking the language unencumbered by
existing code, I really would change `else' to `#:else'.


> The reference claims that "A keyword is like an
> interned symbol, but ... and a keyword cannot be used as an
> identifier" implying that symbols can be used as identifiers.

I agree that it doesn't imply the right use of the word "symbol" and
"identifier". I'll change it, perhaps to "a keyword cannot be used to
form an identifier in the same way as a symbol".


> I have in my head from unknown source (maybe from other schemes) that
> a keyword is a value which evaluates to itself, like a constant,
> whereas symbols are produced by quoting identifiers.

In those other contexts I would say "a keyword can be used as an
expression that evaluates to itself" or "a keyword is self-quoting".

In Racket, however, a keyword is not an expression. The distinction
between a keyword and an expression exactly why I prefer a keyword when
a syntactic marker is needed. It's especially better in a case like
`else', where either the marker or an expression can appear in the same
place. (In your macro, expressions cannot appear in the same place as
`?' and `!', so the difference is less significant.)

See also

 "Keyword and Optional Arguments in PLT Scheme"
 Flatt and Barzilay, Scheme'09
 http://www.cs.utah.edu/plt/publications/scheme09-fb.pdf


_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] problem with require and frtime

2012-01-20 Thread Marijn
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 19-01-12 14:13, Matthew Flatt wrote:
> The `frtime' language exports an `=' that isn't the same as `=' in 
> `racket', so that's why the pattern doesn't match. (This seems like
> a further weakness of the `frtime' docs to specify the exports 
> precisely.)
> 
> You could avoid bound names like `=' as literals in the macro. 
> Normally, it works best for a form-exporting macro to also export 
> bindings for any literals in the form. Otherwise, this kind of 
> confusion is common.

I think I will change the `=' to `!' for now. What kind of binding
should I use for `?' and `!'? There is no sensible meaning to be bound
to them...
What do you use to bind `else'?

> Alternatively, you may want to match literals in your macro 
> symbolically instead of by binding. You can't do that easily with 
> `syntax-rules', but you can use `syntax-case*' and supply `(lambda
> (a b) (eq? (syntax-e a) (syntax-e b)))' as the literal-comparison 
> function.
> 
> If it were me and I decided to go in the direction of symbol
> equality, I'd use keywords instead --- `#:?' and `#:=' instead of
> `?' and `=' --- which makes clear that there's no question of
> binding.

When cond starts using #:else I might consider this more seriously.
The docs seem now less than clear to me about the difference between a
keyword and a symbol. The reference claims that "A keyword is like an
interned symbol, but ... and a keyword cannot be used as an
identifier" implying that symbols can be used as identifiers.

I have in my head from unknown source (maybe from other schemes) that
a keyword is a value which evaluates to itself, like a constant,
whereas symbols are produced by quoting identifiers. The difference
manifesting when multiple-evaluation comes into play: what is the
value of the value of ...

Marijn
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8ZYe8ACgkQp/VmCx0OL2zGjwCfT3PTlGrlicqHKo4ww0TcCicq
Ku8An3dTq+bnD+YYM5hCh61n6zadzo3h
=ScwW
-END PGP SIGNATURE-
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] problem with require and frtime

2012-01-19 Thread Gregory Cooper
I assume it wouldn't be too difficult, and that it's worth doing even if it
doesn't solve this particular problem.  Can someone grant me commit
privileges?

On Thu, Jan 19, 2012 at 5:18 AM, Matthew Flatt  wrote:

> (Just to be clear, that wouldn't solve the problem this time. The `='
> from `scheme' and `racket' are the same, but `frtime' has its own `='.)
>
> At Thu, 19 Jan 2012 08:19:59 -0500, Matthias Felleisen wrote:
> >
> > Greg, how difficult would it be to migrate frtime to #lang racket? --
> Matthias
> >
> >
> >
> > On Jan 19, 2012, at 8:13 AM, Matthew Flatt wrote:
> >
> > > The `frtime' language exports an `=' that isn't the same as `=' in
> > > `racket', so that's why the pattern doesn't match. (This seems like a
> > > further weakness of the `frtime' docs to specify the exports
> > > precisely.)
> > >
> > > You could avoid bound names like `=' as literals in the macro.
> > > Normally, it works best for a form-exporting macro to also export
> > > bindings for any literals in the form. Otherwise, this kind of
> > > confusion is common.
> > >
> > > Alternatively, you may want to match literals in your macro
> > > symbolically instead of by binding. You can't do that easily with
> > > `syntax-rules', but you can use `syntax-case*' and supply `(lambda (a
> > > b) (eq? (syntax-e a) (syntax-e b)))' as the literal-comparison
> > > function.
> > >
> > > If it were me and I decided to go in the direction of symbol equality,
> > > I'd use keywords instead --- `#:?' and `#:=' instead of `?' and `=' ---
> > > which makes clear that there's no question of binding.
> > >
> > >
> > > At Thu, 19 Jan 2012 10:46:37 +0100, Marijn wrote:
> > >> On 18-01-12 17:47, Matthew Flatt wrote:
> > >>> At Wed, 18 Jan 2012 12:02:10 +0100, Marijn wrote:
> >  I would expect both forms to work. This is a reduction of a
> different
> >  problem possibly caused by these issues here.
> > >>
> > >> So I tried to cut down my program to a reasonably sized test-case
> which
> > >> is attached to this email. model.rkt contains (what's left of) the
> model
> > >> macro, demo1.rkt contains a small model and a (require frtime). If you
> > >> do "racket demo1.rkt" then you get the following error:
> > >>
> > >>
> > >> model.rkt:30:17: make-entry: bad syntax in: (make-entry (= profit
> > >> (for/hash ((y years)) (values y (- (hash-ref income y 0) (hash-ref
> > >> expenses y 0) (years income expenses profit))
> > >>
> > >> === context ===
> > >> standard-module-name-resolver
> > >>
> > >>
> > >> but if you comment the (require frtime) then the error goes away. I
> have
> > >> other code that tests this same simple-economy model with the
> > >> non-cutdown version of the model macro and supporting code and
> > >> everything seems to work fine.
> > >>
> > >> Any idea what's going on here?
> > >>
> > >> Marijn
> > >>
> > >>
> >
> --
> > >> [text/plain "demo1.rkt"] [~/Desktop & open] [~/Temp & open]
> > >>
> > >>
> >
> --
> > >> [text/plain "model.rkt"] [~/Desktop & open] [~/Temp & open]
> > >>
> > >>
> >
> --
> > >> [application/pgp-signature "signature.asc"] [~/Desktop & open]
> [~/Temp &
> > open]
> > > _
> > >  Racket Developers list:
> > >  http://lists.racket-lang.org/dev
> _
>  Racket Developers list:
>  http://lists.racket-lang.org/dev
>
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] problem with require and frtime

2012-01-19 Thread Matthew Flatt
(Just to be clear, that wouldn't solve the problem this time. The `='
from `scheme' and `racket' are the same, but `frtime' has its own `='.)

At Thu, 19 Jan 2012 08:19:59 -0500, Matthias Felleisen wrote:
> 
> Greg, how difficult would it be to migrate frtime to #lang racket? -- Matthias
> 
> 
> 
> On Jan 19, 2012, at 8:13 AM, Matthew Flatt wrote:
> 
> > The `frtime' language exports an `=' that isn't the same as `=' in
> > `racket', so that's why the pattern doesn't match. (This seems like a
> > further weakness of the `frtime' docs to specify the exports
> > precisely.)
> > 
> > You could avoid bound names like `=' as literals in the macro.
> > Normally, it works best for a form-exporting macro to also export
> > bindings for any literals in the form. Otherwise, this kind of
> > confusion is common.
> > 
> > Alternatively, you may want to match literals in your macro
> > symbolically instead of by binding. You can't do that easily with
> > `syntax-rules', but you can use `syntax-case*' and supply `(lambda (a
> > b) (eq? (syntax-e a) (syntax-e b)))' as the literal-comparison
> > function.
> > 
> > If it were me and I decided to go in the direction of symbol equality,
> > I'd use keywords instead --- `#:?' and `#:=' instead of `?' and `=' ---
> > which makes clear that there's no question of binding.
> > 
> > 
> > At Thu, 19 Jan 2012 10:46:37 +0100, Marijn wrote:
> >> On 18-01-12 17:47, Matthew Flatt wrote:
> >>> At Wed, 18 Jan 2012 12:02:10 +0100, Marijn wrote:
>  I would expect both forms to work. This is a reduction of a different
>  problem possibly caused by these issues here.
> >> 
> >> So I tried to cut down my program to a reasonably sized test-case which
> >> is attached to this email. model.rkt contains (what's left of) the model
> >> macro, demo1.rkt contains a small model and a (require frtime). If you
> >> do "racket demo1.rkt" then you get the following error:
> >> 
> >> 
> >> model.rkt:30:17: make-entry: bad syntax in: (make-entry (= profit
> >> (for/hash ((y years)) (values y (- (hash-ref income y 0) (hash-ref
> >> expenses y 0) (years income expenses profit))
> >> 
> >> === context ===
> >> standard-module-name-resolver
> >> 
> >> 
> >> but if you comment the (require frtime) then the error goes away. I have
> >> other code that tests this same simple-economy model with the
> >> non-cutdown version of the model macro and supporting code and
> >> everything seems to work fine.
> >> 
> >> Any idea what's going on here?
> >> 
> >> Marijn
> >> 
> >> 
> --
> >> [text/plain "demo1.rkt"] [~/Desktop & open] [~/Temp & open]
> >> 
> >> 
> --
> >> [text/plain "model.rkt"] [~/Desktop & open] [~/Temp & open]
> >> 
> >> 
> --
> >> [application/pgp-signature "signature.asc"] [~/Desktop & open] [~/Temp & 
> open]
> > _
> >  Racket Developers list:
> >  http://lists.racket-lang.org/dev
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] problem with require and frtime

2012-01-19 Thread Matthias Felleisen

Greg, how difficult would it be to migrate frtime to #lang racket? -- Matthias



On Jan 19, 2012, at 8:13 AM, Matthew Flatt wrote:

> The `frtime' language exports an `=' that isn't the same as `=' in
> `racket', so that's why the pattern doesn't match. (This seems like a
> further weakness of the `frtime' docs to specify the exports
> precisely.)
> 
> You could avoid bound names like `=' as literals in the macro.
> Normally, it works best for a form-exporting macro to also export
> bindings for any literals in the form. Otherwise, this kind of
> confusion is common.
> 
> Alternatively, you may want to match literals in your macro
> symbolically instead of by binding. You can't do that easily with
> `syntax-rules', but you can use `syntax-case*' and supply `(lambda (a
> b) (eq? (syntax-e a) (syntax-e b)))' as the literal-comparison
> function.
> 
> If it were me and I decided to go in the direction of symbol equality,
> I'd use keywords instead --- `#:?' and `#:=' instead of `?' and `=' ---
> which makes clear that there's no question of binding.
> 
> 
> At Thu, 19 Jan 2012 10:46:37 +0100, Marijn wrote:
>> On 18-01-12 17:47, Matthew Flatt wrote:
>>> At Wed, 18 Jan 2012 12:02:10 +0100, Marijn wrote:
 I would expect both forms to work. This is a reduction of a different
 problem possibly caused by these issues here.
>> 
>> So I tried to cut down my program to a reasonably sized test-case which
>> is attached to this email. model.rkt contains (what's left of) the model
>> macro, demo1.rkt contains a small model and a (require frtime). If you
>> do "racket demo1.rkt" then you get the following error:
>> 
>> 
>> model.rkt:30:17: make-entry: bad syntax in: (make-entry (= profit
>> (for/hash ((y years)) (values y (- (hash-ref income y 0) (hash-ref
>> expenses y 0) (years income expenses profit))
>> 
>> === context ===
>> standard-module-name-resolver
>> 
>> 
>> but if you comment the (require frtime) then the error goes away. I have
>> other code that tests this same simple-economy model with the
>> non-cutdown version of the model macro and supporting code and
>> everything seems to work fine.
>> 
>> Any idea what's going on here?
>> 
>> Marijn
>> 
>> --
>> [text/plain "demo1.rkt"] [~/Desktop & open] [~/Temp & open]
>> 
>> --
>> [text/plain "model.rkt"] [~/Desktop & open] [~/Temp & open]
>> 
>> --
>> [application/pgp-signature "signature.asc"] [~/Desktop & open] [~/Temp & 
>> open]
> _
>  Racket Developers list:
>  http://lists.racket-lang.org/dev


_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] problem with require and frtime

2012-01-19 Thread Matthew Flatt
The `frtime' language exports an `=' that isn't the same as `=' in
`racket', so that's why the pattern doesn't match. (This seems like a
further weakness of the `frtime' docs to specify the exports
precisely.)

You could avoid bound names like `=' as literals in the macro.
Normally, it works best for a form-exporting macro to also export
bindings for any literals in the form. Otherwise, this kind of
confusion is common.

Alternatively, you may want to match literals in your macro
symbolically instead of by binding. You can't do that easily with
`syntax-rules', but you can use `syntax-case*' and supply `(lambda (a
b) (eq? (syntax-e a) (syntax-e b)))' as the literal-comparison
function.

If it were me and I decided to go in the direction of symbol equality,
I'd use keywords instead --- `#:?' and `#:=' instead of `?' and `=' ---
which makes clear that there's no question of binding.


At Thu, 19 Jan 2012 10:46:37 +0100, Marijn wrote:
> On 18-01-12 17:47, Matthew Flatt wrote:
> > At Wed, 18 Jan 2012 12:02:10 +0100, Marijn wrote:
> >> I would expect both forms to work. This is a reduction of a different
> >> problem possibly caused by these issues here.
> 
> So I tried to cut down my program to a reasonably sized test-case which
> is attached to this email. model.rkt contains (what's left of) the model
> macro, demo1.rkt contains a small model and a (require frtime). If you
> do "racket demo1.rkt" then you get the following error:
> 
> 
> model.rkt:30:17: make-entry: bad syntax in: (make-entry (= profit
> (for/hash ((y years)) (values y (- (hash-ref income y 0) (hash-ref
> expenses y 0) (years income expenses profit))
> 
>  === context ===
> standard-module-name-resolver
> 
> 
> but if you comment the (require frtime) then the error goes away. I have
> other code that tests this same simple-economy model with the
> non-cutdown version of the model macro and supporting code and
> everything seems to work fine.
> 
> Any idea what's going on here?
> 
> Marijn
> 
> --
> [text/plain "demo1.rkt"] [~/Desktop & open] [~/Temp & open]
> 
> --
> [text/plain "model.rkt"] [~/Desktop & open] [~/Temp & open]
> 
> --
> [application/pgp-signature "signature.asc"] [~/Desktop & open] [~/Temp & open]
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] problem with require and frtime

2012-01-19 Thread Marijn
On 18-01-12 17:47, Matthew Flatt wrote:
> At Wed, 18 Jan 2012 12:02:10 +0100, Marijn wrote:
>> I would expect both forms to work. This is a reduction of a different
>> problem possibly caused by these issues here.

So I tried to cut down my program to a reasonably sized test-case which
is attached to this email. model.rkt contains (what's left of) the model
macro, demo1.rkt contains a small model and a (require frtime). If you
do "racket demo1.rkt" then you get the following error:


model.rkt:30:17: make-entry: bad syntax in: (make-entry (= profit
(for/hash ((y years)) (values y (- (hash-ref income y 0) (hash-ref
expenses y 0) (years income expenses profit))

 === context ===
standard-module-name-resolver


but if you comment the (require frtime) then the error goes away. I have
other code that tests this same simple-economy model with the
non-cutdown version of the model macro and supporting code and
everything seems to work fine.

Any idea what's going on here?

Marijn
#lang racket/gui

;;; comment this line to make error go away
(require frtime)

(require "model.rkt")

(define simple-economy
  (model make-immutable-hash hash-ref
   ((? years #f)
(? income (hash))
(? expenses (hash))

(= profit   
   (for/hash ((y years))
 (values
  y
  (- (hash-ref income y 0)
 (hash-ref expenses y 0)   )))
#lang racket

(provide model)

(struct variable ((value #:mutable) rule))

(define-syntax make-store
  (syntax-rules ()
((_ _make-store_ _get-value_ ((_type_ _id_ _args_ ...) ...))
 (let-syntax
 ((make-entry
   (syntax-rules (? =)
 ((_ (? __id__  __init-value__) __other-ids__)
  `(__id__ . ,(variable __init-value__ #f)))
 ((_ (= __id__ __rule__) (__other-id__ (... ...)))
  `(__id__
.
,(variable
  #f
  (lambda ()
(let-syntax
((__other-id__
  (syntax-id-rules ()
(_ (_get-value_ '__other-id__
 (... ...))
  __rule__
   (letrec
   ((store
 (_make-store_
  `(,(make-entry (_type_ _id_ _args_ ...) (_id_ ...)) ...)) ))
 store)

(define-syntax model
  (syntax-rules ()
((_ _make-store_ _store-ref_ ((_type_ _id_ _args_ ...) ...))
 (let ()
   (define (get-variable id) (_store-ref_ store id))
   (define (get-value id) (variable-value (get-variable id)))
   (define store (make-store _make-store_ get-value ((_type_ _id_ _args_ 
...) ...)))

   (match-lambda*
((list 'get id) (get-value id)))
   


signature.asc
Description: OpenPGP digital signature
_
  Racket Developers list:
  http://lists.racket-lang.org/dev


Re: [racket-dev] problem with require and frtime

2012-01-18 Thread Matthew Flatt
At Wed, 18 Jan 2012 12:02:10 +0100, Marijn wrote:
> the following fragment:
> 
> 
> #lang frtime
> 
> (require (only-in srfi/1 every))
> 
> 
> leads to ```only-in: bad module path in: (only-in srfi/1 every)'''
> error. 

The `frtime' language builds on (the older) `scheme' language instead
of `racket', so change `only-in' to `only'.

I'll adjust the docs.

> At the same time this other fragment:
> 
> 
> #lang racket
> 
> (require frtime)
> 
> (require srfi/1)
> 
> 
> leads to ```module: identifier already imported from: frtime at: third
> in: srfi/1''' error.
> 
> I would expect both forms to work. This is a reduction of a different
> problem possibly caused by these issues here.

Unfortunately, the `third' from `racket' (via `racket/list') and from
`srfi/1' are just different functions:

 > (require srfi/1)
 > (third '(1 2 3 . 4)) ; works on any sufficiently long chain of pairs
 3
 > (require racket/list)
 > (third '(1 2 3 . 4)) ; requires a list
 third: expected argument of type ; given '(1 2 3 . 4)

The documentation should clarify that only the `srfi/1' functions
documented in bold (not including those in italic bold) correspond to
`racket' functions, and the others do not; I'll fix those docs, too.

_
  Racket Developers list:
  http://lists.racket-lang.org/dev


[racket-dev] problem with require and frtime

2012-01-18 Thread Marijn
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi,

the following fragment:


#lang frtime

(require (only-in srfi/1 every))


leads to ```only-in: bad module path in: (only-in srfi/1 every)'''
error. At the same time this other fragment:


#lang racket

(require frtime)

(require srfi/1)


leads to ```module: identifier already imported from: frtime at: third
in: srfi/1''' error.

I would expect both forms to work. This is a reduction of a different
problem possibly caused by these issues here.

Marijn
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk8WprIACgkQp/VmCx0OL2yKYACeJxLBVW0N++3g8SgqSpaHvGxD
2DAAoK2p2sezFuU6iYu2/utAWxceQEuA
=rtZ2
-END PGP SIGNATURE-
_
  Racket Developers list:
  http://lists.racket-lang.org/dev