Re: [racket-users] Re: Functional object-oriented programming

2017-02-08 Thread Steve Byan's Lists
> On Feb 8, 2017, at 9:05 PM, Philip McGrath wrote: > Personally, I tend to end up defining helper functions to do functional > update (often with optional keyword arguments to address the > fields-that-stay-the-same issue). Generics in the sense of racket/generic can

Re: [racket-users] Re: Functional object-oriented programming

2017-02-08 Thread Philip McGrath
Note, though, that struct-copy needs to be given the type of the resulting structure statically, at compile time, and "the result of *struct-expr* can be an instance of a sub-type of *id*, but the resulting copy is an immediate instance of *id* (not the sub-type)." [1] If you have a complex

Re: [racket-users] Re: Functional object-oriented programming

2017-02-08 Thread Steve Byan's Lists
Matthias, thanks for the confirmation that macros are the answer. Yes, mutation could be simpler. I'm learning more doing it functionally. Alex, thanks for pointing out struct-copy. I hadn't read that part of the Racket Guide yet. Would it be possible to write a macro that when invoked within

[racket-users] Re: Functional object-oriented programming

2017-02-08 Thread Alex Harsanyi
Structures support this style of updating: (struct foo (bar baz) #:transparent) (define one (foo "hello" 1)) ;; Copy all fields from "one" and update baz to 2 (define two (struct-copy foo one (baz 2))) They also have immutable fields by default. Best Regards, Alex. -- You

Re: [racket-users] Functional object-oriented programming

2017-02-08 Thread Matthias Felleisen
Yes. I have used this pattern extensively and locally defined macros is what you want. But, just in case it is not obvious, you can also mutate fields in Racket and perhaps that’s what you really want. Racket is not ideological about functional purity. > On Feb 8, 2017, at 3:54 PM, Steve

Re: [racket-users] Fun with keyword-apply

2017-02-08 Thread Dan Liebgold
On Wednesday, February 8, 2017 at 2:08:49 PM UTC-8, Ryan Culpepper wrote: > >(require (for-syntax syntax/parse/experimental/template)) >(define-syntax (test-syntax stx) > > (define-splicing-syntax-class spec > as in your original version ) > > (syntax-parse stx

Re: [racket-users] Fun with keyword-apply

2017-02-08 Thread Ryan Culpepper
On 02/08/2017 04:41 PM, Dan Liebgold wrote: Hi all - I have an odd syntax I'm trying to maintain backward compatibility with, but I'd like to take advantage of keyword parameters to accommodate the presence/absence/ordering of those parameters. Here's an example of what I'm trying to do:

[racket-users] Fun with keyword-apply

2017-02-08 Thread Dan Liebgold
Hi all - I have an odd syntax I'm trying to maintain backward compatibility with, but I'd like to take advantage of keyword parameters to accommodate the presence/absence/ordering of those parameters. Here's an example of what I'm trying to do: http://pasterack.org/pastes/88615 Can you think

[racket-users] Functional object-oriented programming

2017-02-08 Thread Steve Byan's Lists
I'm just learning Racket's object system. I feel like I've missed something, as it seems pretty verbose to functionally update objects. The pattern I use when functionally updating object state is to invoke the class constructor with a full set of arguments, some subset of which have updated

Re: [racket-users] read from stdin, except when run in DrRacket

2017-02-08 Thread Steve Byan's Lists
> On Feb 8, 2017, at 2:06 PM, Matthias Felleisen wrote: > > > I thought of giving this answer too, but if this is about testing let me > propose a slightly different approach: Thanks. By "testing" I meant flailing around in the REPL while I a) learn Racket and b)

Re: [racket-users] read from stdin, except when run in DrRacket

2017-02-08 Thread Matthias Felleisen
I thought of giving this answer too, but if this is about testing let me propose a slightly different approach: #lang racket ;; assume main has two arguments (define (main) (define args (current-command-line-arguments)) (if (= (vector-length args) 0) (do-it)

Re: [racket-users] read from stdin, except when run in DrRacket

2017-02-08 Thread Steve Byan's Lists
> On Feb 8, 2017, at 2:02 PM, Ben Greenman wrote: > > One idea: you can put the argument-parsing code in the "main" submodule, then > tell DrRacket not to run the main submodule. [snip] > Then in DrRacket, click "Language -> Choose Language -> Show Details -> >

[racket-users] read from stdin, except when run in DrRacket

2017-02-08 Thread Steve Byan's Lists
I'm working on a script that I eventually plan to invoke from the command line. I'd like the script to either take a file name argument or, if no arguments, read from stdin. However, while developing the script in DrRacket, I'd like to not invoke the top-level function, and to instead define an

Re: [racket-users] IMAP with racket

2017-02-08 Thread Tim Hanson
Cool, thank you! I had no idea about parameterize. I will try that and continue my investigations. -- 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] IMAP with racket

2017-02-08 Thread Matthew Flatt
At Tue, 7 Feb 2017 21:54:40 -0800 (PST), Tim Hanson wrote: > https://docs.racket-lang.org/net/imap.html#%28def._%28%28lib._net%2Fimap..rkt%2 > 9._imap-port-number%29%29 > > Does this make imap-port-number a kind of global variable? Normally, `imap-port-number` would be used with `parameterize`

[racket-users] How to debug segmentation fault in Racket application

2017-02-08 Thread Alex Harsanyi
Occasionally, my Racket application crashes with a segmentation fault (under Windows). The crash is a NULL pointer reference. Unfortunately, having no PDB's the stack trace only contains a list of addresses. Unfortunately, this only happens occasionally, but under the same conditions. It

Re: [racket-users] How to implement a dynamic plugin system?

2017-02-08 Thread Erich Rast
Thanks Matthias and Laurent for your advice! I've taken a look at the source code in MrEd designer and understand how dynamic-require works, but have decided against the plugin structure at least for now, since plugin access to a shared database creates other problems - it turned out at a closer

Re: [racket-users] IMAP with racket

2017-02-08 Thread Tim Hanson
P.s. For that matter couldn't folder also be optional, defaulting to "INBOX"? -- 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