Re: [racket-users] Question about style

2018-08-16 Thread 'Paulo Matos' via Racket Users
On 11/08/18 16:11, Bob Heffernan wrote: > Dear all, > > I am new to Racket and only slightly less new to scheme & scheme-like > languages. > > I have noticed myself often doing something like the following: > > (define (foo x) > (let* ([y (f x)] > [z (g y)] > [p (h z)]) >

Re: [racket-users] Question about style

2018-08-16 Thread Robert Girault
On Thu, Aug 16, 2018 at 6:44 AM 'Paulo Matos' via Racket Users wrote: > On 11/08/18 16:11, Bob Heffernan wrote: > > Dear all, > > > > I am new to Racket and only slightly less new to scheme & scheme-like > > languages. > > > > I have noticed myself often doing something like the following: > > >

[racket-users] Re: Confused by match

2018-08-16 Thread Alex Gian
It will work like this > (match '( b b b b b b ) [(list x ... y ... ) #:when (equal? x y) (list 'x: x 'y: y)]) '(x: (b b b) y: (b b b)) But does (list x ... x ... ) not obviate the need for (list x ... y ... ) #:when (equal? x y) ? -- You received this message because you

Re: [racket-users] Question about style

2018-08-16 Thread Matthias Felleisen
> On Aug 16, 2018, at 8:22 AM, Robert Girault > wrote: > > I think I'd write your example like this. > > (define (foo x) > (local ((define y (f x)) > (define z (g y)) > (define p (h z))) >(bar p))) > > (If I knew what f, g, h do, I might write it differently. If

Re: [racket-users] Confusion about attributes of struct-id

2018-08-16 Thread Ryan Culpepper
On 08/16/2018 06:04 PM, David Storrs wrote: The struct-id syntax class from syntax/parse/class/struct-id is puzzling me.  Given this preamble: (require (for-syntax syntax/parse/class/struct-id syntax/parse syntax/parse/experimental/template

Re: [racket-users] Re: Confused by match

2018-08-16 Thread David Storrs
On Thu, Aug 16, 2018 at 12:08 PM, Alex Gian wrote: > Well, it's not often I'm happy when I see a bug, but thank Fog for that. > Thanks, gfb. > > @David K. Storrs. > I'm not sure your explanation is right, unless it's explaining the bug. > Surely the two values for 'x' must be the same! > Given

Re: [racket-users] Confusion about attributes of struct-id

2018-08-16 Thread David Storrs
On Thu, Aug 16, 2018 at 12:19 PM, Ryan Culpepper wrote: > On 08/16/2018 06:04 PM, David Storrs wrote: > >> The struct-id syntax class from syntax/parse/class/struct-id is puzzling >> me. Given this preamble: >> >> >> (require (for-syntax syntax/parse/class/struct-id >>

Re: [racket-users] Confused by match

2018-08-16 Thread David Storrs
On Wed, Aug 15, 2018 at 10:08 PM, Alex Gian wrote: > Normally in match... > > > (match '(a b b b b b b a) > [`(,x ,y ... ,x) (list 'x: x 'y: y)]) > '(x: a y: (b b b b b b)) > > > (match '(a b b b b b b d) > [`(,x ,y ... ,x) (list 'x: x 'y: y)] > [_ 'nope]) > 'nope > > > So far, so

Re: [racket-users] Question about style

2018-08-16 Thread Bob Heffernan
On 18-08-16 11:43, 'Paulo Matos' via Racket Users wrote: > I really, really don't like nesting and a few years ago adopted the > style of internal defines. It makes for much more readable code: > > (define (foo x) > (define y (f x)) > (define z (g y)) > (define p (h z)) > > (bar p))

Re: [racket-users] Question about style

2018-08-16 Thread Robert Girault
On Thu, Aug 16, 2018 at 10:25 AM Matthias Felleisen wrote: > > On Aug 16, 2018, at 8:22 AM, Robert Girault > > wrote: > > > > I think I'd write your example like this. > > > > (define (foo x) > > (local ((define y (f x)) > > (define z (g y)) > > (define p (h z))) > >(bar

[racket-users] Interaction between define/private and keyword arguments

2018-08-16 Thread 'Paulo Matos' via Racket Users
Hi, I spent a whole day trying to find and then reduce an issue I was having with my software. A procedure, suddenly, was just not being called. It was as if the call was just gone - pufft. Nothing I did helped. I was confused - but after a day I managed to reproduce this with a ridiculously

[racket-users] Re: Confused by match

2018-08-16 Thread gfb
This is an undocumented limitation of match: - issue on github - issue on github -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To

Re: [racket-users] Interaction between define/private and keyword arguments

2018-08-16 Thread Robby Findler
Yes, this looks like a bug. I see something went wrong between versions 6.6 and 6.7. As for `define` vs `define/private`, they are not the same. In the `define` case, storage is allocated in the object (since it is a field, bound to a procedure) and in the `define/private` case, it isn't (since

Re: [racket-users] Interaction between define/private and keyword arguments

2018-08-16 Thread 'Paulo Matos' via Racket Users
On 16/08/18 19:42, Robby Findler wrote: > Yes, this looks like a bug. I see something went wrong between > versions 6.6 and 6.7. > Thanks, opened #2232. > As for `define` vs `define/private`, they are not the same. In the > `define` case, storage is allocated in the object (since it is a >

[racket-users] Converting Windows line-endings for arbitrary ports

2018-08-16 Thread Philip McGrath
I would like to apply the same line-ending conversion that open-input-file with a #:mode of 'text does on Windows to arbitrary input ports, like Racket-level pipes (in the sense of make-pipe). Specifically, I have an external program that I invoke with system* which reads from and writes to

Re: [racket-users] Interaction between define/private and keyword arguments

2018-08-16 Thread Robby Findler
That probably would have been better but we opted to reuse the definition of the define macro. Too clever by half (maybe). Robby On Thu, Aug 16, 2018 at 1:40 PM 'Paulo Matos' via Racket Users < racket-users@googlegroups.com> wrote: > > > On 16/08/18 19:42, Robby Findler wrote: > > Yes, this

[racket-users] all-fields-visible? attribute of struct-id -- What is it?

2018-08-16 Thread David Storrs
struct-id from (require syntax/parse/class/struct-id

[racket-users] What are disappeared-uses?

2018-08-16 Thread David Storrs
I see 'record-disappeared-uses' and 'with-disappeared-uses' in the docs, but there's nothing that makes clear what you would use them for. Some digging around on the mailing list suggests that they allow Dr Racket to draw an arrow to a relevant source location. Do they have any use outside of Dr

Re: [racket-users] What are disappeared-uses?

2018-08-16 Thread Alexis King
> On Aug 16, 2018, at 15:25, David Storrs > wrote: > > I see 'record-disappeared-uses' and 'with-disappeared-uses' in the > docs, but there's nothing that makes clear what you would use them > for. Some digging around on the mailing list suggests that they allow > Dr Racket to draw an arrow to

Re: [racket-users] Interaction between define/private and keyword arguments

2018-08-16 Thread 'Paulo Matos' via Racket Users
I understand, I would have preferred something more explicit, like using define for fields as it is but then instead of using define again for methods, with possibly public or private annotations to have something like define-method/public and define-method/private. It feels to me that

Re: [racket-users] Question about style

2018-08-16 Thread Deren Dohoda
> > Thanks for the up-vote but let me explain the “local” rationale here and > vote for the ‘inner define’ variant. > [snip]... > > > In Racket programs for the world, possibly real, you want to avoid > rightward drift. Indenting deeper and deeper makes code appear ‘ugly’ to > many eyes,

[racket-users] How to handle define forms in a scribble-like language

2018-08-16 Thread Vityou
I'm attempting to make a language similar to scribble. I'm using the `make-at-reader` that scribble provides, and have my module-begin as this: (define-syntax md-module-begin (syntax-parser [(_ (expr1 ...)) #'(#%module-begin (define doc (parse-markdown (string-append (begin expr1) ...)))

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-16 Thread Philip McGrath
You probably want to partially expand the expressions, collect the definitions, and lift them to the module level. -Philip On Thu, Aug 16, 2018 at 11:58 PM, Vityou wrote: > I'm attempting to make a language similar to scribble. I'm using the > `make-at-reader` that scribble provides, and have

Re: [racket-users] all-fields-visible? attribute of struct-id -- What is it?

2018-08-16 Thread Alexis King
> On Aug 16, 2018, at 15:35, David Storrs > wrote: > > struct-id from (require syntax/parse/class/struct-id) has an > all-fields-visible? attribute. I've looked around and can't figure > out what would cause a field to not be visible. Can someone point me > to the relevant part of the FM?

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-16 Thread Alexis King
You might find make-wrapping-module-begin from syntax/modbeg useful here: http://docs.racket-lang.org/syntax/module-helpers.html#%28def._%28%28lib._syntax%2Fwrap-modbeg..rkt%29._make-wrapping-module-begin%29%29 Alexis > On Aug 16, 2018, at 18:58, Vityou wrote: > > I'm attempting to make a

Re: [racket-users] Question about style

2018-08-16 Thread Greg Hendershott
Have you ever considered extending the grammar of define from this: (define id expr) (define (head args) body ...+) To this: (define id expr ... ...); <-- like e.g. `hash` (define (head args) body ...+) So we could write things like: (define x 0 y 1 z 2) Sometimes so much

Re: [racket-users] Question about style

2018-08-16 Thread Philip McGrath
With just a few more parentheses, I have a macro that lets you write: (def [x 0] [y 1] [z 2] ;; or even [(f x) (/ (+ x y) z)]) http://docs.racket-lang.org/adjutor/Stable.html#(form._((lib._adjutor%2Fmain..rkt)._def)) I like explicit delimiters, but I agree that a bunch of one-line

Re: [racket-users] Question about style

2018-08-16 Thread Neil Van Dyke
Bob Heffernan wrote on 08/16/2018 12:43 PM: When it comes to nesting (which, I guess, means the use of let) vs internal defines: is this purely an aesthetic thing? I think, practically, you could call it only aesthetic, since the PLT developers are invested in making internal `define` work

Re: [racket-users] Converting Windows line-endings for arbitrary ports

2018-08-16 Thread Greg Hendershott
Could you use `read-line`, supplying 'any for the optional `mode` argument? https://docs.racket-lang.org/reference/Byte_and_String_Input.html#(def._((quote._~23~25kernel)._read-line)) If reading in line-sized chunks would be awkward for your existing code: I suppose you add a second pipe

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-16 Thread Vityou
How would I go about doing this? Is there a certain function that can tell if something is a top-level declaration? On Thursday, August 16, 2018 at 6:44:53 PM UTC-6, Philip McGrath wrote: > > You probably want to partially expand the expressions, collect the > definitions, and lift them to the

Re: [racket-users] How to handle define forms in a scribble-like language

2018-08-16 Thread Philip McGrath
In general, you can look for identifiers that are free-identifier=? to something from the grammar for "fully expanded programs" ( https://docs.racket-lang.org/reference/syntax-model.html#%28part._fully-expanded%29). That's a little abstract, though, so I've included an example. There might be more