Re: [racket-dev] syntax property duplication

2011-09-07 Thread John Clements

On Sep 6, 2011, at 8:12 PM, Sam Tobin-Hochstadt wrote:

 On Tue, Sep 6, 2011 at 8:05 PM, John Clements cleme...@brinckerhoff.org 
 wrote:
 
 On Aug 18, 2011, at 5:32 AM, Sam Tobin-Hochstadt wrote:
 
 
 Yes, I understand why this happens.  As I see it, there are a few 
 possibilities:
 
 1. The expander should check for duplicates, in some fashion.
 2. This idiom is problematic, in the case where `stx' is both the
 input and used for the syntax properties of the output.
 3. Macros may freely duplicate syntax properties.
 
 All of these have drawbacks, but (3), which you are suggesting, means
 either that syntax properties can only be used to specify idempotent
 information or that the non-idempotent ones need to have some
 *explicit* means by which equal elements can be distinguished, which
 must be part of the API of that syntax property.
 
 If we think this is how syntax properties ought to work, then we
 should add something to the documentation making this clear, and we
 should recognize that it's a limitation.
 
 Would syntax-property guards solve this problem?
 
 I don't really see how.  What are you thinking of?

A guard could keep track of duplicates.  Keep in mind that syntax-property 
guards are purely a figment of my imagination.

John



smime.p7s
Description: S/MIME cryptographic signature
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Re: [racket-dev] syntax property duplication

2011-09-07 Thread Carl Eastlund
On Wed, Sep 7, 2011 at 1:37 PM, John Clements cleme...@brinckerhoff.org wrote:

 On Sep 6, 2011, at 8:12 PM, Sam Tobin-Hochstadt wrote:

 On Tue, Sep 6, 2011 at 8:05 PM, John Clements cleme...@brinckerhoff.org 
 wrote:

 On Aug 18, 2011, at 5:32 AM, Sam Tobin-Hochstadt wrote:


 Yes, I understand why this happens.  As I see it, there are a few 
 possibilities:

 1. The expander should check for duplicates, in some fashion.
 2. This idiom is problematic, in the case where `stx' is both the
 input and used for the syntax properties of the output.
 3. Macros may freely duplicate syntax properties.

 All of these have drawbacks, but (3), which you are suggesting, means
 either that syntax properties can only be used to specify idempotent
 information or that the non-idempotent ones need to have some
 *explicit* means by which equal elements can be distinguished, which
 must be part of the API of that syntax property.

 If we think this is how syntax properties ought to work, then we
 should add something to the documentation making this clear, and we
 should recognize that it's a limitation.

 Would syntax-property guards solve this problem?

 I don't really see how.  What are you thinking of?

 A guard could keep track of duplicates.  Keep in mind that syntax-property 
 guards are purely a  figment of my imagination.

What, in your imagination, is a syntax-property guard?

--Carl

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


Re: [racket-dev] syntax property duplication

2011-09-07 Thread John Clements

On Sep 7, 2011, at 10:40 AM, Carl Eastlund wrote:

 On Wed, Sep 7, 2011 at 1:37 PM, John Clements cleme...@brinckerhoff.org 
 wrote:
 
 On Sep 6, 2011, at 8:12 PM, Sam Tobin-Hochstadt wrote:
 
 On Tue, Sep 6, 2011 at 8:05 PM, John Clements cleme...@brinckerhoff.org 
 wrote:
 
 On Aug 18, 2011, at 5:32 AM, Sam Tobin-Hochstadt wrote:
 
 
 Yes, I understand why this happens.  As I see it, there are a few 
 possibilities:
 
 1. The expander should check for duplicates, in some fashion.
 2. This idiom is problematic, in the case where `stx' is both the
 input and used for the syntax properties of the output.
 3. Macros may freely duplicate syntax properties.
 
 All of these have drawbacks, but (3), which you are suggesting, means
 either that syntax properties can only be used to specify idempotent
 information or that the non-idempotent ones need to have some
 *explicit* means by which equal elements can be distinguished, which
 must be part of the API of that syntax property.
 
 If we think this is how syntax properties ought to work, then we
 should add something to the documentation making this clear, and we
 should recognize that it's a limitation.
 
 Would syntax-property guards solve this problem?
 
 I don't really see how.  What are you thinking of?
 
 A guard could keep track of duplicates.  Keep in mind that syntax-property 
 guards are purely a  figment of my imagination.
 
 What, in your imagination, is a syntax-property guard?

I imagine that when the key involved in the property is a special 
guarded-syntax-property value, then an associated procedure gets to decide 
(approve/reject, substitute an alternate value?) whether a value should be used.

If I understand the problem, the obvious danger in an idea such as this is 
opening a back door into expansion time.

Apologies if I've misunderstood the issue.

John



smime.p7s
Description: S/MIME cryptographic signature
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Re: [racket-dev] syntax property duplication

2011-09-06 Thread John Clements

On Aug 18, 2011, at 5:32 AM, Sam Tobin-Hochstadt wrote:

 
 Yes, I understand why this happens.  As I see it, there are a few 
 possibilities:
 
 1. The expander should check for duplicates, in some fashion.
 2. This idiom is problematic, in the case where `stx' is both the
 input and used for the syntax properties of the output.
 3. Macros may freely duplicate syntax properties.
 
 All of these have drawbacks, but (3), which you are suggesting, means
 either that syntax properties can only be used to specify idempotent
 information or that the non-idempotent ones need to have some
 *explicit* means by which equal elements can be distinguished, which
 must be part of the API of that syntax property.
 
 If we think this is how syntax properties ought to work, then we
 should add something to the documentation making this clear, and we
 should recognize that it's a limitation.

