Re: [racket-users] generalised set! in Racket

2015-06-29 Thread Alexander D . Knauth

On Jun 29, 2015, at 5:56 AM, Alexey Cherkaev  wrote:

> For example, I was thinking of defining syntax to access my implementation of 
> multidimensional arrays
> as
> 
> (define-syntax aref
>  (syntax-rules (set!)
>[(set! (aref ?a ?i ...) ?v) (array-set! ?a ?i ... ?v)]
>[(aref ?a ?i ...) (array-ref ?a ?i ...)]))
> 
> but obviously it won't work now as `set!` expects the `id` not an expression 
> (`syntax-id-rules` won't work either as `aref` is not an `id`).


#lang racket
(require srfi/17 math/array)
(define (aref a . is)
  (array-ref a (list->vector is)))
(set! (setter aref)
  (λ (a . is+v)
(match-define (list is ... v) is+v)
(array-set! a (list->vector is) v)))
(define a (mutable-array #[#[1 2] #[3 4]]))
(aref a 0 1)
(set! (aref a 0 1) 20)
(aref a 0 1)

If you wanted, you could also define your own version of set! that does what 
you want, which (I think) you would need to do if you needed aref to be a macro.


-- 
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.


Re: [racket-users] Using ‘except-in’ to exclude identifiers for a single phase level

2015-06-29 Thread Alexis King
Thanks for your help. I did consider the only-meta-in approach, but then I’d be 
excluding the syntax-rules export as well, which I was trying to avoid if 
possible.

> On Jun 29, 2015, at 7:39 AM, Matthew Flatt  wrote:
> 
> You're right that there's not a form that's like `except-out` but
> constrained both by name and phase. There's also not an export variant
> of `only-meta-in`, which would get your half-way there. You could
> implement a new provide expander to do that.
> 
> Otherwise, in addition to the strategy that you describe, another
> possibility is
> 
> (require (only-meta-in 0 r5rs)
>  ...)
> 
> Then you won't have any conflicts from `r5rs` and `racket/base` at
> phase 1, since there won't be any phase-1 imports from `r5rs`.

-- 
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.


Re: [racket-users] try a new macro expander

2015-06-29 Thread Greg Hendershott
Oops, didn't Cc list:

On Mon, Jun 29, 2015 at 12:13 PM, Greg Hendershott
 wrote:
> On Mon, Jun 29, 2015 at 7:43 AM, Matthew Flatt  wrote:
>> I'll have to update the version number, so there's now a
>>
>>racket-current-x86_64-linux.sh
>>
>> installer link.
>
> Thanks. Updated to use this:
>
> https://github.com/greghendershott/travis-racket/commit/5e4d01720497bac37e8f9e522253c9b778a64b5a

-- 
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.


Re: [racket-users] Naming conventions

2015-06-29 Thread Norman Gray

Greetings.

> On 2015 Jun 29, at 16:05, Philip Blair  wrote:
> 
> Perhaps, I'm wrong, but I don't believe there's an *explicit* convention;  
> however, as far as I've seen, it typically is used for function variants 
> (more specifically, I *usually* see it used to distinguish multiple functions 
> which do more or less the same thing with different input forms).
> 
> To quote Neil Van Dyke: "Pronounce the '/' as 'with' [...] Sometimes it's for 
> a variation in behavior, or composition of behaviors, sometimes it's just a 
> shorthand for the word 'with', and sometimes it's something else."
> Source: http://lists.racket-lang.org/users/archive/2011-September/048044.html

I've tended to make names consistent with the list of conventions collected in 
 (with 
'plt-scheme' -> 'racket').

These are mostly echoed in the Racket style guide at 

 (though I think that '#:' is a syntactical constraint that denotes keywords, 
and not just a naming convention).

All the best,

Norman


-- 
Norman Gray  :  http://nxg.me.uk
SUPA School of Physics and Astronomy, University of Glasgow, UK

-- 
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.


Re: [racket-users] Naming conventions

2015-06-29 Thread Philip Blair
Perhaps, I'm wrong, but I don't believe there's an *explicit* 
convention;  however, as far as I've seen, it typically is used for 
function variants (more specifically, I *usually* see it used to 
distinguish multiple functions which do more or less the same thing with 
different input forms).


To quote Neil Van Dyke: "Pronounce the '/' as 'with' [...] Sometimes 
it's for a variation in behavior, or composition of behaviors, sometimes 
it's just a shorthand for the word 'with', and sometimes it's something 
else."
Source: 
http://lists.racket-lang.org/users/archive/2011-September/048044.html


On 6/29/2015 10:51 AM, John Carmack wrote:


Is there an explicit strategy for the use of / in function names, 
“overlay/xy”, “scale/xy” and so on?


--
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.


--
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] Naming conventions

2015-06-29 Thread John Carmack
Is there an explicit strategy for the use of / in function names, "overlay/xy", 
"scale/xy" and so on?



-- 
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.


Re: [racket-users] Using ‘except-in’ to exclude identifiers for a single phase level

2015-06-29 Thread Matthew Flatt
You're right that there's not a form that's like `except-out` but
constrained both by name and phase. There's also not an export variant
of `only-meta-in`, which would get your half-way there. You could
implement a new provide expander to do that.

Otherwise, in addition to the strategy that you describe, another
possibility is

 (require (only-meta-in 0 r5rs)
  ...)

Then you won't have any conflicts from `r5rs` and `racket/base` at
phase 1, since there won't be any phase-1 imports from `r5rs`.

At Sun, 28 Jun 2015 17:29:37 -0700, Alexis King wrote:
> I think it might be time for me to disclose what I’m actually trying to do 
> here to make it more clear. As mentioned in my original message, I’m trying 
> to 
> make a module language just like r5rs but with support for syntax-case 
> macros. 
> This was my attempt:
> 
> #lang racket/base
> 
> (require (except-in r5rs define-syntax)
>  (for-syntax (only-in racket/base
>   syntax quasisyntax unsyntax unsyntax-splicing
>   syntax-case with-syntax)
>  r5rs))
> 
> (provide (all-from-out r5rs)
>  define-syntax
>  (for-syntax (all-from-out r5rs)
>  (all-from-out racket/base)))
> 
> This doesn’t work, though, because #%top, #%datum, and #%app are already 
> provided for-syntax by r5rs. I can do (except-in r5rs #%top #%datum #%app 
> define-syntax), but then those identifiers aren’t defined in phase 0, which 
> obviously causes problems.
> 
> While writing this email, I realized I can additionally add (only-meta-in 0 
> (only-in r5rs #%top #%datum #%app)), which seems to solve the problem. It’s a 
> bit of a roundabout solution, though.
> 
> > On Jun 28, 2015, at 15:07, Benjamin Greenman  wrote:
> > 
> > Oops. Then I'd want to change the all-from-outs to something more specific, 
> or (preferably) change b to only provide some-fn at one level and make the 
> requiring module be more specific.
> 
> -- 
> 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.

-- 
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.


Re: [racket-users] try a new macro expander

2015-06-29 Thread Matthew Flatt
Thanks! I've pushed repairs for these problems, mreged recent changes
from the main development branches, and updated the snapshot here:

 http://www.cs.utah.edu/~mflatt/tmp/scope-snapshot/

At Thu, 25 Jun 2015 13:56:04 -0400, "Alexander D. Knauth" wrote:
> Another weird error:
> #lang racket/base
> (require racket/stxparam (for-syntax racket/base))
> (define-syntax-parameter add (make-rename-transformer #'+))
> (define-syntax add1 (make-rename-transformer #'add))
> add1
> 
> ;add1: identifier's binding is ambiguous
> ;  context.:
> ;  matching binding.:
> ;  matching binding.:
> ;  => add context.:
> ;  => add matching binding.:
> ;  matching binding.: in: add1
> 
> I found this because of this Travis CI build failure:
> https://travis-ci.org/AlexKnauth/infix-macro/jobs/68245124#L164
> 
> On Jun 25, 2015, at 12:31 AM, Matthew Flatt  wrote:
> 
> > Yes, I overlooked `splicing-local`, and I'll repair it. Thanks for the
> > report!
> > 
> > At Wed, 24 Jun 2015 20:27:39 -0400, "Alexander D. Knauth" wrote:
> >> I’ve just found something that I expected to work, but didn’t:
> >> 
> >> #lang racket/base
> >> (require racket/splicing (for-syntax racket/base))
> >> (splicing-local
> >>[(define x 1)]
> >>  (define-syntax outer-x (make-rename-transformer #'x)))
> >> outer-x
> >> 
> >> ;. outer-x: unbound identifier in module in: outer-x
> >> 
> >> This works in the current expander, but fails in the scope-set expander.
> >> 
> >> It does work for splicing-let and splicing-letrec though.
> >> 
> >> I found it because I rely on it in this macro here:
> >> https://github.com/AlexKnauth/my-object/blob/master/my-object/stuff.rkt#L25
> >> And Travis CI was giving me this error:
> >> https://travis-ci.org/AlexKnauth/my-object/jobs/68248192#L209
> >> 
> >> On Jun 22, 2015, at 8:25 AM, Matthew Flatt  wrote:
> >> 
> >>> At Thu, 21 May 2015 07:15:14 -0600, Matthew Flatt wrote:
>  Otherwise, be prepared for me to come back in a few
>  weeks and lobby for moving to a new macro expander.
> >>> 
> >>> Here's the proposal: let's switch on July 16. "Switch" means that I'd
> >>> merge the new macro expander to the master branch of the development
> >>> repository.
> >>> 
> >>> Thanks to those who have tried the new expander and reported back!
> >>> Meanwhile, I've expanded the write-up and filled out the formal model
> >>> (at the same URL as before).
> >> 
> >> 
> >> -- 
> >> 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.
> > 
> > -- 
> > 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.
> 
> -- 
> 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.

-- 
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] overlapping fields in windows, DrRacket user interface (preferences, "choose language")

2015-06-29 Thread Sanjeev Sharma
windows 7;  it's most obvious in 
"preferences -> warnings"

also "choose language -> details" 


I can ivoke and reverse it from this screen:
 
Control Panel\Appearance and Personalization\Display
 -> make text and other items larger or smaller
   -> medium

-- 
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] generalised set! in Racket

2015-06-29 Thread Alexey Cherkaev
Hi all,

Common Lisp has a very useful idiom of SETF that can set values to arbitrary 
places. For example, one can set (1 2)-th item of an array A as:

(SETF (AREF A 1 2) 20.0d0)

Scheme preferred way is to use `*-set!` procedures. However, sometimes it is 
inconvenient. For example, if I want to swap two elements in the array/vector, 
I would like to use `swap`:

(define-syntax swap
  (syntax-rules ()
((swap ?place1 ?place2 ?tmp)
 (begin
   (set! ?tmp ?place1)
   (set! ?place1 ?place2)
   (set! ?place2 ?place1)

But it will only work for vectors if `set!` can act as CL's SETF on generalised 
places, such as 

(swap (vector-ref v 5) (vector-ref v 3) tmp)

SRFI-17 contains the definition of such a `set!` and I can use it from there 
(AFAIR Racket supports it).

I was wondering if there is more Racket-way of doing this? And is there maybe a 
reason why `set!` wasn't given the same power as SETF?

For example, I was thinking of defining syntax to access my implementation of 
multidimensional arrays
as

(define-syntax aref
  (syntax-rules (set!)
[(set! (aref ?a ?i ...) ?v) (array-set! ?a ?i ... ?v)]
[(aref ?a ?i ...) (array-ref ?a ?i ...)]))

but obviously it won't work now as `set!` expects the `id` not an expression 
(`syntax-id-rules` won't work either as `aref` is not an `id`).

Regards, Alexey

-- 
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.