Re: [racket-users] Confused about syntax properties

2017-01-29 Thread Matias Eyzaguirre

> On 29 Jan 2017, at 11:21, Ben Greenman  wrote:
> 
> The third result is #f because in the third example, stx is `(annotate 
> (annotate 4 2))`. So the first pattern matches and `val` is the syntax 
> `(annotate 4 2)`.
> 
> You can get a "strict" evaluation order by using `local-expand` inside the 
> `annotate` macro. For example:
> 
> #lang racket
> 
> (define-syntax (annotate stx)
>   (syntax-case stx ()
>[(_ val) ; read
>(or (syntax-property (local-expand #'val 'expression #f) 'annotation) 
> #'#f)]
>[(_ val ann) ; write
>(syntax-property #'val 'annotation #'ann #t)]))
> 
> (annotate 4) ;; ==> #f
> (annotate 1 6) ;; ==> 1
> (annotate (annotate 4 2)) ;; ==> 2

Nice, thanks! I wasn’t aware of that. so macros are expanded in the order that 
the reader reads them, not in so called evaluation order.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Confused about syntax properties

2017-01-29 Thread Matias Eyzaguirre
Hullo all,

I'm messing around with syntax properties to try to get a feel for them, but in 
one of my tests they aren't behaving the way I would expect them to.

In my example the output is #f 1 #f, when I would have thought it would be #f 1 
2. Why is the third result #f and not 2?


#lang racket

(define-syntax (annotate stx)
  (syntax-case stx ()
[(_ val) ; read
 (or (syntax-property #'val 'annotation) #'#f)]
[(_ val ann) ; write
 (syntax-property #'val 'annotation #'ann #t)]))

(annotate 4) ; -> #f

(annotate 1 6) ; -> 1

(annotate (annotate 4 2)) ; -> 2

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] composing unquote-rewriters in redex?

2015-08-23 Thread Matias Eyzaguirre
To get rid of racket expressions that have been embedded in metafunctions and 
reduction relations, you use `with-unquote-rewriter`, but you can currently 
only have one rewriter active at a time (as underneath it's a single parameter 
that holds a function).

I've been writing a little library to make working with rewriters a little more 
friendly, I expose a rewriter stack that you can push and pop atomic and 
compound rewriters to. I've been thinking about how best to add support for 
unquote rewriters, but I'm stumped.

One possibility that occurred to me was to have pushing an unquote rewriter 
procedure RW onto the stack just set the current unquote rewriter to a function 
that calls RW on the lw in question, and if RW produces an lw where the unq? 
field is true, then that is the result, otherwise use the previous unquote 
rewriter (thus rewriters that don't want to make a change pass responsibility 
up the stack). Other than the fact that this could get rather slow when the 
unquote-rewriter stack gets really deep, redex currently doesn't publicly 
export the current-unquote-rewriter parameter. Would it be possible to make 
that change?

In the meantime I suppose I shall make my own parameter for keeping track of 
unquote-rewriters, though this has the disadvantage of not knowing anything 
about unquote-rewriters set with the with-unquote-rewriter macro.

Another thought that would require more effort, why is there only ever a single 
unquote-rewriter at a time? compound-rewriters and atomic-rewriters both have a 
table, allowing multiple rewriters to be layered on top of each other?

Anyway thanks,
Matias Eyzagurre.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket] pfds package conflict in racket 6.0

2014-03-18 Thread Matias Eyzaguirre
Hi,

When I try to install the pfds package under racket 6.0, it says that it 
depends on typed-racket-compatibility, which it then says conflicts with 
typed-racket-lib.

I’m guessing that the dependency needs to be updated?

Thanks,
 Matias Eyzaguirre

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] typesetting scribble/lp files individually

2013-12-16 Thread Matias Eyzaguirre
Hi all,

I’ve been using scribble/lp for a little while, but it’s starting to get 
annoying that using it seems to require a second module to lp-include the 
scribble/lp module in order to be able to typeset/render it. It doesn’t look 
like there’s a way to do it, but I thought I’d ask. If there isn’t, would it be 
possible to add one?

Even just having the  pdf and html buttons in the DrRacket toolbar be usable 
with scribble/lp files would greatly reduce the tedium of switching back and 
forth between my program and a file that just contains a call to lp-include.

Thanks,
Matias Eyzaguirre

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Scribble with color-property and background-color-property

2013-10-29 Thread Matias Eyzaguirre
Hi all,
When I use color-property and background-color-property in scribble they work 
as expected when I generate HTML output, but do not seem to have any effect 
when I generate PDF output. Do they not work with the LaTeX renderer?

On the other hand, I’m not very familiar with scribble so It’s easily possible 
I’m doing something wrong. My document looks like this:

#lang scribble/base
@(require (only-in scribble/core style color-property 
background-color-property))
@(define ugly-style
   (style 'ugly (list (color-property "red")
  (background-color-property "blue"
@para[#:style ugly-style]{Hello, this is incredibly ugly text}

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] syntax-case + boxes and hash literals

2013-03-21 Thread Matias Eyzaguirre
#lang scribble/lp

I've been to write some macros but I've run into some rather annoying
limitations of syntax-case. They all involve deconstructing/pattern-matching
literal boxes and literal hash tables. As per the pattern grammer in the
reference guide, I can use syntax case to match against vectors, lists, and
prefab structures, like so:

@chunk[<*>
   (syntax-case #'(1 #(b 2) #s(silly 3)) ()
 [(a #(_ b) #s(silly c))
  #'(a b c)])]

However I cannot do the same with boxes or hash literal. I can match syntax 
that contains boxes, like so:

@chunk[<*>
   (syntax-case #'(1 #&2 #(3)) ()
 [(a b #(c))
  #'(a b c)])]

But I cannot pattern match inside of the box itself. I would have expected that 
the following return a syntax object containing 1, 2, and 3 in a list. Instead 
it gives an error that says "?: bad syntax in: (1 #(b 2) #&3)"

@chunk[<*>
   (syntax-case #'(1 #(b 2) #&3) ()
 [(a #(_ b) #&c)
  #'(a b c)])]

Why is this? It's my understanding that syntax-case is an older features, and 
so perhaps it just wasn't updated when newer constructs arrived. Was this an 
intentional decision, or did it slip through? If it did, could I ask that it be 
added to the TODO list?

Thanks,
Matias Eyzaguirre

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] plist limitations

2012-04-05 Thread Matias Eyzaguirre
The plist library in xml/plist will only allow for plists whose root element is 
a dictionary, and complains bitterly when it is anything else. However many 
plists have an array in their root. I'm unsure what the reasoning for this is, 
but I think it could be considered a bug; however I'm unsure what the process 
is for reporting bugs in racket.

signature.asc
Description: Message signed with OpenPGP using GPGMail

  Racket Users list:
  http://lists.racket-lang.org/users