Would syntax-property guards solve this problem?

John




smime.p7s
Description: S/MIME cryptographic signature
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev

Re: [racket-dev] syntax property duplication

2011-09-06 Thread Sam Tobin-Hochstadt
On Tue, Sep 6, 2011 at 8:05 PM, John Clements cleme...@brinckerhoff.org wrote:

 On Aug 18, 2011, at 5:32 AM, Sam Tobin-Hochstadt wrote:


 Yes, I understand why this happens.  As I see it, there are a few 
 possibilities:

 1. The expander should check for duplicates, in some fashion.
 2. This idiom is problematic, in the case where `stx' is both the
 input and used for the syntax properties of the output.
 3. Macros may freely duplicate syntax properties.

 All of these have drawbacks, but (3), which you are suggesting, means
 either that syntax properties can only be used to specify idempotent
 information or that the non-idempotent ones need to have some
 *explicit* means by which equal elements can be distinguished, which
 must be part of the API of that syntax property.

 If we think this is how syntax properties ought to work, then we
 should add something to the documentation making this clear, and we
 should recognize that it's a limitation.

 Would syntax-property guards solve this problem?

I don't really see how.  What are you thinking of?

-- 
sam th
sa...@ccs.neu.edu

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


Re: [racket-dev] syntax property duplication

2011-08-18 Thread Carl Eastlund
On Wed, Aug 17, 2011 at 6:25 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu wrote:
 The following idiom duplicates the syntax properties on `stx':

  (define-syntax (m stx) (datum-syntax #'here 'id stx stx))

 This is a problem for me because I use syntax properties to indicate
 polymorphic type instantiation.  If an expression that's actually a
 macro using this idiom is instatiated, then Typed Racket tries to do
 the type instantiation twice, resulting in an error.  See the below
 program, which fails.

 Should I expect that duplicate syntax properties are a natural result
 of expansion, and find some way to handle them?  Or is there something
 else that should happen?

 #lang typed/racket
 (: id : (All (A) (A - A)))
 (define (id x) x)
 (define-syntax (m stx) (datum-syntax #'here 'id stx stx))
 (inst m Integer)

 --
 sam th
 sa...@ccs.neu.edu

Merging syntax properties -- duplicating in this case, since the
macro's input and output have the same properties -- are a natural
result of expansion, as you say.  See the third paragraph in the
reference on syntax properties:

http://docs.racket-lang.org/reference/stxprops.html

I think you need to find some way to handle them.

--Carl

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


Re: [racket-dev] syntax property duplication

2011-08-18 Thread Sam Tobin-Hochstadt
On Thu, Aug 18, 2011 at 8:14 AM, Carl Eastlund c...@ccs.neu.edu wrote:
 On Wed, Aug 17, 2011 at 6:25 PM, Sam Tobin-Hochstadt sa...@ccs.neu.edu 
 wrote:
 The following idiom duplicates the syntax properties on `stx':

  (define-syntax (m stx) (datum-syntax #'here 'id stx stx))

 This is a problem for me because I use syntax properties to indicate
 polymorphic type instantiation.  If an expression that's actually a
 macro using this idiom is instatiated, then Typed Racket tries to do
 the type instantiation twice, resulting in an error.  See the below
 program, which fails.

 Should I expect that duplicate syntax properties are a natural result
 of expansion, and find some way to handle them?  Or is there something
 else that should happen?

 #lang typed/racket
 (: id : (All (A) (A - A)))
 (define (id x) x)
 (define-syntax (m stx) (datum-syntax #'here 'id stx stx))
 (inst m Integer)

 Merging syntax properties -- duplicating in this case, since the
 macro's input and output have the same properties -- are a natural
 result of expansion, as you say.  See the third paragraph in the
 reference on syntax properties:

Yes, I understand why this happens.  As I see it, there are a few possibilities:

1. The expander should check for duplicates, in some fashion.
2. This idiom is problematic, in the case where `stx' is both the
input and used for the syntax properties of the output.
3. Macros may freely duplicate syntax properties.

All of these have drawbacks, but (3), which you are suggesting, means
either that syntax properties can only be used to specify idempotent
information or that the non-idempotent ones need to have some
*explicit* means by which equal elements can be distinguished, which
must be part of the API of that syntax property.

If we think this is how syntax properties ought to work, then we
should add something to the documentation making this clear, and we
should recognize that it's a limitation.
-- 
sam th
sa...@ccs.neu.edu

_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev


[racket-dev] syntax property duplication

2011-08-17 Thread Sam Tobin-Hochstadt
The following idiom duplicates the syntax properties on `stx':

  (define-syntax (m stx) (datum-syntax #'here 'id stx stx))

This is a problem for me because I use syntax properties to indicate
polymorphic type instantiation.  If an expression that's actually a
macro using this idiom is instatiated, then Typed Racket tries to do
the type instantiation twice, resulting in an error.  See the below
program, which fails.

Should I expect that duplicate syntax properties are a natural result
of expansion, and find some way to handle them?  Or is there something
else that should happen?

#lang typed/racket
(: id : (All (A) (A - A)))
(define (id x) x)
(define-syntax (m stx) (datum-syntax #'here 'id stx stx))
(inst m Integer)

-- 
sam th
sa...@ccs.neu.edu
_
  For list-related administrative tasks:
  http://lists.racket-lang.org/listinfo/dev