Re: [racket-users] Why does syntax-parser work here but not syntax-parse?

2021-09-08 Thread Stephen Chang
> shouldn't the entire parenthesized expression be given to the macro processor 
> and then replaced with something valid before being rejected?

That would be true if you're defining a macro, i.e. if you use
`define-syntax` instead of `define`.

>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAE8gKofDYFY8AYb2Lyh7CQXx1i01w8jm4DVcMrJL%3DQYHX9SsRQ%40mail.gmail.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1LxRJNCNHTi%2Bi8Tz2W4wtJ6_s%3D-2jXQfxyMi%3DHE9hQptg%40mail.gmail.com.


Re: [racket-users] how to convert encoded path to something build-path can use?

2021-05-21 Thread Stephen Chang
Thanks!

We were previously manually processing the files from
current-library-collection-links, but using `links` saves ~100 lines
of code.

On Fri, May 21, 2021 at 11:50 AM Matthew Flatt  wrote:
>
> Yes, the format changed in that commit.
>
> The `decode-link-path` function is not meant to be public, although it
> could be exposed. But for an approach that works now and with older
> versions, the API you want is `links` from `setup/link`, possibly like
> this:
>
>   (links #:file (find-links-file) #:with-path? #t)
>   (links #:file (find-links-file) #:root? #t)
>
>
> At Fri, 21 May 2021 11:33:41 -0400, Stephen Chang wrote:
> > Hi,
> >
> > It seems that, since 8.1, the format of paths in links.rktd has changed?
> >
> > Are there new API fns that deal with this new kind of encoded path? Or
> > what is the recommended way to process them?
> >
> > Something like this? (Is this `decode-link-path` public? I couldnt find it)
> > https://github.com/racket/racket/commit/2ac7e21ad422ee322daa4a7e0db318f9b72b6c48
> > #diff-51453f6da842dc20af8fe776f54ec99dd15f4f8b7e9e73cd5d45cdeb96e40ef6R49-R52
> >
> > I used to pass the paths directly to `build-path` but now it no longer
> > works. Here's an example error:
> >
> > build-path: contract violation
> >   expected: (or/c path-string? path-for-some-system? 'up 'same)
> >   given: '(up up #"pkgs" #"racket-lib")
> >
> > Any recommendations would be appreciated. Thanks!
> > Steve
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/20210521095016.3e9%40sirmail.smtps.cs.utah.edu.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1Jf2po6sYq2dDqv-eVHiFFYDSzUpxj_kKJnjQEYqobNqw%40mail.gmail.com.


[racket-users] how to convert encoded path to something build-path can use?

2021-05-21 Thread Stephen Chang
Hi,

It seems that, since 8.1, the format of paths in links.rktd has changed?

Are there new API fns that deal with this new kind of encoded path? Or
what is the recommended way to process them?

Something like this? (Is this `decode-link-path` public? I couldnt find it)
https://github.com/racket/racket/commit/2ac7e21ad422ee322daa4a7e0db318f9b72b6c48#diff-51453f6da842dc20af8fe776f54ec99dd15f4f8b7e9e73cd5d45cdeb96e40ef6R49-R52

I used to pass the paths directly to `build-path` but now it no longer
works. Here's an example error:

build-path: contract violation
  expected: (or/c path-string? path-for-some-system? 'up 'same)
  given: '(up up #"pkgs" #"racket-lib")

Any recommendations would be appreciated. Thanks!
Steve

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1J%3DZ%2BoKNi1-OP7YmRYyttNSamBaHxsMZntd9mxOJCKJGA%40mail.gmail.com.


[racket-users] eq? behavior changed on Racket CS?

2021-05-20 Thread Stephen Chang
Hi everyone, Has eq? behavior changed with Racket CS? (ie, 8.0+)

Specifically:

$ racket79/bin/racket
Welcome to Racket v7.9 [bc].
> (eq? (integer->char 955) (integer->char 955))
#f

$ plt/racket/bin/racket
Welcome to Racket v8.1.0.6 [cs].
> (eq? (integer->char 955) (integer->char 955))
#t

Is this expected behavior?

(I know this has probably been addressed and I wasn't paying
attention, but I did a quick search of the list and docs and couldnt
find anything, so just want to double check. Thanks!)

Steve

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1LQw_ECHrgRN%3DfrK9H%2BE8kSFFEqdShqSdvXXmfCmcB0Eg%40mail.gmail.com.


Re: [racket-users] Racket Generic Graph Library: non-numerical edge weight/labels + Graphviz?

2020-02-24 Thread Stephen Chang
> I am somewhat surprised that the graph library enforces numerical edge 
> weights at all.

The docs do informally say number weights but I don't think the
constructors do any checking? Any enforcement should be deferred to
individual algorithms.

Re: graphviz, I took a quick look and I think we could get the
behavior you want with a 1-line modification here, changing = to
equal?
https://github.com/stchang/graph/blob/master/graph-lib/graph/graph-fns-graphviz.rkt#L59-L60

Do you have an example I can work with?

I opened an issue so feel free to reply there instead:
https://github.com/stchang/graph/issues/53

On Sun, Feb 23, 2020 at 8:45 AM unlimitedscolobb
 wrote:
>
> Hello,
>
> I'm using the wonderful graph library which can do tons of various 
> graph-related tasks.  However, I haven't found a way to attach non-numerical 
> weights/labels to edges _and_ have them appear in the Graphviz rendering of 
> the graph.
>
> Is it at all possible?
>
> I did see define-edge-property, but properties defined in this way do not 
> appear in the Graphviz output.  I was looking for ways of passing edge 
> properties to the graphviz function of the library, but there don't seem to 
> be any.
>
> I am planning to do a pull request enhancing the graphviz function with the 
> possibility to include edge properties, but I wanted to ask around for some 
> solutions which may already exist.
>
>
> -
> Sergiu
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/e4cb44fd-0a21-4e91-a75c-f1442127bfa9%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1LrcfpVxLW%2B%2BCkH0iwRrpzx4bG1t9eSMfFiRc%3D5VLG8MA%40mail.gmail.com.


Re: [racket-users] TR: cast on mutable hash table...

2020-02-14 Thread Stephen Chang
Your second suggestion is described in this (hard to find) section of
the TR Guide on Type Generalization:
https://docs.racket-lang.org/ts-guide/caveats.html#%28part._.Type_generalization%29

I agree it should be much more prominent. At the very least, any docs
for invariant constructors should link to that section I think?

On Fri, Feb 14, 2020 at 2:41 PM 'John Clements' via users-redirect
 wrote:
>
> I think I may understand what’s going on here, but a student and I worked on 
> this for quite a while today before I found the problem.
>
> Here’s a program:
>
> #lang typed/racket
>
> (define-type Store (Mutable-HashTable Integer Value))
> (define-type Value (U Real Boolean String))
>
> (define top-store (cast (make-hash (list
> (cons -1 14)
> (cons 1 #t)
> (cons 2 #f)))
> Store))
>
> (hash-set! top-store 5 1234)
>
> It fails with this error:
>
> contract violation
>   expected: (or/c (and/c byte? positive?) #t #f)
>   given: 1234
>   in: the values of
>   the 3rd conjunct of
>   (and/c
>hash?
>hash-mutable?
>(hash/c
> exact-integer?
> (or/c (and/c byte? positive?) #t #f)
> #:immutable
> #f))
>   contract from: typed-world
>   blaming: cast
>(assuming the contract is correct)
>   at: unsaved-editor:6.18
>
> If I understand what’s going on here, the basic issue is that the mutable 
> hash table’s type is being inferred as (Immutable-HashTable Exact-Integer (U 
> Boolean Positive-Byte)), and then as part of the cast, a contract is being 
> inserted, which checks that all added values match the expected value type. 
> The outer cast allows type checking to proceed, but then at runtime it fails 
> because the given value doesn’t match the inferred value type.
>
> This error doesn’t occur with immutable hash tables, because it’s fine to 
> extend an immutable hash table to a larger one that contains it; the original 
> one’s contract isn’t violated.
>
> In this case, one easy error is to change the ‘cast’ into an ‘ann’, which 
> works fine.
>
> This is the first time I’ve encouraged my students to use a mutable hash, 
> which is presumably why I haven’t encountered this before.
>
> I’m trying to formulate a solution that I can put in a Hints for TR file, and 
> I think the answer is probably this:
>
> - When you use “make-hash” in TR, you should always specify the types 
> explicitly using an “inst”.
> or maybe
> - When you call “make-hash” in TR, the call should be immediately wrapped 
> with an “ann” type annotation.
>
> In a perfect world, I think I would ask for a warning when casting a mutable 
> hash table. It could go in that nice “warnings” box. Oh, wait…
>
> … joking aside, actually I just did turn on the “log” window and I don’t see 
> any warning about this, which is not too surprising. Oh, wait, I see another 
> bug…
>
> Thanks for reading, let me know if there’s any more obvious solution.
>
> John
>
>
>
>
>
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/f24851ca-32aa-40e1-9db4-691da815ebe7%40mtasv.net.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1L1MzEsLmhR9xxyd0j-%3D7c_7Ak-gMz609m_D7sE2wfSmQ%40mail.gmail.com.


Re: [racket-users] [racket users] Macro literal "|"

2020-02-03 Thread Stephen Chang
As mentioned, to get your macro to work, you have to change how the
reader behaves on "|".

You might be interested in the (implementation of) no-vert-bar reader lang:

https://docs.racket-lang.org/no-vert-bar-lang/index.html

On Mon, Feb 3, 2020 at 6:27 PM Kevin Forchione  wrote:
>
> Hi guys,
> I’ve been  trying to figure out how to use “|” in a macro. I’ve got syntax 
> like this in mind:
>
> (foo A | B)
>
> Not sure if I can do this because the reader expects a pair. If “|” isn’t a 
> convenient literal to work with is there an alternative others have used that 
> represents more or less the idea of “or” or “alternate”?
>
> Thanks!
>
> Kevin
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/447100AA-DB45-46C3-A7DC-2705A1668302%40gmail.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1%2Br-Hg_yn-hhbEaZBjTLn8-v5MvqqAVitMrjj7BEGi40w%40mail.gmail.com.


Re: [racket-users] Re: expanding to typed/racket using #lang turnstile

2019-11-01 Thread Stephen Chang
I dont know much about J, but if I'm understanding correctly, you have
an implementation of J in Typed Racket?

And then you want to be able to infer more specialized cases in some
instances by pruning the type?

You might be able to do it with just plain macros in that case, which
would generate `ann` like William suggested to simplify some types.

Here's an example that does something similar for things like regexp:
https://blog.racket-lang.org/2017/04/type-tailoring.html

On Thu, Oct 31, 2019 at 5:06 PM Raoul Schorer  wrote:
>
> Thank you very much for taking the time to help me.
> I am trying to write an extendable APL with full type inference and optional 
> type annotation. Essentially, I am trying to compile J. J cannot be compiled 
> efficiently because the ambiguities of its grammar lead to combinatory 
> explosion of conditional branches in the resulting AST. The optional type 
> annotations would therefore allow to prune the AST.
>
> You can find an example of this problem here:
> https://www.reddit.com/r/apljk/comments/bw8s49/question_regarding_the_impossibility_of_compiling/epwfgfq/
>
> In practice, instead of writing
>
> g =: + f (1 2 3 4 5)
>
> where f has an ambiguous type (Union (-> (Array Number) (Array Number)) (-> 
> (-> Array Number) (-> Array Number))), I would write something like
>
> g =: + 3::f (1 2 3 4 5)
>
> Where 3:: represents a type annotation meaning (-> (Array Number) (Array 
> Number))
> Type inference in the language can however be derived directly from the 
> execution model represented by the parse table at 
> https://www.jsoftware.com/help/jforc/parsing_and_execution_ii.htm instead of 
> a traditional inference algorithm. You can find my stub attempt with 
> syntax/parse only at https://github.com/Rscho314/jacket/blob/master/parser.rkt
>
> Perhaps I should persevere with syntax/parse only? Or maybe it would be 
> better to use type.expanders in the codegen phase instead of trying to do all 
> at once with turnstile?
> I hope I am being clear. I'm just a hobbyist and have no formal CS education.
>
> Thanks again!
>
> Le mardi 29 octobre 2019 18:07:21 UTC+1, Raoul Schorer a écrit :
>>
>> Hi,
>>
>> I am attempting to expand to typed/racket from a custom language through 
>> #lang turnstile. Unfortunately, the macro stepper isn't helping me much as 
>> to how I should do that.
>> So far, this minimal example:
>>
>> #lang turnstile
>>
>> (require (only-in (prefix-in tr: typed/racket)
>>   tr:#%module-begin
>>   tr:Number
>>   tr:#%datum)
>>  turnstile/no-unicode)
>> (provide #%datum #%module-begin)
>>
>> ;[MODULE-BEGIN]
>> (define-syntax (#%module-begin stx)
>>   (syntax-parse stx
>> [(_ prg) #`(tr:#%module-begin prg)]))
>>
>> ;[DATUM]
>> (define-typed-syntax #%datum
>>   [(_ . n:number) >>
>>---
>>[/- (tr:#%datum . n) => tr:Number]])
>>
>> returns an error when I try to type a number in the REPL:
>> > 1
>>   type-check: type name used out of context
>>   type: tr:Number
>>   in: tr:Number in: tr:Number
>>
>> I am a bit lost. Could someone give me pointers on how to expand to 
>> typed/racket types using turnstile, please?
>>
>> Thanks a lot!
>> Raoul
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/99b623eb-fbd9-4dfa-b510-7451e4ef2dac%40googlegroups.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1Kv1USzz6tX5uwnLuDefMC_AOcyEwq95r0Ws4vSq9_xHg%40mail.gmail.com.


Re: [racket-users] expanding to typed/racket using #lang turnstile

2019-10-31 Thread Stephen Chang
As William mentioned, the example conflates Typed Racket types with
surface language types, which would probably not be right even if
Typed Racket did not complain.

Does your custom language have its own type system? If not, you may
not need to use Turnstile. Plain macros that expand to Typed Racket
might suffice.

To better help you, would you be willing to describe some more details
about your custom language?

On Tue, Oct 29, 2019 at 1:33 PM William J. Bowman
 wrote:
>
> This might be too minimal of an example.
> It looks like typed Racket doesn't want you to use Typed Racket types in 
> certain
> contexts.
> To implement the functionality I think you want from that example, I would
> write the following
>
> #lang turnstile
>
> (require (only-in (prefix-in tr: typed/racket)
>   tr::print-type
>   tr:ann
>   tr:#%module-begin
>   tr:Number
>   tr:#%datum)
>  turnstile/no-unicode)
> (provide #%datum (rename-out (tr:#%module-begin #%module-begin)))
>
> ;[DATUM]
> (define-typed-syntax #%datum
>   [(_ . n:number) >>
>---
>[≻ (tr:ann (tr:#%datum . n) tr:Number)]])
>
>
> You probably need to use a Turnstile types in your language, and generate 
> Typed
> Racket types using the `ann` form from Typed Racket.
>
> --
> William J. Bowman
>
> On Tue, Oct 29, 2019 at 10:07:21AM -0700, Raoul Schorer wrote:
> > Hi,
> >
> > I am attempting to expand to typed/racket from a custom language through
> > #lang turnstile. Unfortunately, the macro stepper isn't helping me much as
> > to how I should do that.
> > So far, this minimal example:
> >
> > #lang turnstile
> >
> > (require (only-in (prefix-in tr: typed/racket)
> >   tr:#%module-begin
> >   tr:Number
> >   tr:#%datum)
> >  turnstile/no-unicode)
> > (provide #%datum #%module-begin)
> >
> > ;[MODULE-BEGIN]
> > (define-syntax (#%module-begin stx)
> >   (syntax-parse stx
> > [(_ prg) #`(tr:#%module-begin prg)]))
> >
> > ;[DATUM]
> > (define-typed-syntax #%datum
> >   [(_ . n:number) >>
> >---
> >[/- (tr:#%datum . n) => tr:Number]])
> >
> > returns an error when I try to type a number in the REPL:
> > > 1
> >   type-check: type name used out of context
> >   type: tr:Number
> >   in: tr:Number in: tr:Number
> >
> > I am a bit lost. Could someone give me pointers on how to expand to
> > typed/racket types using turnstile, please?
> >
> > Thanks a lot!
> > Raoul
> >
> > --
> > 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.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/racket-users/b9b56563-3a18-406d-9f2f-935220673b79%40googlegroups.com.
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/20191029173336.GJ2191%40williamjbowman.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1KN78gy%2BM5FV2_6PkxGZgOPuyOp5cQCP0OBO2Q6_b2hNQ%40mail.gmail.com.


Re: [racket-users] Efficient idiom for converting key-set of a hash-map into a hash-set

2019-10-25 Thread Stephen Chang
I don't know of a more efficient way to convert, but depending on what
operations you want, you might be able to compute it directly on the
hash, e.g., see hash-has-key?, hash-keys-subset?, hash-union, etc. (I
didnt know about some of the functions until recently.)

On Fri, Oct 25, 2019 at 4:21 PM Sorawee Porncharoenwase
 wrote:
>
> It also might be worth trying `(for/set ([(k v) (in-hash h)]) k)`.
>
> On Fri, Oct 25, 2019 at 1:19 PM David Storrs  wrote:
>>
>> On Fri, Oct 25, 2019 at 10:28 AM Thomas Dickerson
>>  wrote:
>> >
>> > For reasons that are unclear to me, hash-keys and dict-keys both return a 
>> > list? instead of a set? (frankly, this seems like a bug in the API...).
>> >
>> > Is there a something I can do that's more efficient than just calling 
>> > list->set?
>>
>> You could do   '(apply set list-of-keys)', although I'm not sure if
>> that's more efficient or not.  You'd need to benchmark it.
>>
>>
>> >
>> > --
>> > 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.
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/racket-users/36eb8bd7-45eb-4ebb-be30-ebdfd89023fe%40googlegroups.com.
>>
>> --
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/CAE8gKodHgEeqffTCCSKDGP26jRt9oYmi42U0Vu%2BMyH6c2TQ5yw%40mail.gmail.com.
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CADcuegvk8wqkJsdJNqkQXSHi5FgYGZ4afRODYoZD8FnYmOcxVg%40mail.gmail.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1JXu_rEOP3V7vYO8oLW%2BfgOJrjK9%3DxXhr-WRYNvmVr6fQ%40mail.gmail.com.


Re: [racket-users] [ANN] RacketScript working for 7.x

2019-10-08 Thread Stephen Chang
> Does that include libraries like Pict, Pict3d, and the universe/world game 
> tools?

Ideally yes, though we have only bounced around ideas and do not have
a concrete plan.

There is, however, already support for 2htdp/image and 2htdp/universe.

I should have clarified that the functionality of RacketScript has not
changed. It is in the same experimental state and supports the same
subset of Racket as before.

On Wed, Oct 2, 2019 at 2:04 PM Hendrik Boom  wrote:
>
> On Wed, Oct 02, 2019 at 01:53:46PM -0400, Stephen Chang wrote:
> > The RacketScript compiler [1] has been updated to work with Racket 7.x
> > programs, ie all tests pass (though we are still working to support
> > more primitives).
> >
> > Try it out here: http://rapture.twistedplane.com:8080/
> >
> > The next milestone is to improve RacketScript enough to compile the
> > Racket expander [2], with the longer term goal being to self-host, so
> > programs may be independently compiled and run in the browser.
>
> Does that include libraries like Pict, Pict3d, and the universe/world
> game tools?
>
> -- hendrik
>
> >
> > If anyone is interested in helping out, let me know.
> >
> >
> > [1] https://github.com/vishesh/racketscript
> > [2] https://github.com/racket/racket/tree/master/racket/src/expander
> >
> > --
> > 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.
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msgid/racket-users/CAFfiA1LEwkRrYE56j7Y1tM%3D5ZJ4YmWXxtO3R7q26m7g%2Bq0FHRQ%40mail.gmail.com.
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/20191002180411.d4ekgdcp73cepvpq%40topoi.pooq.com.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1Lrb8oopxTVo7_A5D8%2BcumREuVToB6tW1YuO1JrmWXFoQ%40mail.gmail.com.


[racket-users] [ANN] RacketScript working for 7.x

2019-10-02 Thread Stephen Chang
The RacketScript compiler [1] has been updated to work with Racket 7.x
programs, ie all tests pass (though we are still working to support
more primitives).

Try it out here: http://rapture.twistedplane.com:8080/

The next milestone is to improve RacketScript enough to compile the
Racket expander [2], with the longer term goal being to self-host, so
programs may be independently compiled and run in the browser.

If anyone is interested in helping out, let me know.


[1] https://github.com/vishesh/racketscript
[2] https://github.com/racket/racket/tree/master/racket/src/expander

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1LEwkRrYE56j7Y1tM%3D5ZJ4YmWXxtO3R7q26m7g%2Bq0FHRQ%40mail.gmail.com.


Re: [racket-users] tex2page and Racket(latest version) problem

2019-06-30 Thread Stephen Chang
In case this issue is still unresolved, I just ran into this error
message because I accidentally installed a 64 bit distribution when I
needed 32-bit.

On Tue, Jun 16, 2015 at 12:11 PM Vincent St-Amour  wrote:
>
> Hi,
>
> How did you install Racket? It looks like you have used the wrong
> installer. You probably want the Mac OS 64 bit version.
>
> Vincent
>
>
> On Tue, 16 Jun 2015 07:21:30 -0500,
> youga wrote:
> >
> > I want to use tex2page on my mac. tex2page use a scheme compiler.
> > I follow the tex2page install, but I can't run it.
> >
> > Shell:
> > /usr/local/bin/tex2page: line 2: /usr/local/bin/racket: cannot execute 
> > binary file
> >
> > how to solve it?
> > thanks
> >
> > --
> > 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1JUHOSzqZ%2Bhg6yGv3m%3Db-tJTUq9HhV%2BJbH0coubyw6A1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Macro help

2019-05-24 Thread Stephen Chang
If `define-values` is not strictly required, here's a more
syntax-case-y recursive version:

(define-syntax (aux stx)
  (syntax-case stx ()
[(_) #'(begin)]
[(_ (var val) . rst)
 (identifier? #'var)
 #'(begin
 (define var val)
 (aux . rst))]
[(_ var . rst)
 (identifier? #'var)
 #'(begin
 (define var #f)
 (aux . rst))]))

On Fri, May 24, 2019 at 9:33 AM Matthias Felleisen
 wrote:
>
>
> Let me propose the use of syntax-parse as an alternative here. I think it 
> clarifies the purpose of the maco. — Matthias
>
>
> #lang racket
>
> (require (for-syntax syntax/parse))
>
> #; (aux a (b (* 2 pi)) c (d pi))
> ;; =>
> #; (define-values (a b c d) (values #f 6.28318530717958 #f 3.141592653589793))
>
>
> (begin-for-syntax
>   (define-syntax-class optionally-initiliazed
> (pattern (lhs:id rhs:expr))
> (pattern lhs:id #:attr rhs #'#f)))
>
> (define-syntax (aux stx)
>   (syntax-parse stx
> [(_ p:optionally-initiliazed ...) #'(define-values (p.lhs ...) (values 
> p.rhs ...))]))
>
> (aux a (b (* 2 pi)) c (d pi))
>
>
>
>
> On May 24, 2019, at 12:52 AM, Michael Murdock MacLeod 
>  wrote:
>
> Does this work? It uses a helper function, `prune`, to parse the var-val
> clauses.
>
> #lang racket
>
> (define-for-syntax (prune stx)
>  (syntax-case stx ()
>[()
> #'()]
>[((var val) others ...)
> (cons #'(var val)
>   (prune #'(others ...)))]
>[(var others ...)
> (cons #'(var #f)
>   (prune #'(others ...)))]))
>
> (define-syntax (aux stx)
>  (syntax-case stx ()
>[(_ terms ...)
> (with-syntax ([((var val) ...) (prune #'(terms ...))])
>   #'(define-values (var ...) (values val ...)))]))
>
> (aux a (b (* 2 pi)) c (d pi))
> a
> b
> c
> d
>
> ;; output shown below
>
> #f
> 6.283185307179586
> #f
> 3.141592653589793
>
> On Thursday, May 23, 2019 9:41:17 PM PDT Kevin Forchione wrote:
>
> Hi guys,
> I’ve been wracking my brains all day trying to come up with a macro that
> would convert this syntax:
>
> ;; (aux a (b (* 2 pi)) c (d pi))
> ;; => (define-values (a b c d) (values #f 6.28318530717958 #f
> 3.141592653589793)
>
>
> I’m missing some part of the picture. The closest I’ve come is to create a
> list of the pairs:
>
> #lang racket
>
> (define-syntax (aux stx)
>  (syntax-case stx ()
>[(_ (var val)) #'`((var ,val))]
>[(_ var) #''((var #f))]
>[(_ (var0 val0) var1 ...) #'(append `((var0 ,val0)) (aux var1 ...))]
>[(_ var0 var1 ...) #'(append '((var0 #f)) (aux var1 ...))]))
>
> (aux a (b (* 2 pi)) c (d pi)) ;=> '((a #f) (b 6.283185307179586) (c #f) (d
> 3.141592653589793))
>
>
> Any help is greatly appreciated!
>
> Kevin
>
>
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/2893163.LJ05K77S5N%40alphtsr.
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/A0B65B5E-0244-4E7C-89E5-24ED2CDF69EB%40felleisen.org.
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1%2BDYBrq_UutmwX5_sPatngCr%3DLkqFsczLxKn_rDBA%2BOrw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Cleanest way to 'if/then' inside a macro?

2019-05-15 Thread Stephen Chang
> For the same reasons I would use a `let` around a code block -- it's an easy 
> way to isolate computation and create reusable elements.  What would a more 
> normal way be when using syntax-parse?

The #:with syntax-parse "pattern directive" does the same thing, but
with less parens.
https://docs.racket-lang.org/syntax/stxparse-specifying.html?#%28tech._pattern._directive%29


> The syntax->datum part is because I want it to default to #t whereas 
> (attribute missing-optional-value) would be #f and offer no way to 
> distinguish between a missing argument (which should be interpreted as #t) 
> and an explicit #f.

I see. IMO it's awkward because it's trying to handle three cases for
only two possible outputs. I think the more Racket-standard way to do
this is to only have 2 possibilities: explicit argument or no
argument. See the struct options for examples, eg #:mutable or
#:omit-define-syntaxes



>> #lang racket
>> (require (for-syntax racket racket/syntax syntax/parse))
>> (define-syntax (foo stx)
>>   (syntax-parse stx
>> [(foo name (~optional flag))
>>  #:with propthing (if (attribute flag)
>>   #'(#:property prop:foo (delay "stuff"))
>>   #'())
>>  #`(begin
>>  (define-values (prop:foo foo? foo-ref)
>>(make-struct-type-property 'foo 'can-impersonate))
>>  (struct name (id) (~@ . propthing) #:transparent)
>>  (name 'bob))]))
>>
>> (foo person)
>> (foo thing #f)
>>
>> answer 3) A more "rackety" way would be if you included a part of the
>> output as the optional input. (this would invert your default case
>> though). This is the more natural use case for the ~? and ~@ patterns
>> because you no longer need the extra "if":
>>
>> #lang racket
>> (require (for-syntax racket racket/syntax syntax/parse))
>> (define-syntax (foo stx)
>>   (syntax-parse stx
>> [(foo name (~optional prop-val))
>>  #`(begin
>>  (define-values (prop:foo foo? foo-ref)
>>(make-struct-type-property 'foo 'can-impersonate))
>>  (struct name (id) (~? (~@ #:property prop:foo (delay
>> prop-val))) #:transparent)
>>  (name 'bob))]))
>>
>> (foo person)
>> (foo thing "stuff")
>
>
> Yep.  That's how I would have done it if the prop-val were something simple, 
> but this example was highly simplified for clarity  In point of fact the 
> contents of the `delay` are going to be a significant pile of reflectance 
> data built off the struct transformer.  Not something that the user should 
> care about aside from saying "yes, do / don't include this."
>
>>
>>
>> On Wed, May 15, 2019 at 10:56 AM David Storrs  wrote:
>> >
>> > I'd like to find a general mechanism, when writing macro code, to say "If 
>> > this optional argument was supplied, generate this code.  If not, generate 
>> > this other code", where "this other code" might be nothing at all.  I feel 
>> > like this should be simple, but my brain is failing.
>> >
>> > As an example, consider a macro that generates a struct; the macro has an 
>> > optional argument that controls whether a property is added, and it 
>> > defaults to 'add it'. I thought I could do the following, but it doesn't 
>> > compile because the bits aren't spliced properly and I'm not sure what I'm 
>> > missing.  Note that the syntax->datum part is because I want it to default 
>> > to #t whereas (attribute missing-optional-value) would be #f and offer no 
>> > way to distinguish between a missing argument and an explicit #f.  Again, 
>> > I feel like there should be a simpler way.
>> >
>> > #lang racket
>> > (require (for-syntax racket racket/syntax syntax/parse))
>> > (define-syntax (foo stx)
>> >   (syntax-parse stx
>> > [(foo name  (~optional arg:boolean))
>> >  (with-syntax ([propthing
>> > (if (syntax->datum #'(~? arg #t))
>> > #'(#:property prop:foo (delay "stuff"))
>> > #'())])
>> >#`(begin
>> >(define-values (prop:foo foo? foo-ref)
>> >  (make-struct-type-property 'foo 'can-impersonate))
>> >(struct name (id) (~@ propthing) #:transparent)
>> >(name 'bob)))]))
>> >
>> > (foo person)
>> > (foo thing #f)
>> >
>> >
>> >
>> >
>> >
>> > --
>> > 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.
>> > To view this discussion on the web visit 
>> > https://groups.google.com/d/msgid/racket-users/CAE8gKofM%3Dep0B%2BY0YXOq5uqooh-jDTBr7mZ9yDK%2BFrVVVbEHjA%40mail.gmail.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 

Re: [racket-users] Cleanest way to 'if/then' inside a macro?

2019-05-15 Thread Stephen Chang
answer 1) You are missing a dot in (~@ propthing), ie this will work:
(~@ . propthing)

minor question) is there a reason you are using with-syntax with syntax-parse?

answer 2) You may want to try "attribute". It's somewhat like
"syntax", except it returns false when there are unbound patvars, eg:

#lang racket
(require (for-syntax racket racket/syntax syntax/parse))
(define-syntax (foo stx)
  (syntax-parse stx
[(foo name (~optional flag))
 #:with propthing (if (attribute flag)
  #'(#:property prop:foo (delay "stuff"))
  #'())
 #`(begin
 (define-values (prop:foo foo? foo-ref)
   (make-struct-type-property 'foo 'can-impersonate))
 (struct name (id) (~@ . propthing) #:transparent)
 (name 'bob))]))

(foo person)
(foo thing #f)

answer 3) A more "rackety" way would be if you included a part of the
output as the optional input. (this would invert your default case
though). This is the more natural use case for the ~? and ~@ patterns
because you no longer need the extra "if":

#lang racket
(require (for-syntax racket racket/syntax syntax/parse))
(define-syntax (foo stx)
  (syntax-parse stx
[(foo name (~optional prop-val))
 #`(begin
 (define-values (prop:foo foo? foo-ref)
   (make-struct-type-property 'foo 'can-impersonate))
 (struct name (id) (~? (~@ #:property prop:foo (delay
prop-val))) #:transparent)
 (name 'bob))]))

(foo person)
(foo thing "stuff")


On Wed, May 15, 2019 at 10:56 AM David Storrs  wrote:
>
> I'd like to find a general mechanism, when writing macro code, to say "If 
> this optional argument was supplied, generate this code.  If not, generate 
> this other code", where "this other code" might be nothing at all.  I feel 
> like this should be simple, but my brain is failing.
>
> As an example, consider a macro that generates a struct; the macro has an 
> optional argument that controls whether a property is added, and it defaults 
> to 'add it'. I thought I could do the following, but it doesn't compile 
> because the bits aren't spliced properly and I'm not sure what I'm missing.  
> Note that the syntax->datum part is because I want it to default to #t 
> whereas (attribute missing-optional-value) would be #f and offer no way to 
> distinguish between a missing argument and an explicit #f.  Again, I feel 
> like there should be a simpler way.
>
> #lang racket
> (require (for-syntax racket racket/syntax syntax/parse))
> (define-syntax (foo stx)
>   (syntax-parse stx
> [(foo name  (~optional arg:boolean))
>  (with-syntax ([propthing
> (if (syntax->datum #'(~? arg #t))
> #'(#:property prop:foo (delay "stuff"))
> #'())])
>#`(begin
>(define-values (prop:foo foo? foo-ref)
>  (make-struct-type-property 'foo 'can-impersonate))
>(struct name (id) (~@ propthing) #:transparent)
>(name 'bob)))]))
>
> (foo person)
> (foo thing #f)
>
>
>
>
>
> --
> 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.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CAE8gKofM%3Dep0B%2BY0YXOq5uqooh-jDTBr7mZ9yDK%2BFrVVVbEHjA%40mail.gmail.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAFfiA1KCWzcg67HxkvUSikuwwZAXkeORmmz_2W2zB6MOJHW9UQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] https://lists.racket-lang.org/ is throwing a security exception

2019-05-06 Thread Stephen Chang
https for lists.racket-lang is not working at the moment. Sorry for
the inconvenience. The server hosting lists.racket-lang went down
recently. A partial temporary non-https version is up but https hasnt
been enabled yet.

On Mon, May 6, 2019 at 12:48 PM David Storrs  wrote:
>
> I'm not sure if this is relevant or not, but figured I'd mention it.  Is that 
> supposed to be working, or is it obsolete?  It does turn up in Google 
> searches, so maybe worth thinking about.
>
> --
> 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] Re: catch and bind an unbound id in a macro

2019-04-20 Thread Stephen Chang
fwiw, I think here is a working version along the lines of your
original attempt.

#lang racket
(require (for-syntax syntax/parse))

(define-syntax set/define
  (syntax-parser
[(_ h k v)
 #:when (with-handlers ([exn:fail:syntax:unbound? (lambda _ #f)])
  (local-expand #'h 'expression null))
 #'(hash-set! h 'k v)]
[(_ h k v)
 #'(begin
 (define h (make-hash))
 (hash-set! h 'k v))]))

(set/define h a 1)
(set/define h a 2)
(hash-set! h 'b 42)
h ; '#hash((b . 42) (a . 2))

(define bar (make-hash))
(set/define bar a 1)
bar ; '#hash((a . 1))

(define (foo)
  (set/define local-h a 1)
  (set/define local-h a 2)
  (hash-set! local-h 'b 42)
  local-h)

(foo) ; '#hash((b . 42) (a . 2))

On Sat, Apr 20, 2019 at 6:24 PM Shu-Hung You
 wrote:
>
> identifier-binding returns #f for top-level bindings. I believe
> make-base-eval is evaluating expressions at top-level.
>
> On Sat, Apr 20, 2019 at 4:56 PM Ryan Kramer  wrote:
> >
> > Below is a short example showing that identifier-binding doesn't seem to 
> > work quite right with Scribble's make-base-eval. It works fine with 
> > make-evaluator from racket/sandbox.
> >
> > I'm not sure why this is, but using syntax-local-value instead works 
> > everywhere. (Implementation here: 
> > https://github.com/default-kramer/plisqin/commit/2723d7c11be5b6938e681ea869e8b9f4957849b0#diff-1a91d998f2be05413392d588a89323d3R31)
> >
> > #lang racket
> > (require scribble/eval
> >  racket/sandbox)
> >
> > (define (setup eval)
> >   (eval
> >'(define-syntax (define-if-not stx)
> >   (syntax-case stx ()
> > [(_ id val)
> >  (identifier-binding #'id)
> >  #'(void)]
> > [(_ id val)
> >  #'(define id val)]
> >
> > (define scribble-eval (make-base-eval))
> > (scribble-eval '(require racket))
> > (setup scribble-eval)
> >
> > (define racket-eval (make-evaluator 'racket))
> > (setup racket-eval)
> >
> > (scribble-eval '(define-if-not foo 1))
> > (scribble-eval '(define-if-not foo 2))
> > (scribble-eval 'foo) ; want 1, get 2
> >
> > (racket-eval '(define-if-not bar 3))
> > (racket-eval '(define-if-not bar 4))
> > (racket-eval 'bar) ; want 3, get 3
> >
> > --
> > 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] Racket 5, multiple-collection packages and info.rkt

2018-12-12 Thread Stephen Chang
Hi Claes, Thanks for the effort in splitting the package.

Would any users of the graph library object to dropping support for 5.x?
On Tue, Dec 11, 2018 at 10:19 PM Claes Wallin (韋嘉誠)
 wrote:
>
> I am trying to split the package graph into graph-doc and graph-lib,
> see: https://github.com/stchang/graph/pull/37
>
> So far, the package has been compatible with Racket 5.3.2, and I image
> the original author Mr. Chang would like to keep it that way, if
> possible.
>
> In their respective graph/info.rkt (until now a single file, now split
> into two files), graph-lib wants to define test-timeouts and graph-doc
> wants to define scribblings. On Racket 6 this is fine, but on Racket
> 5[0] I get:
>
>raco pkg install: packages conflict
>   package: ./graph-lib
>   package: graph-doc
>   file: graph/info.rkt
>
> If I remove graph-doc/graph/info.rkt, the documentation does not get built.
>
> Do we have to drop Racket 5 compatibility to split this package in two?
>
> [0] not on Racket 5.92, but I guess that would be more appropriately
> named something like 6.0rc or 6.0pre?
>
> - - - -
>
> I looked in Racket 5.93 and there pkgs/net-pkgs/net-doc/net didn't
> have an info.rkt. How did the documentation get built? Is there some
> special workaround for release packages?
>
> On Racket 5.3.6 and earlier the release packages weren't separate
> packages, they were simply in core collects, and I assume there was no
> racket-minimal? So I have nothing to learn from by looking there.
>
> --
>/c
>
> --
> 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] what do people use for number formatting?

2018-05-07 Thread Stephen Chang
Oops, I didnt see the rounding.

On Mon, May 7, 2018 at 7:53 PM, Ben Greenman
 wrote:
> I use this:
> http://docs.racket-lang.org/gtp-util/index.html#%28def._%28%28lib._gtp-util%2Fmain..rkt%29._rnd%29%29
>
> I didn't know about SRFI 54 --- looking forward to reading other responses.
>
> --
> 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] what do people use for number formatting?

2018-05-07 Thread Stephen Chang
~r
http://docs.racket-lang.org/reference/strings.html?q=~r#%28def._%28%28lib._racket%2Fformat..rkt%29._~7er%29%29

On Mon, May 7, 2018 at 7:46 PM, 'John Clements' via Racket Users
 wrote:
> Okay, how many times have I written the function that accepts 1.237472387 and 
> returns “1.24” ? What do you folks use? I see that SRFI 54 covers this use 
> case, and a lot of others besides. Is this the most commonly used package for 
> formatting numbers?
>
> John
>
>
>
> --
> 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] Is it possible to pass syntax information from bottom up?

2018-04-18 Thread Stephen Chang
Here's a version of your program that performs as you specified:
http://pasterack.org/pastes/91460

But do take a look at the paper, docs [1], or codebase [2], which
turns this idea into complete languages.

[1]: http://docs.racket-lang.org/turnstile/index.html
[2]: https://github.com/stchang/macrotypes

On Wed, Apr 18, 2018 at 9:39 AM, Matthias Felleisen
 wrote:
>
> You want to look at Stephen's Turnstile, a DSL for making typed DSLs and 
> macros. Like all type systems, this is exactly what it does.
>
> Here is the link to the paper:
>
>  https://www2.ccs.neu.edu/racket/pubs/#popl17-ckg
>
> It obscures what you need, which is a combination of local-expand, 
> syntax-parse and its various hooks. The rough idea is to locally expand a 
> given phrase and to expand in such a way that macros return two pieces of 
> information: the expanded syntax and the additional property. You can try to 
> encode this with
>
> #'(begin expanded-code property)
>
> or just use a syntax-property, whatever fits best. When the local-expand 
> returns, take apart the macro and re-do the same thing.
>
> Details in the implementation.
>
> You may also wish to look at the implementation of Alexis’ Hackett.
>
>
>
>
>
>
>> On Apr 18, 2018, at 8:40 AM, Dmitry Pavlov  wrote:
>>
>> Hello,
>>
>> I am looking for an advice on how to write a macro that is aware of the 
>> information extracted from syntax objects from another macro that is called 
>> "inside" the first one. For instance, let it be the (this) macro that 
>> detects if its argument is an integer or float, and let it be the (print) 
>> macro that should emit the according printing command -- at compile time.
>>
>> Here is a stub (not working) to show what I am trying to achieve:
>>
>> #lang racket/base
>>
>> (require racket/format
>>  (for-syntax syntax/parse)
>>  (for-syntax racket/base))
>>
>> (define-syntax (print stx)
>>   (syntax-parse stx
>> (((~literal print) expr)
>>  (if #t ;; need some condition here that knows whether expr is an 
>> integer or a float
>>  (syntax/loc stx
>>(displayln (~r expr #:notation 'positional #:precision '(= 2
>>  (syntax/loc stx
>>(printf "~a\n" expr))
>>
>> (define-syntax (this stx)
>>   (syntax-parse stx
>> (((~literal this) (expr ...))
>>  (syntax/loc stx (expr ...))
>>  )
>> (((~literal this) datum)
>>  (if (exact? (syntax->datum #'datum))
>>(printf "we know at compile time that is is an integer\n")
>>(printf "we know at compile time that is is a float\n"))
>>  (syntax/loc stx datum
>>
>>
>> (print (this (this (this 123
>> (print (this (this (this 456.0
>>
>>
>> How do I achieve that (print) knows which number is in (this) down there?
>> I thought about (syntax-property), but it does not work, either because I am 
>> misapplying it, or because of the way the syntax expander works.
>>
>> I also tried to (expand-syntax) to get the syntax expander work bottom-up, 
>> but eventually decided that it can not work too, or I do not understand how 
>> it should work.
>>
>> The other option that I see is "manual" processing of the whole syntax tree 
>> after the (syntax-parse) did its job. But it seems a bit extra for the task. 
>> Is it the only way?
>>
>> Best regards,
>>
>> Dmitry
>>
>>
>> --
>> 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] Reimplementing Hackett’s type language: expanding to custom core forms in Racket

2018-04-17 Thread Stephen Chang
Hi Alexis,

Great article. And timely too, since it addresses some of the same
usage issues of local-expand and stoplists that we ran into with
Turnstile.

(I'm also interested in why the core forms are added to the stop list.
Is it because of let-syntax? I know it's probably been mentioned
before but I wasn't able to find an explanation in the docs or
archive.)

Specifically, we (Michael Ballantyne) recently added stoplists for
terms, but we're still experimenting with the right representation for
types.

In our experimentation we manually implemented the recursive,
stop-listed expansions like you did (but it wasny as elegant as your
syntax classes). I eventually ran into the same issue with binding
types and passing the context, so it was good to see a solution worked
all the way through, and written up nicely.

In the future, I would love to receive notification about any new blog posts.

On Sun, Apr 15, 2018 at 10:38 AM, David Thrane Christiansen
 wrote:
> Hi Alexis,
>
> I am very happy to have posts like this announced here. Thanks for writing
> it! It was useful and interesting.
>
> David
>
> On Sun, Apr 15, 2018, 06:58 Alexis King  wrote:
>>
>> Hello all,
>>
>> I wrote a blog post about my recent experience rewriting the
>> implementation of Hackett’s internal type representation, and on writing
>> languages that expand to custom core forms in Racket in general. For
>> those interested in Hackett and/or (ab)uses of some of the lesser-known
>> features of Racket’s macro system, you might be interested:
>>
>>
>> https://lexi-lambda.github.io/blog/2018/04/15/reimplementing-hackett-s-type-language-expanding-to-custom-core-forms-in-racket/
>>
>> I’ve refrained in the past from posting my blog to this list, since it
>> does not seem like something other people normally do and many of the
>> interested parties seem to find it through some other channel. Still, I
>> thought I’d try posting it here this time. Feedback is welcome and
>> appreciated, both on the blog post itself and on whether or not people
>> appreciate posting things like this to this list.
>>
>> Alexis
>>
>> --
>> 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] sharing an awesome plot - warms the cockles of my heart

2018-03-24 Thread Stephen Chang
For those who don't have drracket handy: http://pasterack.org/pastes/59296

On Mar 24, 2018 4:26 PM, "Jos Koot"  wrote:
>
> Very nice,
> Jos Koot
>
> 
> From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On 
> Behalf Of Sanjeev Sharma
> Sent: 23 March 2018 22:17
> To: Racket Users
> Subject: [racket-users] sharing an awesome plot - warms the cockles of my 
> heart
>
> I've done no math in 20 years - used to do tons (with the not so great 
> graphics of the time) saw this intriguing plot & banged my head against a 
> wall for a couple of hours.
>
> Then I just settled down & read the manual systematically, pretending it may 
> have some info,  followed the examples and voila
>
> (require plot)(plot-new-window? #t)
> (define(xu u)(*(sin(* 33 u))(cos(* 9 u
> (define(yu u)(*(sin(* 49 u))(sin(* 7 u
> (plot(parametric(λ(t)(vector(xu t)(yu t)))0 1));
>
>
> --
> 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] running tests with different #langs

2018-03-23 Thread Stephen Chang
I frequently want to run the same tests with different #lang's.

Has anyone written a test harness that lets me do this without
duplicating the test code? (I couldnt find anything on the pkg
server.)

-- 
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] "Site not secure"

2018-03-09 Thread Stephen Chang
It's fixed now. Cron job didn't run for some reason. Thanks for the heads up!

On Fri, Mar 9, 2018 at 12:42 PM, 'John Clements' via Racket Users
 wrote:
>
>
>> On Mar 9, 2018, at 8:25 AM, Tim Hanson  wrote:
>>
>> Hi, I tried to grab the latest racket version from download.racket-lang.org 
>> and chrome and edge tell me the certificate of the site at 
>> mirror.racket-lang.org is not yet valid or expired. It's no problem as I 
>> found a mirror with a valid certificate, but I guess you'll want to renew 
>> the certificate.
>
> Yep, I see this too. Certificate expired on March 8th at 11:42 AM (PST, 
> presumably).
>
> John
>
>
>
>
>
> --
> 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] weak references and quoted values

2017-09-07 Thread Stephen Chang
Ran into some unexpected behavior today. Quoted values do not seem to
be garbage collected when there are only weak references. Is this
correct behavior?


Here's an example program:

#lang racket/base

(define key1 (list 1))
(define key2 '(1))

(define hash1 (make-weak-hash (list (cons key1 1
(define hash2 (make-weak-hash (list (cons key2 1

hash1
hash2

(set! key1 null)
(set! key2 null)

(collect-garbage) ; I tried a range of gc pressure here with no difference

hash1
hash2


I expected it to produce:

'#hash(((1) . 1))
'#hash(((1) . 1))
'#hash()
'#hash()

But instead got:

'#hash(((1) . 1))
'#hash(((1) . 1))
'#hash()
'#hash(((1) . 1))


Searching through the docs I found the following line [1] that maybe
explains the behavior (but I'm not sure)?

"Values produced by quote remain reachable when the quote expression
itself is reachable."

Is this saying that since the quoted value is reachable via the weak
reference, it is considered reachable?

[1] http://docs.racket-lang.org/reference/eval-model.html?#%28part._gc-model%29

-- 
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] immutable hash table references?

2017-05-24 Thread Stephen Chang
I believe Racket uses HAMTs [1] for immutable hash tables.

[1]: http://lampwww.epfl.ch/papers/idealhashtrees.pdf

On Wed, May 24, 2017 at 11:01 AM, 'John Clements' via users-redirect
 wrote:
> I’m introducing hash tables to students in a first-year class. Is there a 
> handy reference for the implementation of immutable hash tables? Is this in 
> Okasaki?
>
> John
>
>
>
> --
> 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] Re: syntax expands to define syntax, problems with ...

2017-03-15 Thread Stephen Chang
The inner ellipses need to be "escaped". I like using the dot notation
in nested macros but I know others do not like that style.

(define-syntax (test stx)
  (syntax-case stx ()
((_ n e ...)

 #'(define-syntax (n stx)
 (syntax-case stx ()
   ((_ e0 (... ...))
#'(n (e ...) e0 (... ...))
))

On Wed, Mar 15, 2017 at 12:33 PM, Dan Liebgold
 wrote:
> Here's what works, not using the inner ellipses:
>
> http://pasterack.org/pastes/34338
>
> But I'd prefer to use the ellipses..
>
> --
> 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] help with splicing syntax class error report

2017-03-14 Thread Stephen Chang
You get the dreaded "bad syntax" because syntax-parse doesnt know
which pattern failed. There a couple of things you can do:

1) Use a commit pattern, which tells syntax-parse not to backtrack
past the commit point. You have to change the order of patterns for
this to work.

  (define-splicing-syntax-class maybe
#:datum-literals (:thing)
(pattern (~seq) #:attr n #'0)
(pattern (~seq ~! :thing n:id)))

2) Use the ~post pattern, which essentially tells syntax-parse to give
priority to a particular pattern.

  (define-splicing-syntax-class maybe
#:datum-literals (:thing)
(pattern (~post (~seq :thing n:id)))
(pattern (~seq) #:attr n #'0))

On Tue, Mar 14, 2017 at 1:13 PM, Dan Liebgold
 wrote:
> Hi -
>
> I have some legacy code syntax I'm retrofitting with syntax-parse. Is there a 
> simple way to have this type of syntax error report a better error message:
>
> http://pasterack.org/pastes/59739
>
> I'd like it to point directly to ":thung" and say it expected ":thing" or 
> nothing there if possible.
>
> Thanks,
> Dan
>
> --
> 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] create a new provide syntax

2017-03-10 Thread Stephen Chang
combine-out may help simplify things?

(define-syntax my-out
  (make-provide-transformer
   (lambda (stx modes)
 (syntax-parse stx
   ((_ name:id)
#:with mk-name (format-id #'name "make-~a" #'name)
(expand-export #'(combine-out name mk-name) modes))

or

(define-provide-syntax my-out
  (syntax-parser
[(_ name:id)
 #:with mk-name (format-id #'name "make-~a" #'name)
 #'(combine-out name mk-name)]))


On Fri, Mar 10, 2017 at 1:25 PM, Dan Liebgold
 wrote:
> Hi -
>
> I'd like to create a new provide syntax that essentially turns this:
>
>   (provide (my-out name))
>
> into this:
>
>   (provide name make-name)
>
> where 'name' and 'make-name' are defined in the surrounding context. It looks 
> like define-provide-syntax isn't up to the task, so I used 
> 'make-provide-transformer' directly, like so:
>
> (define-syntax my-out
>   (make-provide-transformer
>(lambda (stx modes)
>  (syntax-parse stx
>((_ name:id)
> (let ([nt #'name]
>   [c (format-id #'name "make-~a" (syntax-e #'name))])
>   (list (make-export nt (syntax-e nt) 0 #f nt)
> (make-export c (syntax-e c) 0 #f c)
> )))
>
>
> Is there a more concise way of doing this?
>
> Thanks,
> Dan
>
> --
> 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] scribble section as link

2017-03-04 Thread Stephen Chang
Ah, I understand now. I remember trying to do this as well but I'm not
sure it's possible.

I just tried manually playing around a bit with scribble structs but
couldnt figure it out. Best I could do was redirecting a seclink, or
changing the toc contents of an element.

But there doesnt seem to be any way to change the toc contents of a
part (someone correct me if I'm wrong).

Here's my code in case it's helpful.

#lang scribble/manual
@(require scribble/core
  scribble/html-properties
  net/url)
@title{asdf}
@section[#:style (make-style #f (list (make-part-link-redirect
(string->url "http://google.com; #:tag "a"]{A}
@section{@seclink["a"]{link to sec A (goes to google)}}

@(make-toc-target2-element #f "stuff" '(element "stf")
@hyperlink["http://google.com"]{link to "stuff" (try to redirect to
google but doesnt work)"})

On Sat, Mar 4, 2017 at 2:38 PM, David Van Horn <dvanh...@cs.umd.edu> wrote:
> The latex analogy of what I'd like is something like:
>
> \addcontentsline{toc}{section}{\href{google.com}{The Google}}
>
> On Sat, Mar 4, 2017 at 2:30 PM, David Van Horn <dvanh...@cs.umd.edu> wrote:
>> Thanks, this does make the section heading a link, but in the table of
>> contents or in the left hand navigation bar, the link is to the
>> (empty) section, not the URL.  What I'd like is for the navigation
>> links to go to the URL.
>>
>> David
>>
>>
>> On Sat, Mar 4, 2017 at 2:06 PM, Stephen Chang <stch...@ccs.neu.edu> wrote:
>>> Does `hyperlink` do what you want?
>>>
>>> eg
>>>
>>> @section{@hyperlink["http://google.com"]{The Google}}
>>>
>>> On Sat, Mar 4, 2017 at 1:49 PM, David Van Horn <dvanh...@cs.umd.edu> wrote:
>>>> I'm using scribble to make a web page and I'd like a section-like
>>>> heading that is just a link to an external URL, but I don't see how to
>>>> do this.  Is it possible?
>>>>
>>>> David
>>>>
>>>> --
>>>> 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] scribble section as link

2017-03-04 Thread Stephen Chang
Does `hyperlink` do what you want?

eg

@section{@hyperlink["http://google.com"]{The Google}}

On Sat, Mar 4, 2017 at 1:49 PM, David Van Horn  wrote:
> I'm using scribble to make a web page and I'd like a section-like
> heading that is just a link to an external URL, but I don't see how to
> do this.  Is it possible?
>
> David
>
> --
> 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] Idiomatic way to include numbers in a map?

2017-03-02 Thread Stephen Chang
Not with map, which requires equal-length arguments.

You could do the slightly less ugly:

(map
foo
lst-A
lst-B
(range (length lst-A)))


On Thu, Mar 2, 2017 at 11:14 AM, David Storrs <david.sto...@gmail.com> wrote:
>
>
> On Thu, Mar 2, 2017 at 10:09 AM, Stephen Chang <stch...@ccs.neu.edu> wrote:
>>
>> The in-X forms are sequences, and must be used with the sequence API, ie
>> for/X.
>>
>> map only works with lists, so you could use build-list or range:
>> (map
>> foo
>> lst-A
>> lst-B
>> (range 2))
>>
> Is there a way to do it if I don't know how many items will be in the list?
> What I want is to say "just keep sticking numbers in until one of the lists
> runs out."  I could say (range 1) but that's ugly.
>
>
>>
>> On Thu, Mar 2, 2017 at 9:55 AM, David Storrs <david.sto...@gmail.com>
>> wrote:
>> > I'd like to be able to do something like this:
>> >
>> > (struct foo (a b c))
>> > (define lst-A '(a b))
>> > (define lst-B '(d e))
>> > (map
>> > foo
>> > lst-A
>> > lst-B
>> > (in-naturals))
>> >
>> > I'd expected this to produce:  (foo 'a 'd 0) (foo 'b 'e 1), but instead
>> > it
>> > throws an exception "expected list, given stream".  I could do it with a
>> > for/list but that's much more verbose.  What would be the idiomatic way
>> > of
>> > doing this?
>> >
>> > --
>> > 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] Idiomatic way to include numbers in a map?

2017-03-02 Thread Stephen Chang
The in-X forms are sequences, and must be used with the sequence API, ie for/X.

map only works with lists, so you could use build-list or range:
(map
foo
lst-A
lst-B
(range 2))

On Thu, Mar 2, 2017 at 9:55 AM, David Storrs  wrote:
> I'd like to be able to do something like this:
>
> (struct foo (a b c))
> (define lst-A '(a b))
> (define lst-B '(d e))
> (map
> foo
> lst-A
> lst-B
> (in-naturals))
>
> I'd expected this to produce:  (foo 'a 'd 0) (foo 'b 'e 1), but instead it
> throws an exception "expected list, given stream".  I could do it with a
> for/list but that's much more verbose.  What would be the idiomatic way of
> doing this?
>
> --
> 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] Package layout in docs

2017-01-29 Thread Stephen Chang
I like the current structure of the docs but Ethan's comments reminded
of recent blog posts by Eric Raymond (of "Cathedral and the Bazaar"
fame), who surprisingly advocates against "swarm design". The posts
are about Rust but maybe it's something to keep in mind if the package
system gets much large.

[1]: http://esr.ibiblio.org/?p=7294
[2]: http://esr.ibiblio.org/?p=7303

On Sun, Jan 29, 2017 at 8:45 AM, Matthew Flatt  wrote:
> At Sat, 28 Jan 2017 22:51:43 -0800 (PST), Ethan Estrada wrote:
>> My only real beef with the Racket docs are the layout of packages;
>> there is no clear distinction between docs for standard library items
>> and docs for community provided libs.
>
> That's intentional. I'd say that the absence of a line that
> distinguishes "Racket" from "not Racket" at the package level is an
> extrapolation of our goal to avoid a line between the "language" and
> "library" at the level of a module.
>
> There are certainly some drawbacks to allowing any old module to add
> new constructs to the programming language, but we think the benefits
> outweigh the drawbacks. Similarly, there are some drawbacks to allowing
> any old package to have the same status as the base system, but I
> believe in the benefits.
>
> In both cases, it's important that programmers have control over what
> is used and what isn't used. The module system enforces boundaries so
> that a module added to a program can't have an arbitrary effect on
> other modules in the program. Similarly, the package system is intended
> to give the programmer control over what packages are installed and how
> they are installed.
>
> I'm not objecting to improvement here --- just trying to clarify why
> the current organization is like that.
>
> Also, I'd concede that we have a notion of "main distribution", which
> identifies a set of packages that are included in the Racket installers
> at racket-lang.org. That's a useful concept, but I see it as a
> compromise, and I'm reluctant to reflect that distinction in the
> documentation.
>
> --
> 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] specify test timeout for pkg-build?

2017-01-27 Thread Stephen Chang
I have a package whose tests are timing out when run by pkg-build. Is
there a way to extend this timeout?

I know I can specify individual file timeouts with `test-timeouts` but
I couldnt figure out how to specify a timeout for testing the whole
package. Is this possible?

Steve

-- 
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] Client side web applications in Racket

2017-01-22 Thread Stephen Chang
> Do you have plans to revist the tail call question within RacketScript?

Yes we do. The readme includes that statement just to be upfront with
users about racketscript's philosophy and what to expect when trying
racketscript.

That being said, RacketScript currently converts self-tail-calls to
loops, which is already on par with some industrially-used functional
language js compilers, so we conjecture that racketscript's tail call
handling is already sufficient for a wide variety of applications.

Of course, we would also be happy to learn of any deficiencies. Even
though Racketscript is still immature and unstable, we welcome
feedback and contributions from the community to help shape
Racketscript's development.


> TCO
> is essential to idiomatic Scheme, and (while Racket is not Scheme, and has
> grown other noteworthy strengths, and people have less interest in learning
> algorithm crafting than they used to) I think TCO still has a lot of merit,
> and should not be discarded lightly.
>
> Not many people will mind if you discard first-class continuations, however.
> :)
>
>
> --
> 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] syntax-property lost across module boundary (WAS: format-id doesn't preserve preserved?-edness of syntax-property?)

2016-12-15 Thread Stephen Chang
> What are the implications of this for the Types as Macros/Turnstile
stuff?

As William mentioned, he's also working on a language using the Types
as Macros approach. Alex and I have run into the same issue, but it's
always with compiled files (without compiling, requires and provides
appear to behave as expected). Unfortunately, we have not figured out
a good solution either. Could we borrow any ideas from Typed Racket
here?

> but I’d like to know if I’m relying on some sort of undefined behavior

In some sense, the entire Types as Macros approach is "undefined
behavior" :/ because we are using the expander for unintended
purposes. So thank you (and William and everyone else that has tried
it out) for diving in and helping us figure out what works and what
needs more work.

But now that we've shown that such an approach is both viable and
wanted by Racket programmers, for the rough parts where we cannot find
a good solution, the next step might be to address these issues with
contributions to the expander itself.

Just to throw them out there, other issues that I'm working on (in
addition to scopes on stx props) are:
- Better support (over stop lists) for "delimited" expansion. For
example, I often want to "fully expand an expression, but not past a
specified language".
- Better support for expanding expressions with free identifiers in a context.
- Better support for mapping stx objs back to the surface stx, in a
hygienic way.

On Wed, Dec 14, 2016 at 6:50 PM, Alexis King  wrote:
>> On Dec 14, 2016, at 7:14 AM, Matthew Flatt  wrote:
>>
>> To summarize, don't try to attach syntax objects as property values
>> like that. I know this advice sounds ironic, given that the original
>> use of properties was for syntax-valued keys like 'origin. Properties
>> like 'origin are meant to be extracted from just-expanded programs,
>> though, as opposed to used in a later compilation step. At the same
>> time, those uses of properties are why we can't just make
>> `syntax-property` reject property values that are syntax objects.
>
> What are the implications of this for the Types as Macros/Turnstile
> stuff that Stephen and Alex have been working on, given that they
> use heavily use syntax objects in syntax properties as part of
> attaching type information to identifiers? Are they doing something
> to work around this and/or using properties in a way that avoids
> this issue? Or is it likely that they’ll run into this for programs
> that span multiple modules?
>
> (Obviously, I have a personal motive for asking this question, since
> I’ve been playing with Turnstile and the techniques it uses myself.
> So far I’ve been able to write programs that span multiple modules
> without much issue, modulo an issue I asked about on this mailing
> list a month or two back, but I’d like to know if I’m relying on
> some sort of undefined behavior.)
>
> --
> 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] hyperlink in code:comment

2016-11-30 Thread Stephen Chang
Each code formatting form, like `racketblock`, allows specifying an
escape identifier for use within that form, though all forms default
to `unsyntax` if unspecified, I believe. Some forms, like `codeblock`
do not support escapes.

The docs here [1] has more details, and specifically the docs for
racketblock [2] has more examples.


[1]: http://docs.racket-lang.org/scribble/scribble_manual_code.html
[2]: 
http://docs.racket-lang.org/scribble/scribble_manual_code.html?#%28form._%28%28lib._scribble%2Fmanual..rkt%29._racketblock%29%29

On Tue, Nov 29, 2016 at 3:42 PM, Jos Koot <jos.k...@gmail.com> wrote:
> Thanks, I'll try that.
> It is not clear to me where I can use @#,
> But certainly your response will be a great help for me.
> Thanks again, Jos
>
> -Original Message-
> From: stchang...@gmail.com [mailto:stchang...@gmail.com] On Behalf Of Stephen 
> Chang
> Sent: martes, 29 de noviembre de 2016 21:31
> To: Jos Koot
> Cc: Racket Users
> Subject: Re: [racket-users] hyperlink in code:comment
>
> You can use the escape identifier:
>
> #lang scribble/manual
>
> @(require scribble/eval
>   (for-label racket))
>
> @interaction[
>  (define a (list 1))
>  (define b (list 1))
>  (code:comment @#,para{a and b are not @racket[eq?], but they are
> @racket[equal?]:})
>  (eq? a b)
>  (equal? a b)]
>
> On Tue, Nov 29, 2016 at 2:56 PM, Jos Koot <jos.k...@gmail.com> wrote:
>> A simplified fragment of scribble code:
>>
>> #lang scribble/manual
>>
>> @(require scribble/eval)
>>
>> @interaction[
>>  (define a (list 1))
>>  (define b (list 1))
>>  (code:comment "a and b are not eq, but they are equal:")
>>  (eq? a b)
>>  (equal? a b)]
>>
>> Within the comment I would like to hyperlink 'eq' to the doc of [eq?]
>> and 'equal' to the doc of [equal?]
>>
>> Is this possible?
>> If so how?
>> I have tried it without success.
>>
>> Thanks, Jos
>>
>> --
>> 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] hyperlink in code:comment

2016-11-29 Thread Stephen Chang
You can use the escape identifier:

#lang scribble/manual

@(require scribble/eval
  (for-label racket))

@interaction[
 (define a (list 1))
 (define b (list 1))
 (code:comment @#,para{a and b are not @racket[eq?], but they are
@racket[equal?]:})
 (eq? a b)
 (equal? a b)]

On Tue, Nov 29, 2016 at 2:56 PM, Jos Koot  wrote:
> A simplified fragment of scribble code:
>
> #lang scribble/manual
>
> @(require scribble/eval)
>
> @interaction[
>  (define a (list 1))
>  (define b (list 1))
>  (code:comment "a and b are not eq, but they are equal:")
>  (eq? a b)
>  (equal? a b)]
>
> Within the comment I would like to hyperlink 'eq' to the doc of [eq?]
> and 'equal' to the doc of [equal?]
>
> Is this possible?
> If so how?
> I have tried it without success.
>
> Thanks, Jos
>
> --
> 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] Using the graph library

2016-10-31 Thread Stephen Chang
Hi Lawrence,

Can you  provide some more context? Are you looking to learn about
graphs in general, or specifically about the graph library API.

For the former, any well known algorithms textbook should have a
decent introduction. I used CLRS [1] as a guide when developing the
library.

For the latter, take a look at the example programs included with the
library [2]. If things are still confusing, I'm open to feedback on
which specific components could be improved.

[1]: https://mitpress.mit.edu/books/introduction-algorithms
[2]: https://github.com/stchang/graph/tree/master/graph/tests

On Sat, Oct 29, 2016 at 2:59 PM, Lawrence Bottorff  wrote:
> I see the Racket Generic Graph Library, but I don't know how to use it. Where 
> would one go to learn, tutorial-style" the ins and outs of using this 
> library? I take it this library allows you to "roll your own" graph database? 
> I did notice the HTDP has a section on graph things. Would this help?
>
> LB
>
> --
> 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] How to 'apply' a function with optional parameters?

2016-10-29 Thread Stephen Chang
string-join already expects a list of strings, so are you sure you want apply?
Can you give a more specific example?

Perhaps map or some other iteration is what you want?

(for ([strs '(("a" "b") ("c" "D" "E"))])
  (displayln (string-join strs " ")))

=>
a b
c D E

On Sat, Oct 29, 2016 at 10:27 AM,   wrote:
> Hi,
>
> ...still improving my shortwave-broadcaster-dumper... :)
>
> I have a list with sublists of strings, which I want to concatenate.
> Each sublist shall form one line of output.
> I tried 'string-append', but this gives me something like this
> (excerpt):
> "189RikisutvarpidRas1+2-24001234567Icelandic"
> ...the separating #\space is missing.
>
> The according code looks like this (excerpt)
>
> (apply string-append sublist)
>
> then I found 'string-join' which has extra-parameters
> to define separator of all kinds.
>
> ...but...how can I express the 'apply'-instruction...with the
> addional parameters???
>
> This looks something inbetween funny and weird:
>
> (apply string-join sublist " ")
>
> and racket mumbles:
> apply: contract violation
>   expected: list?
>   given: " "
>   argument position: 3rd
>   other arguments...:
>#
>
>
> ?
>
> Cheers
> Meino
>
>
>
>
>
> --
> 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] is there a way to syntax-local-lift- something into a define-syntax?

2016-10-09 Thread Stephen Chang
Yes, that worked. Thanks.

On Sun, Oct 9, 2016 at 8:11 AM, Matthew Flatt <mfl...@cs.utah.edu> wrote:
> Does `syntax-local-lift-module-end-declaration` work?
>
> At Sat, 8 Oct 2016 19:29:19 -0400, Stephen Chang wrote:
>> I'm trying to write a provide transformer that wraps a provided
>> identifier and then provides that instead.
>>
>> For example,
>> #lang racket
>> (require (for-syntax syntax/parse racket/provide-transform))
>>
>> (define-syntax wrapped-out
>>   (make-provide-pre-transformer
>>(lambda (stx modes)
>>  (syntax-parse stx
>>[(_ f)
>> #:with wrapped-f
>> (syntax-local-lift-expression
>>  #'(lambda args (display "applying ") (displayln 'f)
>> (apply f args)))
>> (pre-expand-export
>>  #'(rename-out [wrapped-f f]) modes)]
>>
>> (provide (wrapped-out +))
>>
>> A program requiring my module and using addition will print "applying +".
>>
>> But I actually want to wrap f with a macro. Is this possible? (Is this
>> an XY problem?)
>
> --
> 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] is there a way to syntax-local-lift- something into a define-syntax?

2016-10-08 Thread Stephen Chang
I'm trying to write a provide transformer that wraps a provided
identifier and then provides that instead.

For example,
#lang racket
(require (for-syntax syntax/parse racket/provide-transform))

(define-syntax wrapped-out
  (make-provide-pre-transformer
   (lambda (stx modes)
 (syntax-parse stx
   [(_ f)
#:with wrapped-f
(syntax-local-lift-expression
 #'(lambda args (display "applying ") (displayln 'f)
(apply f args)))
(pre-expand-export
 #'(rename-out [wrapped-f f]) modes)]

(provide (wrapped-out +))

A program requiring my module and using addition will print "applying +".

But I actually want to wrap f with a macro. Is this possible? (Is this
an XY problem?)

-- 
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] Re: Sending a file via HTML request.

2016-08-24 Thread Stephen Chang
Vishesh Yadav wrote a DrRacket plugin that automatically compiles a
program to JS via whalesong and uploads it to a server. It sounds
related to what you are describing so you may want to take a look at
his code.

The plugin code is here: https://github.com/vishesh/drracket-whalesong
in particular these lines may be of interest:
https://github.com/vishesh/drracket-whalesong/blob/master/tool.rkt#L62-L74

and the server code is here: https://github.com/vishesh/whalebin

If you want to try it out, the server is running at
bigbang.ccs.neu.edu (but seems to be experiencing temporary problems
at the moment).

On Wed, Aug 24, 2016 at 7:36 AM, Normal Loone  wrote:
> Sorry, I should have been clearer:
>
> I want to send a file directly from DrRacket to a server. I have submit 
> button as a plugin in DrRacket and it then should take the file and send it 
> to the server (the file is known, doesnt need to be selected from user).
>
> I tried the code from HTH Stephen, but problem is that the web application 
> starts on DrRacket start and not when I press the button, how I wanted it.
>
> So if someone could tell me a way to just directly send a file with DrRacket 
> as an HTML request, I'd really appreciate that.
>
> --
> 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] Racket Shell

2016-08-20 Thread Stephen Chang
Cool! Will definitely check it out.

Is this at all related to Vincent's work? [1]

[1]: https://github.com/stamourv/rash

On Sat, Aug 20, 2016 at 3:17 PM, William G Hatch  wrote:
> Hello everyone,
>
> Being obsessed with shells and wanting very badly to have a racket
> shell, I've spent a good chunk of time over the last couple of weeks
> working on shell-related stuff for Racket.  First is a library for shell
> pipelines (that may also contain racket functions).  The interface is
> roughly like this (assuming `my-grep` is a racket function that
> implements grep):
>
>(run-pipeline '(ls -l) (list my-grep "foobar") '(wc -l))
>
> The docs for that library are here [1].
>
> Additionally, I've got a rough sketch of a line-based syntax for writing
> shell
> scripts or using a shell repl with embedded racket code.  Right now its
> syntax
> looks like this:
>
>#lang rash
>ls -l | @my-grep "foobar" | wc -l
>;; A line is not wrapped in a pipeline if it starts with &
>;; You can get back into #lang rash syntax with @rash{} or @rash/out{}
>&@(define ttys @rash/out{ls /dev | grep tty})
>
> I want to change the line syntax a lot (especially to not need &), but I
> decided to put it up (with some very rough documentation) here [2] to
> get some feedback on what people think of it.
>
> I'm really interested in people's thoughts about both parts and ways people
> think they could be improved.
>
> Thanks,
>
> William Hatch
>
> [1] http://docs.racket-lang.org/shell-pipeline/index.html
> [2] http://docs.racket-lang.org/rash/index.html
>
> --
> 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] How do I "make base"

2016-08-03 Thread Stephen Chang
> It was also suggested that it is not in src/Makefile, instead:
"I'm usually in the top-level checkout dir", to quote stamourv.

Is this what you're looking for?
https://github.com/racket/racket/blob/master/Makefile#L153-L160

On Wed, Aug 3, 2016 at 1:02 PM, Tim Brown  wrote:
> Here's hoping someone can answer this without too much (any) difficulty:
>
> I have the Unix source in racket-6.6-src.tgz from the download page.
> It's untarred into racket-6.6 . I want this because it has a superset
> of the packages I'll eventually want in my installation.
>
> If I:
>
>  configure
>  make
>  make plain-install
>
> I don't get a raco executable built.
>
> On IRC, it was suggested that I do a `make base` -- which should get me
> a raco capabale of pkg and setup. Problem is -- I can't find base as a
> target.
>
> It was also suggested that it is not in src/Makefile, instead:
> "I'm usually in the top-level checkout dir", to quote stamourv.
>
> A git clone later and I *still* don't have base in any makefile.
>
> Folks... how do I either make base or get as minimal a racket
> installation as I can with a capable raco?
>
> Thanks in anticipation,
>
> Tim
>
> --
> Tim Brown - t...@timb.net - +44(0)7771714159
>
> --
> 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] IO in racket is painful

2016-03-22 Thread Stephen Chang
> It may be overkill for this use case, but I would probably use the
> parsack package, since I think its interface is pretty intuitive.

:) I had started writing up a parsack example, and I was all set to
admonish the OP for not creating a parser when you want a parser but
then I saw it was for a programming contest where I guess this sort of
scanf/regexp hackery is ok?

> Should it throw an exception, or should it
> return #f? I’m not sure there is great precedent set here, though
> throwing seems to be the Racket way in other places.

printf throws an exception when there's a type mismatch, eg (printf "~b" "1")

(thanks for the example Ben)


>
> --
> 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] IO in racket is painful

2016-03-22 Thread Stephen Chang
A "read" variant that works with format strings would be a useful
addition I think.

Matthew, your solution is clever :) (but with symbols instead of strings).

Another alternative could be to use match:

#lang racket

(define (trim-brackets str)
  (string-trim str #rx"\\[|\\]|,"))

(define (pad n w)
  (~r n #:pad-string "0" #:min-width w))

(parameterize ([current-input-port (open-input-file "file.txt")])
  (for ([ln (in-lines)])
(match (string-split (trim-brackets ln) ", ")
  [(list (app string->number x)) (displayln x)]
  [(list (app string->number x) y (app string->number z))
   (printf "[~a, ~a, ~a]\n" (pad x 2) y (pad z 4))])))

or if you are willing to write a macro:

#lang racket

(define (trim-brackets str)
  (string-trim str #rx"\\[|\\]|,"))

(define (pad n w)
  (~r n #:pad-string "0" #:min-width w))

(define-match-expander numstr
  (syntax-rules () [(_ x) (app string->number x)]))

(parameterize ([current-input-port (open-input-file "file.txt")])
  (for ([ln (in-lines)])
(match (string-split (trim-brackets ln) ", ")
  [(list (numstr x)) (displayln x)]
  [(list (numstr x) y (numstr z))
   (printf "[~a, ~a, ~a]\n" (pad x 2) y (pad z 4))])))



(yes, I didnt close the port)

On Tue, Mar 22, 2016 at 6:34 PM, Matthew Butterick  wrote:
>> Then, for all rows, read and split the string. The best that i have found to 
>> do that is using regular expressions.
>>
>>   (define split-row (regexp-match #rx"\\[(.+), (.+), (.+)\\]" (read-line)))
>>
>> Then you have to manually convert the substrings into values
>>
>>   (define a (string->number (second split-row)))
>>   (define b (third split-row))
>>   (define c (string->number (fourth split-row)))
>
> This kind of destructuring & conversion from strings to values can sometimes 
> be more conveniently handled by converting your source data into something 
> that looks like Racket S-expressions (in this case, by removing the commas) 
> and then calling `read` to do the rest, e.g.
>
> #lang racket
> (with-input-from-file "data.txt"
>   (λ _ (for/list ([ln (in-lines)])
>  (read (open-input-string (string-replace ln "," ""))
>
> --
> 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] colorizing code in html - scribble or the GUI?

2016-03-15 Thread Stephen Chang
You can also submit the code to pasterack.org, which uses the scribble
css. Each paste page also gives the html source of the code and output
on the side, which you can copy to anywhere you want.

On Tue, Mar 15, 2016 at 7:11 PM, Sanjeev Sharma  wrote:
> is there a quick & dirty way to use scribble or the drracket GUI to generate 
> html for random code snippets?
>
> --
> 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] How to get a "green bar" (or similar) on passing tests?

2016-03-05 Thread Stephen Chang
Do you mean something like?

#lang racket
(require rackunit)
(require rackunit/gui)
(define tests
  (test-suite
   "my tests"
   (test-equal? "check 1" 1 1)
   (test-equal? "check 2" 2 2)))
(test/gui tests)

But that will pop a window. Alternatively,

#lang racket
(require rackunit)
(require rackunit/text-ui)

(define tests
  (test-suite
   "my tests"
   (test-equal? "check 1" 1 1)
   (test-equal? "check 2" 2 2)))
(run-tests tests)

produces:

2 success(es) 0 failure(s) 0 error(s) 2 test(s) run
0

where 0 is the number of unsuccessful tests.



On Sat, Mar 5, 2016 at 11:43 PM, Daniel Prager
 wrote:
> Is there a way to get a successful run of RackUnit tests to give a bit of
> encouragement?
>
> E.g. 12 out of 12 tests passed.
>
> The regular set-up seems to follow the "no news is good news" philosophy.
>
> Also, I couldn't figure out how to summon the rackunit/gui test runner
> (which may be what I want). What does a minimal example look like?
>
> Many thanks
>
> Dan
>
> --
> 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] Re: Racket 6.4 very slow

2016-03-02 Thread Stephen Chang
In general, times reported in DrRacket are unreliable.

See: 
https://docs.racket-lang.org/guide/performance.html#%28part._.Dr.Racket-perf%29

Try the command line. Here's what I get on my machine:

$ ~/racket61/bin/racket
Welcome to Racket v6.1.
-> (define (total n)
 (for/sum ([x (in-range (+ 1 n))]) x))
-> (time (total 10))
cpu time: 3044 real time: 3051 gc time: 0
55

$ ~/racket62/bin/racket
Welcome to Racket v6.2.
-> (define (total n)
 (for/sum ([x (in-range (+ 1 n))]) x))
-> (time (total 10))
cpu time: 3036 real time: 3046 gc time: 0
55

$ ~/racket63/bin/racket
Welcome to Racket v6.3.
-> (define (total n)
 (for/sum ([x (in-range (+ 1 n))]) x))
-> (time (total 10))
cpu time: 3040 real time: 3045 gc time: 0
55

$ ~/racket64/bin/racket
Welcome to Racket v6.4.
-> (define (total n)
(for/sum ([x (in-range (+ 1 n))]) x))
-> (time (total 10))
cpu time: 3036 real time: 3041 gc time: 0
55



On Wed, Mar 2, 2016 at 1:31 PM, Matthias Felleisen  wrote:
>
> It sounds like your files are not compiled. Try
>
>  raco setup
>
> in a shell. You may need to supply some command line flags if your files are 
> half way compiled.
>
> (Your examples runs in 3200 ms on my Mac in Racket 6.4.1)
>
>
>
> On Mar 2, 2016, at 1:26 PM, vkelmenson via Racket Users 
>  wrote:
>
>> On Tuesday, March 1, 2016 at 10:51:58 PM UTC-5, vkelm...@aol.com wrote:
>>> I recently downloaded Racket version 6.4. I have previously been using 
>>> version 6.1. It is much slower than version 6.1. Several short functions 
>>> run approx 20 times slower on 6.4 than 6.1. These were run at the same time 
>>> on the sam matine in succession.
>>> I am using Mac osX version 10.8.5
>>> Has anyone else noticed this?
>>
>> (define (total n)
>>  (for/sum ([x (in-range (+ 1 n))]) x))
>> (time (total 10))
>> in Racket 6.1 just now 5287 milliseconds. In Racket 6.4 102384 milliseconds.
>> Also: When I am typing in the interactions pane of 6.4 there is often a 1-2 
>> second delay before my
>> keystrokes show up.
>>
>> --
>> 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] Writing a blank to a file

2016-03-02 Thread Stephen Chang
Use display? or set read-accept-bar-quote to #f

On Wed, Mar 2, 2016 at 1:12 PM, Marco Morazan  wrote:
>
> Hi All,
>
> I seem to recall I knew how to do this once, but can't recall the details.
>
> How do we write a blank to a text file without the parallel bars appearing?
>
> So, (write '| | outfile) produces | | in the file. I want to eliminate the 
> vertical bars.
>
> Thanks,
>
> Marco
>
> --
> 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] Strange Output from check-expect ???

2016-02-24 Thread Stephen Chang
Thanks for the report. Which version are you using? I'm seeing that
the behavior appears in 6.3 but is fixed in 6.4.

On Wed, Feb 24, 2016 at 4:22 PM, Jeffrey Edgington  wrote:
> I am getting an unexpected message from check-expect when I try the following:
>
> #lang racket
> (require test-engine/racket-tests)
>
> (struct element (x y) #:transparent)
>
> (define (make-element-list n)
>   (for*/list ([i n][j n]) (element (+ i 1) (+ j 1
>
> (check-expect (make-element-list 1) 0)
>
> (test)
>
>
> The result is:
>
> Ran 1 check.
> 0 checks passed.
> Actual value differs from the expected value.
> Actual value: ))1 1 tnemele( tsil(
>   Expected value: 0
>
>
>
> but for example if I type the following into the interactions pane:
>
>> (make-element-list 1)
> (list (element 1 1))
>
> Which is what I want… Why is the message from check-expect reversed?
>
> Thanks!
>
> Jeffrey Edgington
>
>
> --
> 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] Chaperone of immutable hash

2016-02-13 Thread Stephen Chang
I added similar basic tests here.

https://github.com/racket/racket/blob/master/pkgs/racket-test-core/tests/racket/hash.rktl
On Feb 13, 2016 4:12 PM, "Robby Findler" 
wrote:

> I think this is what you want?
>
> (chaperone-hash
>  (hash)
>  (λ (h key) (values key (λ (h key val) val)))
>  (λ (h key val) (values key val))
>  (λ (h key) key)
>  (λ (h key) key)
>  (λ (hash) 'okay)
>  (λ (hash key) key))
>
>
>
>
> On Sat, Feb 13, 2016 at 3:02 PM, Gustavo Massaccesi 
> wrote:
> > I want to make a test with a chaperone of an immutable hash, but the
> > signature of make-chaperone-hash has too many parts.
> >
> > Do anyone have an example of use of make-chaperone-hash. If possible,
> > the chaperone that does nothing, only forward the values.
> >
> > Gustavo
> >
> > --
> > 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] backwards-incompatible change to in-vector

2016-01-19 Thread Stephen Chang
> I think you should not change this backwards compatibility unless you
> really know it isn't used (and even then it is hard to know such
> things).

Well I still think these programs would be relying on a bug, since
they are referencing a non-existent vector element.

But since there's no agreement, I'll leave it for now.

I'll just add a special case for empty vectors and 0,0.

It's probably not worth it to add yet-another new special case, as in
Matthew's email, right?




>
> Robby
>
> On Tue, Jan 19, 2016 at 1:16 PM, Stephen Chang <stch...@ccs.neu.edu> wrote:
>> Yes, or course it's possible, at the expense of more unreadable code.
>>
>> But the zero special case doesnt make sense. And is inconsistent with
>> other out-of-range cases, eg (in-vector (vector) 1 1) errors
>>
>> To be clear, empty traversals with valid indices would still be legal,
>> eg (in-vector (vector 1 2) 1 1)
>>
>> On Tue, Jan 19, 2016 at 2:06 PM, Vincent St-Amour
>> <stamo...@eecs.northwestern.edu> wrote:
>>> Would it be possible to special-case `(in-vector (vector) 0 0)`
>>> directly, and fix the bug while keeping backwards compatibility?
>>>
>>> Vincent
>>>
>>>
>>> On Tue, 19 Jan 2016 12:19:12 -0600,
>>> Stephen Chang wrote:
>>>>
>>>> I'm fixing pr 15227 but I would like to do so in a backwards-incompatible 
>>>> way.
>>>>
>>>> Right now an out-of-range index is sometimes allowed as an argument to
>>>> in-vector, leading to the bug:
>>>>
>>>> $ racket
>>>> Welcome to Racket v6.4.0.4.
>>>> -> (for/sum ([x (in-vector (vector 10 20) 2 -1 -1)]) x)
>>>> SIGSEGV MAPERR si_code 1 fault on addr 0x180
>>>> Aborted
>>>>
>>>> From what I can tell, the out-of-range index is allowed to enable this 
>>>> program:
>>>>
>>>> (in-vector (vector) 0 0)
>>>>
>>>> I want to change in-vector so that the starting index is always a
>>>> valid vector-ref. The above program would become illegal.
>>>>
>>>> From what I gather, the above program is allowed so that in-vector
>>>> mimics in-range but I don't think this makes sense either if it means
>>>> allowing out-of-range indices for the former.
>>>>
>>>> Any objections?
>>>>
>>>> --
>>>> 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.

-- 
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] backwards-incompatible change to in-vector

2016-01-19 Thread Stephen Chang
I'm fixing pr 15227 but I would like to do so in a backwards-incompatible way.

Right now an out-of-range index is sometimes allowed as an argument to
in-vector, leading to the bug:

$ racket
Welcome to Racket v6.4.0.4.
-> (for/sum ([x (in-vector (vector 10 20) 2 -1 -1)]) x)
SIGSEGV MAPERR si_code 1 fault on addr 0x180
Aborted

>From what I can tell, the out-of-range index is allowed to enable this program:

(in-vector (vector) 0 0)

I want to change in-vector so that the starting index is always a
valid vector-ref. The above program would become illegal.

>From what I gather, the above program is allowed so that in-vector
mimics in-range but I don't think this makes sense either if it means
allowing out-of-range indices for the former.

Any objections?

-- 
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] backwards-incompatible change to in-vector

2016-01-19 Thread Stephen Chang
Yes, or course it's possible, at the expense of more unreadable code.

But the zero special case doesnt make sense. And is inconsistent with
other out-of-range cases, eg (in-vector (vector) 1 1) errors

To be clear, empty traversals with valid indices would still be legal,
eg (in-vector (vector 1 2) 1 1)

On Tue, Jan 19, 2016 at 2:06 PM, Vincent St-Amour
<stamo...@eecs.northwestern.edu> wrote:
> Would it be possible to special-case `(in-vector (vector) 0 0)`
> directly, and fix the bug while keeping backwards compatibility?
>
> Vincent
>
>
> On Tue, 19 Jan 2016 12:19:12 -0600,
> Stephen Chang wrote:
>>
>> I'm fixing pr 15227 but I would like to do so in a backwards-incompatible 
>> way.
>>
>> Right now an out-of-range index is sometimes allowed as an argument to
>> in-vector, leading to the bug:
>>
>> $ racket
>> Welcome to Racket v6.4.0.4.
>> -> (for/sum ([x (in-vector (vector 10 20) 2 -1 -1)]) x)
>> SIGSEGV MAPERR si_code 1 fault on addr 0x180
>> Aborted
>>
>> From what I can tell, the out-of-range index is allowed to enable this 
>> program:
>>
>> (in-vector (vector) 0 0)
>>
>> I want to change in-vector so that the starting index is always a
>> valid vector-ref. The above program would become illegal.
>>
>> From what I gather, the above program is allowed so that in-vector
>> mimics in-range but I don't think this makes sense either if it means
>> allowing out-of-range indices for the former.
>>
>> Any objections?
>>
>> --
>> 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] begin-for-syntax causes syntax objects to expand to a different #'quote

2015-12-16 Thread Stephen Chang
I'm not sure. I would guess that it corresponds to the label phase?

On Wed, Dec 16, 2015 at 10:37 PM, Leif Andersen <l...@leifandersen.net> wrote:
> Ah, okay, thanks. One question, I notice that you can pass in #f to
> #:phase, I presume that is similar to for-label, can I use that to
> indicate I would like it to match on all phases?
>
> ~Leif Andersen
>
>
> On Wed, Dec 16, 2015 at 10:02 PM, Stephen Chang <stch...@ccs.neu.edu> wrote:
>> There's a #:phase option available when specifying literals:
>>
>> http://docs.racket-lang.org/syntax/Parsing_Syntax.html?q=syntax-parse#%28form._%28%28lib._syntax%2Fparse..rkt%29._syntax-parse%29%29
>>
>> On Wed, Dec 16, 2015 at 9:55 PM, Leif Andersen <l...@leifandersen.net> wrote:
>>> Okay, that makes sense, thanks.
>>>
>>> So out of curiosity, when doing a `syntax-parse`, is there any way I
>>> can pass in phase level 1 quote as a literal?
>>>
>>> ~Leif Andersen
>>>
>>>
>>> On Wed, Dec 16, 2015 at 6:44 PM, Sam Tobin-Hochstadt
>>> <sa...@cs.indiana.edu> wrote:
>>>> That depends on what you're trying to do, but probably not. Going under a
>>>> `quote-syntax` doesn't change things, it's just that those identifiers are
>>>> usually used in a macro somewhere else. But it would depend on your
>>>> application.
>>>>
>>>> Note the handling of submodules, though, in particular the call to
>>>> `syntax-shift-phase-level`.
>>>>
>>>> Sam
>>>>
>>>> On Wed, Dec 16, 2015 at 6:41 PM Leif Andersen <l...@leifandersen.net> 
>>>> wrote:
>>>>>
>>>>> Ah, cool. Thanks.
>>>>>
>>>>> Does that also mean that if I see a `syntax` form inside of a
>>>>> `begin-for-syntax` it goes back to phase 0?
>>>>>
>>>>> Thanks.
>>>>>
>>>>> ~Leif Andersen
>>>>>
>>>>>
>>>>> On Wed, Dec 16, 2015 at 6:25 PM, Sam Tobin-Hochstadt
>>>>> <sa...@cs.indiana.edu> wrote:
>>>>> > The identifiers are the same, but only when comparing their phase-1
>>>>> > bindings. When doing traversal of syntax objects, you need to keep track
>>>>> > of
>>>>> > the phase that identifiers are meaningful at.
>>>>> >
>>>>> > Here's a version of your paste comparing at the right phase:
>>>>> > http://pasterack.org/pastes/95574
>>>>> >
>>>>> > Here's some quite complex code that walks fully-expanded syntax, and (I
>>>>> > think) handles phases right as of yesterday:
>>>>> >
>>>>> > https://github.com/samth/pycket/blob/master/pycket/pycket-lang/expand.rkt
>>>>> >  .
>>>>> > See the `current-phase` parameter.
>>>>> >
>>>>> > Sam
>>>>> >
>>>>> > On Wed, Dec 16, 2015 at 6:22 PM Leif Andersen <l...@leifandersen.net>
>>>>> > wrote:
>>>>> >>
>>>>> >> Hello,
>>>>> >>
>>>>> >> I am finding that when I have a syntax object:
>>>>> >>
>>>>> >> #'(begin-for-syntax (define-values (x) 5), when I expand it it becomes:
>>>>> >> #'(begin-for-syntax (define-values (x) '5). However, the quote in that
>>>>> >> expansion will not be free-identifier=? to the one if I were to type
>>>>> >> it out by hand:
>>>>> >> #'(begin-for-syntax (define-values (x) '5), and expand that.
>>>>> >>
>>>>> >> If however, I have a `begin` rather than a `begin-for-syntax`, giving
>>>>> >> me:
>>>>> >> #'(begin (define-values (x) 5) it works as expected. (The quote it
>>>>> >> expands into is free-identifier=? to the one that I am using.)
>>>>> >>
>>>>> >> I am calling expand (or expand-syntax) directly, and not really using
>>>>> >> any phase levels outside of whatever `expand` may use.
>>>>> >>
>>>>> >> Here is my code: http://pasterack.org/pastes/78711
>>>>> >>
>>>>> >> #lang racket
>>>>> >>
>>>>> >> (define x (expand #'(begin-for-syntax
>>>>> >>   (define-values (x) '5
>>>>>

Re: [racket-users] R7RS (small) in Racket

2015-10-25 Thread Stephen Chang
This paper is not about Racket but reports on an r7rs implementation
experience and so may have some helpful hints:

http://www.schemeworkshop.org/2014/papers/Kato2014.pdf
On Oct 25, 2015 5:18 PM, "Alexis King"  wrote:

> I have built a very small, very incomplete implementation of R7RS in
> Racket. You can install the “r7rs” package, or you can find it on GitHub
> here:
> https://github.com/lexi-lambda/racket-r7rs
>
> Most of the standard seems fairly straightforward, but there are two
> questions I have. First of all, do there exist any R7RS libraries or
> programs out there that could be used as test cases? The standard is not
> always 100% clear, so having real code to test against would be ideal. This
> is probably more productive than hopelessly guessing at the meaning behind
> the fuzzier areas of the spec.
>
> Second of all, the only non-trivial problem is how to handle the R7RS
> library system and how to integrate it with Racket’s modules. I’ve been
> thinking about how to handle this, and I’m not sure which path I should
> take. I think there are two different use-cases to having an R7RS
> implementation inside of Racket, and each presents its own needs:
>
>1. Maintaining full source compatibility with R7RS-compliant programs.
>2. Implementing R7RS as a module language and requiring “#lang r7rs”.
>
> These are not necessarily mutually exclusive. It seems that Racket’s R5RS
> support manages to provide both options by having the “r5rs” lang and
> module language while also including a mode that works by evaluating
> expressions at the top-level. The question becomes: what is the value
> behind an R7RS implementation? I’ve mostly been implementing it as an
> exercise, and because it’s irked me a little that we have R{5,6}RS
> implementations but not R7RS, but it probably isn’t very useful within the
> Racket ecosystem.
>
> With this context in mind, I ask those have been involved in the Racket
> R5RS or R6RS support to share their experiences regarding these problems.
> Also, if anyone is aware of usages of R7RS (or would be interested in R7RS
> support in Racket, for whatever reason), I’d appreciate thoughts on that as
> well.
>
> If interest is low, I’ll probably just take option 2 for now and build a
> mostly-compliant implementation that accommodates Racket in a few places,
> but I do have some potential ideas for how to handle source compatibility.
> Still, I’m sure I’d be tackling many of the same problems other people have
> already considered, which is why I ask for information about any prior art.
>
> Thanks,
> Alexis
>
> --
> 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] Strange garbage collection behavior with closures

2015-10-22 Thread Stephen Chang
pasterack uses make-module-evaluator in a sandbox. It's also still
running 6.1.1. Would either of those cause the observed difference?

On Wed, Oct 21, 2015 at 9:18 PM, Matthew Flatt  wrote:
> An empty closure is allocated as a constant --- similar to a literal
> string or literal fraction in your program. The "closure" will stick
> around as long as the code does, and the code will stick around as the
> namespace where its loaded.
>
> If you change `(λ () 0`) to `(λ () (if box 0 'huh?))`, then you end up
> with a non-empty closure (i.e., allocated at run time) due to the
> reference to `box`, and so you get `#f` at the end as you expect.
>
> I don't know why PasteRack produces #f, but it must not hold onto the
> namespace.
>
> At Wed, 21 Oct 2015 21:07:52 -0400, Scott Moore wrote:
>> I’m trying to do something a bit fancy that makes use of weak-hashes, but 
>> I’ve
>> run into strange behavior (things not being removed that I believe should be)
>> when I use keys that are closures. Doing some of my own debugging, this
>> doesn’t appear specific to weak hashes, but also to weak boxes. Here is a
>> short example (based on the example programs in section 19.11 of
>> http://docs.racket-lang.org/guide/performance.html):
>>
>> #lang racket
>>
>> (struct foo ())
>>
>> (define box #f)
>>
>> (let ([f (foo)])
>>   (set! box (make-weak-box f))
>>   (weak-box-value box))
>> (weak-box-value box)
>> (collect-garbage)
>> (weak-box-value box)
>>
>> (let ([f (λ () 0)])
>>   (set! box (make-weak-box f))
>>   (weak-box-value box))
>> (weak-box-value box)
>> (collect-garbage)
>> (weak-box-value box)
>>
>> I expect the output of this program to be:
>>
>> #
>> #
>> #f
>> #
>> #
>> #f
>>
>> Curiously, I do get this answer if I paste the program to pasterack.org. If
>> instead I run the program in DrRacket, or at the command line (both compiled
>> and not compiled), I get this output:
>>
>> #
>> #
>> #f
>> #
>> #
>> #
>>
>> Any idea what is happening here? As far as I can tell, the reachability of 
>> “f”
>> in both code blocks should be identical, despite the difference in the type 
>> of
>> value. Maybe some sort of compiler transformation or a subtlety in the
>> reachability analysis? Or a bug?
>>
>> Thanks,
>> Scott
>>
>> --
>> 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] Whalesong-as-a-service

2015-09-08 Thread Stephen Chang
Hi Racket users,

This past summer, Vishesh Yadav created a web application to
facilitate sharing of Racket programs as Javascript (big-bang programs in
particular).

Vishesh is exploring improvements to Whalesong as part of a master's
thesis, taking a descriptive approach and focusing on how Racket
programmers prefer to use Javascript. We're hoping this site will help
us collect some useful examples.

We invite everyone to check it out in its current state and provide
feedback: http://bigbang.ccs.neu.edu/
Submit problems here: https://github.com/vishesh/whalebin

Here are some big-bang programs we've ported:
http://bigbang.ccs.neu.edu/search?q=%23Stevelikes

Vishesh has also developed a DrRacket tool to make local development
in Whalesong easier. The tool adds 2 buttons: a Scribble-style local
compile button, and button that uploads to the website.

I've added the tool as "whalesong-tools" to the pkg server. The src is
here: https://github.com/vishesh/drracket-whalesong

The local-compile button requires a Whalesong installation. Use the
version maintained by Jens. I don't think installation works via the
package manager, but installation instructions are here:
https://github.com/soegaard/whalesong. It will run with Racket 6.2.1
but not anything more recent than that.

-- 
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] macro-generate attribute access?

2015-08-21 Thread Stephen Chang
Is there a way to access an attribute, other than with the . syntax?

For example, the following example does not work:

#lang racket
(require (for-syntax syntax/parse))

(define-syntax (define-stuff stx)
  (syntax-parse stx
[(_ attr-name macro-name)
 #'(begin
 (begin-for-syntax
   (define-syntax-class C
 (pattern any #:attr attr-name #'any)))
 (define-syntax macro-name
   (syntax-parser
 [(_ (~var c C))
  #'c.attr-name])))]))
(define-stuff an-attr a-macro)
(a-macro 1)

I've also tried various format-id's which I also can't get to work. Is
there an alternate way, in the spirit of ~var vs :, to get an
attribute's value?

-- 
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] Some help with syntax-parse: macro in macro

2015-07-31 Thread Stephen Chang
You might want to specify collect in #:datum-literals if it is not a
defined name.

Can you describe some usage examples? That may lead to better insight
for the implementation.

On Fri, Jul 31, 2015 at 11:49 AM, Deren Dohoda deren.doh...@gmail.com wrote:
 Suppose I have a macro (experiment ...) which is intended, among other 
 things, to be composed of uses of a macro (collect ...).

 For instance:
 (experiment
   (collect ...)
   (collect ...) ...)

 To my understanding, collect is not a literal. Can I turn the collect macro 
 itself into a syntax class somehow? Should I instead create a dummy literal 
 collect for this purpose, and then create a (collect* ...) macro?

 Thanks for any advice.

 Deren

 --
 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] Re: is this a bug?

2015-07-29 Thread Stephen Chang
For any f, acc, and lst, (foldl f acc lst), from left-to-right,
applies to f to each element of lst and the current accumulated value.
The initial accumulator is acc so the second intermediate accumulated
value is (f (first lst) acc). Replacing f, acc, and lst with your
arguments, the second intermediate accumulated value in your example
is (list 'a1 '()), and so on.

On Wed, Jul 29, 2015 at 10:09 AM,  sagyo12341...@gmail.com wrote:
 Sorry Stephen,

 I expected,

 (foldl (lambda (x y) (list x y)) () '(list a1 a2 a3 a4 a5))
 (list (list (list (list (list a1 a2) a3) a4) a5).

 it may be a problem in non-commutative operations.

 Taro

 --
 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] is this a bug?

2015-07-29 Thread Stephen Chang
What's the output you expected?

Does this post help you?
http://stackoverflow.com/questions/8778492/why-is-foldl-defined-in-a-strange-way-in-racket

On Wed, Jul 29, 2015 at 9:45 AM,  sagyo12341...@gmail.com wrote:
 Dear racket maintainers,

 Maybe, I found a bug.

 (foldr (lambda (x y) (list x y)) '() '(a1 a2 a3 a4 a5))
 '(a1 (a2 (a3 (a4 (a5 ())
 (foldl (lambda (x y) (list x y)) '() '(a1 a2 a3 a4 a5))
 '(a5 (a4 (a3 (a2 (a1 ())

 Thanks, I hope racket language is more popular.

 Taro

 --
 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] Affecting the errors generated by syntax-parse

2015-07-25 Thread Stephen Chang
I haven't played with the example in detail, but do you want the cut
operator here?

http://docs.racket-lang.org/syntax/stxparse-patterns.html?q=syntax-parse#%28form._%28%28lib._syntax%2Fparse..rkt%29._~7e!%29%29

On Sat, Jul 25, 2015 at 9:55 AM, Jens Axel Søgaard
jensa...@soegaard.net wrote:
 Hi All,

 The syntax-parse form can often generate sensible errors based on the
 progress made
 during the attempt to match a pattern against a syntax-object. Given
 multiple choices
 the choice where the maximum progress was made is used to generate the
 error message.

 Is there a way to tell syntax-parse, that a given choice is to be used as
 the source
 of the error, if the match fails?

 A concrete example: In the toy language below a top-level form can be a
 definition
 or an expression. The malformed definition (define (foo 3) x) is not a legal
 definition -- it is however clear that the user intended to write a
 definition,
 since the form begins with (define ...). During matching syntax-parse
 makes more progress under the assumption that the definition is a sequence
 expression, so the error message becomes: begin expected.

 How can I stop the matching prematurely when the (define ...) is seen?

 /Jens Axel

 #lang racket
 ;;;
 ;;; URLANG
 ;;;

 ; In the grammar below x stands for a non-keyword identifier

 ; program::= top-level-form ...
 ; top-level-form ::= definition | expr

 ; definition ::= (define (x x ...) body)
 ; body   ::= expr

 ; expr   ::= datum | reference | application | sequence
 ; reference  ::= x
 ; application::= (x0 x ...)
 ; sequence   ::= (begin expr ...)

 ; keyword::= define | begin

 ; datum  ::= fixnum

 ; identifier an identifier that is not a keyword
 ; fixnum an integer between -2^53 and 2^53

 (require syntax/parse)

 (define min-fixnum (- (expt 2 53)))
 (define max-fixnum(expt 2 53))

 (define (Fixnum? r)
   (and (number? r) (integer? r)
(= min-fixnum r max-fixnum)))

 (define-syntax-class Fixnum
   #:opaque
   (pattern d
#:fail-unless (Fixnum? (syntax-e #'d)) #f))

 (define-syntax-class Datum
   (pattern (~or d:Fixnum)))

 (define-syntax-class Keyword
   #:literals (begin define)
   (pattern (~or begin define)))

 (define-syntax-class Id
   (pattern (~and x:id
  (~not y:Keyword

 (define-syntax-class Reference
   (pattern x:Id))

 (define-syntax-class Application
   #:literals (define)
   (pattern (e:Expr ...)))

 (define-syntax-class Sequence
   #:literals (begin)
   (pattern (begin e0:Expr e:Expr ...)))

 (define-syntax-class Definition
   #:literals (define)
   (pattern (define (name:Id a:Id ...) body:Body)))


 (define-syntax-class Body
   (pattern b:Expr))

 (define-syntax-class Expr
   (pattern (~or e:Datum
 e:Application
 e:Reference
 e:Sequence)))

 (define-syntax-class TopLevelForm
   (pattern (~or t:Definition
 t:Expr)))

 (define-syntax-class Program
   (pattern (p:TopLevelForm ...)))

 ;;; The following expressions show some legal
 ;;; constructs that are matched correctly.

 (syntax-parse #'3
   [d:Datum 'datum])

 (syntax-parse #'3
   [e:Expr 'expr])

 (syntax-parse #'(define (a x) x)
   [t:TopLevelForm 'toplevelform])

 (syntax-parse #'((define (foo x y) (+ x 1)) (foo 3))
   [p:Program 'program])

 ;;; The malformed definition (define (a 4 x) x) is
 ;;; correctly rejected as a toplevel form, but the
 ;;; automatically generated error is not as intended.

 (syntax-parse #'(define (a 4 x) x)
   [t:TopLevelForm 'toplevelform])

 --
 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] Affecting the errors generated by syntax-parse

2015-07-25 Thread Stephen Chang
Actually, I dont get the begin expected error that you mention. I'm getting:

define: expected identifier
  parsing context:
   while parsing Id
   while parsing Definition
   while parsing TopLevelForm in: 4

with the 4 highlighted, which seems correct since it comes from using
the Definition class?

On Sat, Jul 25, 2015 at 10:51 AM, Stephen Chang stch...@ccs.neu.edu wrote:
 I haven't played with the example in detail, but do you want the cut
 operator here?

 http://docs.racket-lang.org/syntax/stxparse-patterns.html?q=syntax-parse#%28form._%28%28lib._syntax%2Fparse..rkt%29._~7e!%29%29

 On Sat, Jul 25, 2015 at 9:55 AM, Jens Axel Søgaard
 jensa...@soegaard.net wrote:
 Hi All,

 The syntax-parse form can often generate sensible errors based on the
 progress made
 during the attempt to match a pattern against a syntax-object. Given
 multiple choices
 the choice where the maximum progress was made is used to generate the
 error message.

 Is there a way to tell syntax-parse, that a given choice is to be used as
 the source
 of the error, if the match fails?

 A concrete example: In the toy language below a top-level form can be a
 definition
 or an expression. The malformed definition (define (foo 3) x) is not a legal
 definition -- it is however clear that the user intended to write a
 definition,
 since the form begins with (define ...). During matching syntax-parse
 makes more progress under the assumption that the definition is a sequence
 expression, so the error message becomes: begin expected.

 How can I stop the matching prematurely when the (define ...) is seen?

 /Jens Axel

 #lang racket
 ;;;
 ;;; URLANG
 ;;;

 ; In the grammar below x stands for a non-keyword identifier

 ; program::= top-level-form ...
 ; top-level-form ::= definition | expr

 ; definition ::= (define (x x ...) body)
 ; body   ::= expr

 ; expr   ::= datum | reference | application | sequence
 ; reference  ::= x
 ; application::= (x0 x ...)
 ; sequence   ::= (begin expr ...)

 ; keyword::= define | begin

 ; datum  ::= fixnum

 ; identifier an identifier that is not a keyword
 ; fixnum an integer between -2^53 and 2^53

 (require syntax/parse)

 (define min-fixnum (- (expt 2 53)))
 (define max-fixnum(expt 2 53))

 (define (Fixnum? r)
   (and (number? r) (integer? r)
(= min-fixnum r max-fixnum)))

 (define-syntax-class Fixnum
   #:opaque
   (pattern d
#:fail-unless (Fixnum? (syntax-e #'d)) #f))

 (define-syntax-class Datum
   (pattern (~or d:Fixnum)))

 (define-syntax-class Keyword
   #:literals (begin define)
   (pattern (~or begin define)))

 (define-syntax-class Id
   (pattern (~and x:id
  (~not y:Keyword

 (define-syntax-class Reference
   (pattern x:Id))

 (define-syntax-class Application
   #:literals (define)
   (pattern (e:Expr ...)))

 (define-syntax-class Sequence
   #:literals (begin)
   (pattern (begin e0:Expr e:Expr ...)))

 (define-syntax-class Definition
   #:literals (define)
   (pattern (define (name:Id a:Id ...) body:Body)))


 (define-syntax-class Body
   (pattern b:Expr))

 (define-syntax-class Expr
   (pattern (~or e:Datum
 e:Application
 e:Reference
 e:Sequence)))

 (define-syntax-class TopLevelForm
   (pattern (~or t:Definition
 t:Expr)))

 (define-syntax-class Program
   (pattern (p:TopLevelForm ...)))

 ;;; The following expressions show some legal
 ;;; constructs that are matched correctly.

 (syntax-parse #'3
   [d:Datum 'datum])

 (syntax-parse #'3
   [e:Expr 'expr])

 (syntax-parse #'(define (a x) x)
   [t:TopLevelForm 'toplevelform])

 (syntax-parse #'((define (foo x y) (+ x 1)) (foo 3))
   [p:Program 'program])

 ;;; The malformed definition (define (a 4 x) x) is
 ;;; correctly rejected as a toplevel form, but the
 ;;; automatically generated error is not as intended.

 (syntax-parse #'(define (a 4 x) x)
   [t:TopLevelForm 'toplevelform])

 --
 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] Re: How to return summary from the inner loop?

2015-07-10 Thread Stephen Chang
I understand now. I still claim that an (explicit) inner loop is not needed:

(define (validate-ranges5 value-list low-list high-list)
  (for*/fold ([failures 0])
 ([(lo hi) (in-parallel low-list high-list)]
  [v value-list]
  #:when ( lo v hi))
(printf \n*** Faulty!: ~a  ~a  ~a\n lo v hi)
(add1 failures)))

(validate-ranges5 '(5 15 25) '(1 11 21) '(10 20 30))

=

*** Faulty!: 1  5  10

*** Faulty!: 11  15  20

*** Faulty!: 21  25  30
3

On Fri, Jul 10, 2015 at 5:40 PM, Pekka Niiranen
pekka.niira...@pp5.inet.fi wrote:
 Thanks Sir,

 This was exactly what I tried to reason.
 It never occured to me that parameter failure can be used
 in both for/fold -constructs.

 About the problem (Stephen):

 value-list: '(5, 15, 25)
 low-list:   '(1, 11, 21)
 high-list:  '(10, 20, 30)

 I need to check the following 9 cases:

 LVH

 1   5  10  BS
 1  15  10
 1  25  10

 11   5  20
 11  15  20 BS
 11  25  20

 21   5  30
 21  15  30
 21  25  30 BS

 -pekka-


 On 7/10/15 11:48 PM, Pierpaolo Bernardi wrote:

 On Fri, Jul 10, 2015 at 10:45 PM, Pierpaolo Bernardi
 olopie...@gmail.com wrote:

 If I understand correctly the spec, this should do what you ask?


 which, fixing the typo, becomes:

 (define (validate-ranges value-list low-list high-list)
(for/fold ((failures 0))
  ((low (in-list low-list))
   (high (in-list high-list)))
  (for/fold ((failures 0))
((value (in-list value-list)))
(if (= low value high)
  failures
  (add1 failures)



 --
 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] How to return summary from the inner loop?

2015-07-10 Thread Stephen Chang
Perhaps I don't understand the problem, but why is the inner loop necessary?

By the way, you can use (printf ...) instead of (fprintf
(current-output-port) ...)

Would this work?

(define (validate-ranges2 value-list low-list high-list)
  (for/sum ([v value-list]
[lo low-list]
[hi high-list]
#:when ( lo v hi))
(printf \n*** Faulty!\n)
1))

Or, without using for:

(define (validate-ranges3 vals los his)
  (count
   (λ (lo v hi)
 (and ( lo v hi)
  (printf \n*** Faulty!\n)))
   los vals his))

Without the printing:

(define (validate-ranges4 vals los his)
  (count  los vals his))


On Fri, Jul 10, 2015 at 4:01 PM, Pekka Niiranen
pekka.niira...@pp5.inet.fi wrote:
 Hello users,

 I want to loop thru values and return the total number of failures
 instead of breaking out of loop as soon as the first failure is encountered.

 The code below works as intended:

 define (validate-order value-list low-list)
   ;; Checks whether all the values are all above list of low limits
   (define result
 (for/fold ([failures 0])
   ([e low-list]
[v value-list])
   (if ( v e)
   (begin
 (fprintf (current-output-port) BS~n)
 (add1 failures))
   failures)))
   result)


 However, if I need to use nested loop I have to build
 intermediate list ranges before looping:

 (define (validate-ranges value-list low-list high-list)
   ;; Checks whether all the values are all between list
   ;; of low/high limits

   ;; I do not like this intermediate definition:
   (define ranges (for/list ([s low-list]
 [e high-list])
(cons s e)))

   (define result
 (for/fold ([failures 0])
   ([v value-list]
[r ranges])

   ;; I do not like the car/cdr -function calls either:

   (if ( (car r) v (cdr r))
   (begin
 (fprintf (current-output-port) ~n)
 (fprintf (current-output-port) *** Faulty!~n)
 (add1 failures))
   failures)))
   result)

 Is is somehow possible to return the result from the inner
 loop to the scope of the outer loop? Somehow like this:

 (define (validate-ranges value-list low-list high-list)
   (define result (for/??? ([s low-list]
[e high-list])
   (for/fold ([failures 0])
 ([v value-list])
 (if ( s v e)
 (begin
   (fprintf (current-output-port) BS~n)
   (add1 failures))
 failures
 result)

 -pekka-

 --
 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] could i get some feedback and help on a graphical editor project?

2015-07-08 Thread Stephen Chang
The Style Guide is a good place to start for learning Racket
conventions: http://docs.racket-lang.org/style/index.html

Overall, things look good! Your code already uses many Racket idioms.

Some things that caught my attention on first glance:

- The code is wider than typical. Though tastes differ, most Racket
code tries to stay within 80 or 102 columns.

- Use square brackets in certain places to aid readability. For
example, around cond and match clauses and let binding clauses. You
already do this somewhat, so just use it more consistently.

- unless/when already return void, so an explicit subsequent (void) is
unnecessary.

- To reduce code verbosity, utilize pattern matching (more than you
already do), particularly to destructure structs. For example, instead
of:

;; from clockwise-turn?
  (let* ((ax (node-x a))
 (ay (node-y a))
 (bx (node-x b))
 (by (node-y b))
 (cx (node-x c))
 (cy (node-y c)))
(not (positive? (- (* (- bx ax) (- cy ay)) (* (- cx ax) (- by ay))

write:

  (match* (a b c)
[((node ax ay) (node bx by) (node cx cy))
 (not (positive? (- (* (- bx ax) (- cy ay)) (* (- cx ax) (- by ay)]))

- Avoid manually traversing lists. Use for list comprehensions
instead of let loops. For example, instead of:

;; from highlight-paths
(let loop : Void
([x : (Listof path) (filter path? lst)])
(cond ((empty? x) (void))
  (else (when (any-entity-highlighted? (path-entities (car x)))
  (map (lambda ([i : Entity])
(set-entity-highlighted! i #t)) (path-entities (car x
(loop (cdr x)

write:

  (for ([p : path (filter path? lst)]
#:when (any-entity-highlighted? (path-entities p)))
(for ([i : Entity (path-entities p)]) (set-entity-highlighted! i #t)))


I didnt see anything blatant that should be converted to macros. In
general, you should prefer functions to macros, and I think your code
is organized well in general. That being said, you may want to look
into match expanders:

For example:

(define-match-expander line-pat
  (syntax-rules () [(_ pat1 pat2) (struct* line ([p1 pat1][p2 pat2]))]))

would allow you to write:

   (match i
 [(line-pat p1 p2) (list (node-x p1) (node-x p2))] ...)

instead of:
;; from canvas-utils.rkt
   (match i
 [(struct* line  ([p1 p1] [p2 p2])) (list (node-x p1)
(node-x p2))] ..)

And then you could nest a pattern more easily. For example, instead of:

;; from canvas-utils.rkt
  (let ((lx1 (node-x (line-p1 line-struct)))
(ly1 (node-y (line-p1 line-struct)))
(lx2 (node-x (line-p2 line-struct)))
(ly2 (node-y( line-p2 line-struct ...)

you could write:

  (match line-struct
[(line-pat (node lx1 ly1) (node lx2 ly2)) ...])

Functionality-wise, I tried to open disk_cover R14.dxf but got the
following error:

hash-ref: no value found for key
  key: 8

I was able to open disk_cover R2004-2006.dxf. It did lag somewhat
when I tried to drag it but I'm not sure if this is due to some parts
of the code or the large image itself. Maybe some others who have more
experience writing gui apps will comment.

On Wed, Jul 8, 2015 at 6:17 AM, copycat kangren.c...@gmail.com wrote:
 Hello all,

   feedback is most appreciated. I had a lot of fun writing this small program 
 (see bottom for details and repository link), and i want to improve my skills 
 so i can write idiomatic Scheme/Racket code one day. Particularly helpful 
 would be suggestions as to where i can use macros to reduce the amount of 
 code the program has. There is also some seriously verbose stuff in 
 lst-utils.rkt (find-entity-with-starting-node, find-entities-from-node ...) 
 that i'm not sure how to refactor at the moment now.

   Also, I am a new programmer and have only seriously programmed in VB.NET 
 and Racket and am thinking about building on this program to develop a GUI 
 for a gantry robot teaching interface. But i am worried about any roadblocks 
 that i may encounter on the way in using Racket. Please help me clear my 
 doubts.

 

 WARNING: bottom is a long description which is as much for me as it for you. 
 Skip to the below for a TL;DR.

   The first part of the GUI will be displaying a large image of a printed 
 circuit board (PCB) consisting of stitched high-resolution images taken with 
 an area-scan camera. The idea is to let the user draw on this background 
 image the order of movements (commands) of the gantry robot. More detailed 
 control of the robot movements has to be specified in a spreadsheet/display 
 list of some sort. There will also be some commands involving machine vision 
 for checking position markers (fiducials), and various sort of vision 
 inspections. These commands are then saved as a program to be executed in 
 the second part of the GUI.

  Those are the very basics, more fancy features that i 

Re: [racket-users] API design 2 -- variadic styles

2015-07-06 Thread Stephen Chang
Racket has linguistic support for keyword arguments, which address
many of the issues you raised:
http://docs.racket-lang.org/guide/keywords.html

Would this help in your case?

Additional background: http://www.cs.utah.edu/plt/publications/scheme09-fb.pdf

On Mon, Jul 6, 2015 at 10:56 AM, John Carmack jo...@oculus.com wrote:
 A primary goal of the scripting work is that it should be easy to do easy
 things.  You shouldn’t have to specify all the options if you just want to
 play a sound or show a picture, but you should still be able to get at them
 when you need them.



 For the case of a sound effect, all of the following data may be specified:



 Wav file – URI to a .wav file with audio samples.

 Volume – Scale factor for the wav samples.

 Position – 3D point for HRTF spatialized audio processing.

 Looping – Flag to cause the wav file to loop continuously.

 Name – An identifier to allow the parameters on a playing sound to be
 updated later.

 Time – Absolute time for the sound to start, necessary for synced background
 audio in drop-in multiplayer servers and glitch free transitioning between
 wav files.



 There are four broad strategies for exposing all that.



 Multiple functions for different sets of parameters:

 (+sound wav-string)

 (+sound-positioned Wav-string position-vec3)

 (+named-sound wav-string position-vec3 sound-name)

 (+sound-update sound-name new-position-vec3)



 This has a combinatorial explosion problem.



 Optional parameter count with implicit type by position, C++ style:

 (+sound wav-string position-vec3 name-int volume-float looping-bool
 time-float)



 Need to define special values for parameters that are essentially skipped –
 POSITION_NONE, NAME_NONE, etc, since it is possible to want to set later
 values without all the preceding ones.  Not very self-documenting, and not
 feasible for large numbers of options like GPU state.



 Keyword delimited parameters, command line parsing style:

 (+sound ‘wav wav-string ‘position position-vec3 ‘name name-int ‘volume
 volume-float ‘looping looping-bool ‘time time-float)



 A typo in an option symbol name will not be detected at compile time if done
 as a function, but I guess that is a good argument for a macro.



 Option functions:

 (+sound (opt-wav wav-string) (opt-position position-vec3) (opt-name
 name-int) (opt-volume volume-float) (opt-looping looping-bool) (opt-time
 time-float))



 Simple to do transformations or validation on the inputs, but the most
 verbose.

 Bad option names will be detected at compile time, but you could still
 compile, say, graphics options into a sound command, which would have been
 detected with the keyword delimited parameters.



 In some cases, parameters can be inferred by type.  For sounds, a parameter
 that is a string is the wav, a float is the volume, a bool is looping, a
 vec3 is position, an int is name.  That is sheer luck – other commands would
 very likely have multiple parameters with common types, and even here there
 would be an ambiguity with time.  Still, it would be possible to go
 type-system-happy and explicitly have types for everything.  I suppose that
 would syntactically degenerate to option functions.



 It is tempting to use flags that are just signaled by their presence – just
 add ‘looping instead of ‘looping #t or (looping #t), but that can be awkward
 when the state of a flag is programmatically evaluated.



 Currently I am using a hybrid form, where the first parameter is an implicit
 type (and second parameter for gfx commands), and all following parameters
 are evaluated and appended as options.

 --
 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] API design 2 -- variadic styles

2015-07-06 Thread Stephen Chang
Just realized that the first link is not very useful. These might be
more informative:

http://docs.racket-lang.org/guide/application.html?q=keyword#%28part._keyword-args%29
http://docs.racket-lang.org/guide/contracts-general-functions.html?q=keyword#%28part._contracts-keywords%29

On Mon, Jul 6, 2015 at 11:05 AM, Stephen Chang stch...@ccs.neu.edu wrote:
 Racket has linguistic support for keyword arguments, which address
 many of the issues you raised:
 http://docs.racket-lang.org/guide/keywords.html

 Would this help in your case?

 Additional background: http://www.cs.utah.edu/plt/publications/scheme09-fb.pdf

 On Mon, Jul 6, 2015 at 10:56 AM, John Carmack jo...@oculus.com wrote:
 A primary goal of the scripting work is that it should be easy to do easy
 things.  You shouldn’t have to specify all the options if you just want to
 play a sound or show a picture, but you should still be able to get at them
 when you need them.



 For the case of a sound effect, all of the following data may be specified:



 Wav file – URI to a .wav file with audio samples.

 Volume – Scale factor for the wav samples.

 Position – 3D point for HRTF spatialized audio processing.

 Looping – Flag to cause the wav file to loop continuously.

 Name – An identifier to allow the parameters on a playing sound to be
 updated later.

 Time – Absolute time for the sound to start, necessary for synced background
 audio in drop-in multiplayer servers and glitch free transitioning between
 wav files.



 There are four broad strategies for exposing all that.



 Multiple functions for different sets of parameters:

 (+sound wav-string)

 (+sound-positioned Wav-string position-vec3)

 (+named-sound wav-string position-vec3 sound-name)

 (+sound-update sound-name new-position-vec3)



 This has a combinatorial explosion problem.



 Optional parameter count with implicit type by position, C++ style:

 (+sound wav-string position-vec3 name-int volume-float looping-bool
 time-float)



 Need to define special values for parameters that are essentially skipped –
 POSITION_NONE, NAME_NONE, etc, since it is possible to want to set later
 values without all the preceding ones.  Not very self-documenting, and not
 feasible for large numbers of options like GPU state.



 Keyword delimited parameters, command line parsing style:

 (+sound ‘wav wav-string ‘position position-vec3 ‘name name-int ‘volume
 volume-float ‘looping looping-bool ‘time time-float)



 A typo in an option symbol name will not be detected at compile time if done
 as a function, but I guess that is a good argument for a macro.



 Option functions:

 (+sound (opt-wav wav-string) (opt-position position-vec3) (opt-name
 name-int) (opt-volume volume-float) (opt-looping looping-bool) (opt-time
 time-float))



 Simple to do transformations or validation on the inputs, but the most
 verbose.

 Bad option names will be detected at compile time, but you could still
 compile, say, graphics options into a sound command, which would have been
 detected with the keyword delimited parameters.



 In some cases, parameters can be inferred by type.  For sounds, a parameter
 that is a string is the wav, a float is the volume, a bool is looping, a
 vec3 is position, an int is name.  That is sheer luck – other commands would
 very likely have multiple parameters with common types, and even here there
 would be an ambiguity with time.  Still, it would be possible to go
 type-system-happy and explicitly have types for everything.  I suppose that
 would syntactically degenerate to option functions.



 It is tempting to use flags that are just signaled by their presence – just
 add ‘looping instead of ‘looping #t or (looping #t), but that can be awkward
 when the state of a flag is programmatically evaluated.



 Currently I am using a hybrid form, where the first parameter is an implicit
 type (and second parameter for gfx commands), and all following parameters
 are evaluated and appended as options.

 --
 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] API function naming

2015-07-03 Thread Stephen Chang
 The prefixes are based on this file:
 https://github.com/racket/gui/blob/master/tex-table/tex-table.rkt

 Maybe there are missing ones you're used to?

Sorry, that was supposed to be a compliment! I love DrRacket's support
for unicode and I havent wanted any symbols that aren't already
supported.

I was agreeing with Neil V's general sentiment that inputting
non-standard symbols (even with DrRacket's assistance) often feels
more cumbersome than simply choosing a longer name. It's like the
right-handed version of emacs pinky?

However, ultimately I stick with the shorter names because I agree
that it's more readable.




 Robby

 --
 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] API function naming

2015-07-03 Thread Stephen Chang
 You also have unicode available to you. IDE support can help with this
 -- I think the cmd-\ for lambda has worked pretty well.

I've been going this route more, especially because DrRacket supports
autocompletion of (what it deems) unique latex prefixes. For example,
in DrRacket, type \G, followed by ctrl-\

However, I often hate myself afterwards, exactly because:

 These punctuation characters that typically require a shift modifier might be
 pleasing to the eye, but unpleasing to the typist.

That being said, I haven't stopped doing it yet.




 Robby

 On Fri, Jul 3, 2015 at 12:36 PM, Stephen Chang stch...@ccs.neu.edu wrote:
 What symbols have the least historic baggage?

 I've gone through this exercise a few times, and each time settled on '$'.

 As Greg points out, pretty much every one of my my Racket libraries
 makes use of this symbol (was it that obvious? :) ) exactly because I
 was looking for something that Racket programmers would not confuse
 for something else.

 Off the top of my head, here are some other Racket symbol conventions
 (may not apply to Scheme in general):

 ~: syntax-parse pattern combinators; I've tried to use this before and
 received negative feedback about it
 !: imperative/side-effecting functions
 @: documentation, at mentioned by Greg, and also units
 #: recognized by the reader (often in combination with a second
 symbol) for various literals
 %: objects, and % is for interfaces (as a suffix)
 ^: unit signatures (suffix)
 : this one may be relatively safe, I think?
 *: sometimes denotes list version or more often just alternate (eg let*)
 -: standard word delimiter, a la '_' in C and other languages
 /: often pronounced with, as in call/cc; can also just be a
 delimiter (eg in the web server)
 _: the C ffi bindings have this prefix; some use it to mean internal
 ?: predicates (suffix)
 =: equality functions (suffix)

 Did I miss any?

 Note that I excluded symbols that already have special meaning to the
 reader: http://docs.racket-lang.org/reference/reader.html

 (Should these go in the style guide somewhere?)

 Another idea is to use two or more symbols?










 --
 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] API function naming

2015-07-03 Thread Stephen Chang
 What symbols have the least historic baggage?

I've gone through this exercise a few times, and each time settled on '$'.

As Greg points out, pretty much every one of my my Racket libraries
makes use of this symbol (was it that obvious? :) ) exactly because I
was looking for something that Racket programmers would not confuse
for something else.

Off the top of my head, here are some other Racket symbol conventions
(may not apply to Scheme in general):

~: syntax-parse pattern combinators; I've tried to use this before and
received negative feedback about it
!: imperative/side-effecting functions
@: documentation, at mentioned by Greg, and also units
#: recognized by the reader (often in combination with a second
symbol) for various literals
%: objects, and % is for interfaces (as a suffix)
^: unit signatures (suffix)
: this one may be relatively safe, I think?
*: sometimes denotes list version or more often just alternate (eg let*)
-: standard word delimiter, a la '_' in C and other languages
/: often pronounced with, as in call/cc; can also just be a
delimiter (eg in the web server)
_: the C ffi bindings have this prefix; some use it to mean internal
?: predicates (suffix)
=: equality functions (suffix)

Did I miss any?

Note that I excluded symbols that already have special meaning to the
reader: http://docs.racket-lang.org/reference/reader.html

(Should these go in the style guide somewhere?)

Another idea is to use two or more symbols?










 --
 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] API function naming

2015-07-03 Thread Stephen Chang
 Perhaps this isn’t applicable in this case, but may I suggest a less-common 
 alternative: no prefixing at all? If you put all the commands into a separate 
 module, users of the module can use ‘prefix-in’ to choose whatever prefix 
 they prefer.

Prefixes (and suffixes) have two purposes. One is to disambiguate a
global namespace, as with the set- or hash- functions. I think
your proposal applies in this case and I mostly agree.

The other purpose is to convey a (sometimes package-local) convention.
For example, users of my Parsack package know that any $-prefixed
identifier is a parser. Removing the prefix would defeat the
readability that I'm trying to achieve, similar to removing the '?'
from predicates.

John's case seems to fall into the latter so I think a prefix would be
useful. (And I second Neil T's suggestion.)




 This can be paired with documentation that uses a particular prefix in all 
 its examples, encouraging a standard of sorts, but the choice of any prefix 
 would still be available if a user prefers. For an example of this in the 
 wild see Racket’s own parser-tools library 
 (http://docs.racket-lang.org/parser-tools/Lexers.html). The common matchers 
 are provided unprefixed in the parser-tools/lex-sre module, but the docs 
 consistently use a ‘:’ prefix to create a standardized usage.

 This doesn’t eliminate the problem of needing to choose a prefix entirely, 
 but it does give a little more flexibility to avoid the fear of choosing a 
 prefix some users really don’t like.

 Alexis

 --
 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] variadic function who use parameters from a mother variadic function

2015-07-03 Thread Stephen Chang
Actually, ~a by itself might do what you want.

(~a 1 2 3) ; = 123

On Fri, Jul 3, 2015 at 4:18 PM, Stephen Chang stch...@ccs.neu.edu wrote:
 I think the call to values is misplaced.

 Here's a functioning version of foo, and a perhaps more concise alternative:

 (define (foo . L)
   (let ([bar (string-join (build-list (length L) (λ (x) ~a)) )])
 (apply format bar L)))

 (define (my-foo . L)
   (string-join (map ~a L) ))

 On Fri, Jul 3, 2015 at 4:06 PM, mazert rom...@elgeekador.net wrote:
 Hello,

 To directly go to the essential : here is an example :

 (define (foo . L)
   (let ([bar (string-join (build-list (length L) (λ (x) ~a)) )])
 (format bar (apply values L

 Globally, I want to use a function who has variable parameters within a
 function who has variable parameters too.

 It is possible ?
 Thanks in advance.

 --
 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] variadic function who use parameters from a mother variadic function

2015-07-03 Thread Stephen Chang
I think the call to values is misplaced.

Here's a functioning version of foo, and a perhaps more concise alternative:

(define (foo . L)
  (let ([bar (string-join (build-list (length L) (λ (x) ~a)) )])
(apply format bar L)))

(define (my-foo . L)
  (string-join (map ~a L) ))

On Fri, Jul 3, 2015 at 4:06 PM, mazert rom...@elgeekador.net wrote:
 Hello,

 To directly go to the essential : here is an example :

 (define (foo . L)
   (let ([bar (string-join (build-list (length L) (λ (x) ~a)) )])
 (format bar (apply values L

 Globally, I want to use a function who has variable parameters within a
 function who has variable parameters too.

 It is possible ?
 Thanks in advance.

 --
 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] right abstraction for this?

2015-06-11 Thread Stephen Chang
Would any of the functions in unstable/list help? For example,

#lang racket
(require unstable/list)

(define (gather lst)
  (for/hash ([g (group-by car lst)])
(values (caar g) (append-map cdr g

(gather '((a c) (a d) (b e) (b f)))
; = '#hash((a . (c d)) (b . (e f)))

On Thu, Jun 11, 2015 at 12:25 PM, 'John Clements' via users-redirect
us...@plt-scheme.org wrote:
 I write this kind of code all the darn time:

 ;; take (listof (list a b)) into (hashof a (listof b))
 (define (gather l)
   (for/fold ([ht (make-hash)])
 ([pr l])
 (hash-set ht (first pr) (cons (second pr)
   (hash-ref ht (first pr) empty)

 ;; gather the responses into a table:
 (define rating-table (gather responses2))

 ;; compute the mean rating for each student
 (for/list ([(student ratings) (in-hash rating-table)])
   (list student (mean ratings)))

 … that is: given an association list, gather them together, then compute 
 (say) the mean of the values. In this case, I’m trying to compute the mean 
 rating for a bunch of students. Very simple.

 So… why does it take so much code? I feel like these should be built-in 
 abstractions. There are (at least) two possibilities:

 1) There’s an obvious, built-in way to do this, and I’m just missing it.
 2) There’s an abstraction that we’re missing, and I feel like Clojure might 
 have it. Or am I just making this up? Getting clojure running is such a pain….

 Thanks for any advice!

 John

 --
 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] Re: Use Parsack to parse a #language?

2015-05-12 Thread Stephen Chang
 Once I get my head around what's needed to connect up a custom
 reader

Matthew's example from his talk at the first RacketCon (and other
conferences) might be a good place to start:
https://github.com/mflatt/scratchy/blob/master/scratchy/reader.rkt
https://github.com/mflatt/scratchy/blob/master/scratchy/parser.rkt

 I seem to recall that Racket used to come with a combinator parser
library. It's been removed but I don't remember why

(Replying to myself) I found the old library. Looks like it was
discontinued for lack of a maintainer.
http://planet.racket-lang.org/package-source/plt/combinator-parser.plt/1/0/planet-docs/combinator-parser/index.html

-- 
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] Re: Use Parsack to parse a #language?

2015-05-11 Thread Stephen Chang
Glad you're having a good time!

I think you should be able to use it to implement your language's
reader but I don't have any actual experience doing so.

I seem to recall that Racket used to come with a combinator parser
library. It's been removed but I don't remember why but maybe that
could be an indication that it's not a good idea?

My library is currently a straight port from Haskell (ie, not
idiomatic Racket) so it won't be as nice as the built-in parsing tools
in terms of fitting into the Racket toolchain. You may have to do some
manual gluing.

A few things off the top of my head:
1) Input-wise the parser combinators only consume strings. To be fully
Rackety, they should work with ports (if anyone wants to take a crack
at it, it would be very appreciated).
2) You'll have to manually convert the character outputs to syntax.
3) You'll have to manually extract the source location from the
parsack state and add it to your syntax objects.

Greg Hendershott can probably fill you in on more unpleasantries, as
his markdown parser is the biggest client (that I currently know of)
:)


On Mon, May 11, 2015 at 9:40 PM, Daniel Prager
daniel.a.pra...@gmail.com wrote:
 I've been having a great time playing with Stephen Chang's Parsack
 (parsec-style parsing for Racket) and enjoying the straightforward learning
 curve and usability. Thanks Stephen!

 Has anyone used Parsack to do the parsing for a little language and then
 plugged it into the main Racket infrastructure?

 Good idea? Mismatched tool? What does it / would it take?


 Thanks

 Dan

-- 
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] Re: [racket] Racket 6.0 does not work

2015-05-05 Thread Stephen Chang
 ./racket: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found 
 (required by ./racket)

I just ran into this problem and a search led me to this thread, thanks.

I am running Debian 7.8 wheezy which includes glibc 2.13. I originally
used the Ubuntu 12.04 (Precise) 64bit installer from the Utah snapshot
page and got the above error.
http://www.cs.utah.edu/plt/snapshots/

I then installed with the wheezy 64bit installer from the Northwestern
snapshot page and everything worked out of the box.
http://plt.eecs.northwestern.edu/snapshots/

Thanks everyone.

On Wed, Mar 12, 2014 at 6:42 PM, Matthew Flatt mfl...@cs.utah.edu wrote:
 The new download pages include a 64-bit Debian Squeeze installer for v6.0.

 At Mon, 10 Mar 2014 07:10:50 +0100, Manfred Lotz wrote:
 John Clements asked about a Debian version the other day. Robby Findler
 pointed him to: http://plt.eecs.northwestern.edu/snapshots/

 I suggest downloading the Debian Wheezy version which I guess would
 have the glibc version you need.


 --
 Manfred


 On Wed, 5 Mar 2014 18:03:26 -0300
 Junia Magellan jun...@gmail.com wrote:

  I am a professor of Computer Science in a technological institute. My
  research is comparing productivity of computer languages using
  Measurement Theory. I think you already know that from my previous
  posts. The point is that Racket 6.0 installer is very unfriendly.
  Well, it is almost like the installer of Racket 6.0. The only
  difference is that Racket 6.0 does not work.
 
  I asked about 8 students to install Racket 6.0. Nobody succeeded.
  100% of failures. I tried the installation myself, and failed. I will
  give an example.  I am using Cloud computing, and cannot modify the
  machine. For instance, I cannot install a new operating system to
  satisfy the requirements of Racket 6.0. Given these constraints, the
  situation is the following:
 
  cat /proc/cpuinfo
 
  vendor_id: AuthenticAMD
  cpu family: 21
  model: 2
  model name: AMD Opteron 63xx class CPU
  stepping: 0
  microcode: 0x165
  cpu MHz: 2299.909
  cache size: 512 KB
  fpu: yes
  fpu_exception: yes
  cpuid level: 13
  wp: yes
  bogomips: 4599.81
  TLB size: 1024 4K pages
  clflush size: 64
  cache_alignment: 64
  address sizes: 48 bits physical, 48 bits virtual
 
  This particular machine has 16 cores, and the kernel is:
 
  uname -mrs
  Linux 3.2.52 x86_64
 
  When I try to run Racket 5.36, everything works perfectly well. Here
  is an example:
 
  # mv racket racket60
  # mv racket-old/ racket
  # racket/bin/racket -il xrepl
  Welcome to Racket v5.3.6.
  - (* 3 4 5)
  60
  - (exit)
 
  Now, let us see what happens with Racket 6.0:
 
  # mv racket racket-old
  # mv racket60 racket
  # mv racket60 racket
  # racket/bin/racket
  racket/bin/racket: /lib64/libc.so.6: version `GLIBC_2.14' not found
  (required by racket/bin/racket)
  #
 
  I would like you to understand that most people are not PhD in
  Computer Science. 90% of people want to run out of the box
  applications. Even programmers don't have in depth knowledge about
  the workings of computers and operating systems. I don't know why
  Racket 6.0 needs libc.so.6, or GLIBC_2.14. I just want to run
  statistics programs written in Racket from an Internet page.
 
  I will give you another example about Racket 6.0. There are a lot of
  people that use a text editor called Vim+mzscheme. This text editor
  has a lot of applications about Rasch measurement, that are used by
  people in the business of education. I mean, people who work in
  things like SAT, GRE, USMLE, and equivalent activities in countries
  around the world. These programs test students, and the processed
  scores are often used by admission offices to accept applicants. I
  happen to work with this kind of programs.
 
  Installing Vim+mzscheme is a nuisance, since people must compile
  Racket from sources, and Vim from sources. In Windows, few people
  succeed in performing the task. The same is true in the case of OS-X.
  I am talking about Racket 5.36, for I don't know a single person who
  installed vim+mzscheme with Racket 6.0.
 
  What I need is a version of Racket that work right out of the box, at
  least for OS-X, Windows 7, Windows 8, and Linux. I also need a fast
  editor, like Vim.
 
  Well members of this list, here is what I am going to do. I will
  download Bigloo, learn how to use it, hire a programmer to write
  array operations in Bigloo, translate a lot of programs from Racket
  and Common Lisp to Bigloo, and start from zero, as in Edith Piaf's
  song.
 
 
 
 
 
  * Junia Magalhães Rocha*
 
  Doutoranda em Inteligência Artificial - Engenharia Elétrica - UFU
  Mestre em Inteligência Artificial - Ciência da Computação - UFU
 
  Docente do IFTM - Campus Avançado Patrocínio
 
  Lattes: http://lattes.cnpq.br/3659680417351721
 




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