Re: [racket-users] Module dependencies

2018-05-28 Thread Laurent
You could also have a third file, test-a-and-b.rkt, that requires both
a.rkt and b.rkt and includes the test that depend on both files.


On Mon, May 28, 2018 at 10:08 AM Claes Wallin (韋嘉誠) 
wrote:

> (require) binds at compile time and creates a cycle, but by using
> (dynamic-require) you can get past compilation and only load the file at
> runtime, where the seemingly circular reference really isn't.
>
> --
>/c
>
> On Sun, May 27, 2018, 23:48 Matthias Felleisen 
> wrote:
>
>>
>> Modules cannot refer to each other in a cyclic fashion, including
>> submodules. — Matthias
>>
>>
>>
>> On May 27, 2018, at 8:33 AM, Brandon Irizarry 
>> wrote:
>>
>> Say I have two files, "file-a.rkt" and "file-b.rkt" that each contain a
>> submodule test, like so:
>>
>>
>> Contents of "file-a.rkt":
>>
>> #lang racket/base
>> (define (my-function) 'apple)
>> (module+ test
>> (require "file-b.rkt")
>> (other-function))
>>
>> Contents of "file-b.rkt":
>>
>> #lang racket/base
>> (define (other-function) 'orange)
>> (module+ test
>> (require "file-a.rkt")
>> (my-function))
>>
>> The require statements form a circular reference, even though running
>> file-b, along with its tests, shouldn't trigger file-a's tests.
>>
>> I've looked into compiling file-a and file-b, but that didn't work.
>>
>> - Brandon
>>
>>
>> --
>> 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.


Re: [racket-users] Questions on functional-setter generator macro

2018-05-28 Thread Greg Hendershott
On Mon, May 28, 2018 at 9:58 AM, David Storrs  wrote:
> O *course* there is.  Lord know, why should I have an original idea
> now?  :P

The Racket package ecosystem is growing to where we need some
volunteers to form a mathic order of Lorites (like in Neal
Stephenson's novel, Anathem).

-- 
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] Questions on functional-setter generator macro

2018-05-28 Thread David Storrs
On Sat, May 26, 2018 at 3:11 PM, Alexis King  wrote:

> This isn’t a direct answer to your question, but as Matthias notes, my
> struct-update package already implements a macro that generates
> functional setters from structure definitions. Here’s a link to the
> documentation:
>

O *course* there is.  Lord know, why should I have an original idea
now?  :P



> http://docs.racket-lang.org/struct-update/index.html
>
> Of course, that isn’t especially helpful if your goal is to get better
> at authoring macros, not just generate functional setters. For that, you
> might find the (short) source code of struct-update helpful, located
> here:
>
> https://github.com/lexi-lambda/struct-update/blob/
> 8ce456cde8764ae27c348123ec9e01e76826d536/struct-update-lib/
> struct-update/main.rkt


Yes, thank you, this helps.  I hadn't thought about superclass fields.


> Admittedly, your make-functional-setter function does a bit more than
> define-struct-updaters, since it allows for a wrapper function. So I’ll
> also give some brief answers to a few of your unrelated questions.
>

I think we take a different approach -- struct-updaters always specifies a
contract of (-> struct-id? any/c struct-id) whereas make-functional-setters
offers the option to not have a contract or to specify whatever contract
you want.  I'm a firm believer in the idea that you should be allowed to
shoot yourself in the foot if you want the ability to do so.


> > On May 26, 2018, at 10:46, David Storrs 
> > wrote:
> >
> > A) Is there a way to test if a syntax class has a particular attribute
> > before trying to use it?
>
> Yes, use the attribute form. If x is an optional attribute, (attribute
> x) will be #f if the attribute was not bound and the value of the
> attribute if it was bound. If you want, you can change the default value
> to something else other than #f by providing the #:defaults option to
> ~optional.
>

Handy, thanks.


> > B) Alternatively, is there a way to create a null syntax object that
> > expands to nothing?  Not (void), not "", literally nothing.   Then I
> > could have each pattern bind all the attributes via #:with and just
> > have some of them be blank.
>
> Not in an arbitrary context. In a definition context, (begin)
> effectively expands into nothing, since begins are spliced into the
> enclosing context, but in an expression context, you can’t have
> something that expands into nothing.
>
> That said, it sounds like what you might actually want is the template
> and ?? forms from syntax/parse/experimental/template. This allows you
> to write something like this:
>
> (template (foo (?? x)))
>
> The above will be like #'(foo x) if (attribute x) is non-#f, but if it
> is #f, it will be like #'(foo). In Racket 6.12 and earlier, you must use
> the template form for ?? to work, but in Racket 7 and later, ?? will
> also work with the ordinary syntax (aka #') form, so if the word
> “experimental” spooks you, don’t worry about it too much.
>
> Alexis
>
>
This is really helpful, thank you.

-- 
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] Unmap failed

2018-05-28 Thread pavelrodzevich
Hello, my name is Pavel and I'm new to Racket :)

I'm playing with macros right now and get a strange error: "unmap failed".

What I'm trying to achieve in this program: expand (step x) into (+ (expt 2 
0) (expt 2 1) ...)

For small numbers everything is OK, but I get an error for (step 100)

What does this error mean and how can I fix it?

Code is in attachements. 


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


macro-step.rkt
Description: Binary data


Re: [racket-users] Module dependencies

2018-05-28 Thread 韋嘉誠
(require) binds at compile time and creates a cycle, but by using
(dynamic-require) you can get past compilation and only load the file at
runtime, where the seemingly circular reference really isn't.

-- 
   /c

On Sun, May 27, 2018, 23:48 Matthias Felleisen 
wrote:

>
> Modules cannot refer to each other in a cyclic fashion, including
> submodules. — Matthias
>
>
>
> On May 27, 2018, at 8:33 AM, Brandon Irizarry 
> wrote:
>
> Say I have two files, "file-a.rkt" and "file-b.rkt" that each contain a
> submodule test, like so:
>
>
> Contents of "file-a.rkt":
>
> #lang racket/base
> (define (my-function) 'apple)
> (module+ test
> (require "file-b.rkt")
> (other-function))
>
> Contents of "file-b.rkt":
>
> #lang racket/base
> (define (other-function) 'orange)
> (module+ test
> (require "file-a.rkt")
> (my-function))
>
> The require statements form a circular reference, even though running
> file-b, along with its tests, shouldn't trigger file-a's tests.
>
> I've looked into compiling file-a and file-b, but that didn't work.
>
> - Brandon
>
>
> --
> 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.