Re: [racket-users] Macro generating macro question

2023-05-24 Thread Kevin Forchione
> On May 24, 2023, at 2:11 AM, Jens Axel Søgaard wrote: > > #lang racket > (require (for-syntax syntax/parse > racket/syntax)) > > (define-syntax (make-id-macro stx) > (syntax-parse stx > [(_ id) > (with-syntax ([name (format-id #'id "do-~a" #'id)] >

[racket-users] Macro generating macro question

2023-05-23 Thread Kevin Forchione
Hi guys, I’m stumped. In a nutshell I want to write a macro that is passed an id and will produce a macro called id that can take variable arguments. I’m sure I’m overlooking something fundamental. The basic form below “works” if I don’t have ellipsis aver the variables, but that’s not what

Re: [racket-users] [racket users] list question

2021-02-25 Thread Kevin Forchione
> On Feb 25, 2021, at 10:12 AM, Norman Gray wrote: > > > I think this is called 'zip', or a convolution [1]. The variant you describe > is (effectively) with circular lists, but seems to be the same principle. > > ...and I see that, with that name in hand, SRFI/1 does indeed have a zip >

[racket-users] [racket users] list question

2021-02-25 Thread Kevin Forchione
Hi guys, I’m trying to find out what this process may be called. Suppose you have lists of various lengths: ‘(A B C D E F) ‘(1 2) ‘(3 4 5) And you want tho produce the following: '((A 1 3) (B 2 4) (C 1 5) (D 2 3) (E 1 4) (F 2 5) (A 1 3) (B 2 4) (C 1 5) (D 2 3) ...) As you can see each

[racket-users] [racket users] Detecting characters in symbols in macros

2020-12-09 Thread Kevin Forchione
Hi guys, Is there a way to detect a character in a symbol in a macro so that one branch of the syntax-parse would be chosen or discarded based on that? Here’s roughly what I’m getting at…. #lang racket (require (for-syntax syntax/parse)) (define-syntax (foo stx) (syntax-parse stx [(_

Re: [racket-users] [racket users] Pollen tag question

2020-10-30 Thread Kevin Forchione
> On Oct 30, 2020, at 12:25 PM, Matthew Butterick wrote: > > Spaces at the beginning of body lines do not appear in the resulting > S-expressions, but the column of each line is noticed, and all-space > indentation strings are added so the result has the same indentation … If the > first

Re: [racket-users] [racket users] Pollen tag question

2020-10-30 Thread Kevin Forchione
If I remove my pollen.rkt from the directory and use: #lang pollen A B C D I get: '(root "A B" "\n" "C D”) But if I use: #lang pollen ◊(define foo "foo") A B C D I get: '(root " " "A B" "\n" " " "C D")

Re: [racket-users] [racket users] Pollen tag question

2020-10-30 Thread Kevin Forchione
> On Oct 29, 2020, at 9:21 PM, Sorawee Porncharoenwase > wrote: > > Whoops. I meant: > > #lang pollen > > ◊(define (vb . s) s) > > ◊vb{ A B >C D} > and the output is: > > '(" A B" "\n" " " "C D") > > On Thu, Oct 29, 2020 at 9:19 PM

[racket-users] [racket users] Pollen tag question

2020-10-29 Thread Kevin Forchione
Hi guys, I’ve noticed that the elements being sent to a pollen tag don’t preserve the spacing when the text spans multiple lines for any space occurring before characters on the subsequent line, although does preserve the spacing between characters on that line.Is thes intentional? For

Re: [racket-users] [racket users] Macros sharing data?

2020-10-21 Thread Kevin Forchione
> > Here’s a toy example. It generates an error, but hopefully conveys the idea > I’m trying to express. > > #lang racket > > (require (for-syntax syntax/parse) > racket/stxparam > racket/stxparam-exptime) > > (define-syntax-parameter mval 1) > > (define-syntax (foo stx) >

Re: [racket-users] [racket users] Macros sharing data?

2020-10-21 Thread Kevin Forchione
> On Oct 21, 2020, at 10:33 AM, William G Hatch wrote: > > On Wed, Oct 21, 2020 at 10:07:12AM -0700, Kevin Forchione wrote: >> Hi guys, >> Suppose I have a macro that computes a value and then calls another macro in >> its template. Is there a way to share t

[racket-users] [racket users] Macros sharing data?

2020-10-21 Thread Kevin Forchione
Hi guys, Suppose I have a macro that computes a value and then calls another macro in its template. Is there a way to share that data with the 2nd macro without passing it as an argument? Thanks! Kevin -- You received this message because you are subscribed to the Google Groups

Re: [racket-users] [racket users] make-keyword-procedure follow-up

2020-10-09 Thread Kevin Forchione
> On Aug 30, 2019, at 1:19 AM, Philip McGrath wrote: > > Hi Kevin, > > This is interesting! A number of people have wanted conveniences around > `keyword-apply` and accepting the same keywords as some other function. (The > trouble is, different people have different ideas of what those

[racket-users] [racket users] scribble using @ as text?

2020-09-24 Thread Kevin Forchione
Hi guys, I’ve been racking my brains and going through scribble manuals trying to figure out how to do something as simple as proceed a sentence like: The @ is used in a scribble command. I’m sure I’m overlooking something very basic, since the @ is referenced all over scribble documentation.

[racket-users] [racket users] Naming conventions

2020-09-18 Thread Kevin Forchione
Hi guys, Racket has some naming conventions that I’ve come across: parameters prefixed with “current-“, class and interfaces suffixed with % and <%> respectively. I’ve not stumbled across one for structs yet. Suppose I have a circle struct and want to distinguish this from the http/image

Re: [racket-users] [racket users] describe variant issue?

2020-09-17 Thread Kevin Forchione
> On Sep 15, 2020, at 3:11 PM, Sam Tobin-Hochstadt wrote: > > This is a difference in behavior between Racket BC and Racket CS, and > not something in the describe library: > > [samth@homer:~/work/teaching/c211 (master) racket-7.8] racket > Welcome to Racket v7.8. >> (struct->vector 5) >

[racket-users] [racket users] describe variant issue?

2020-09-15 Thread Kevin Forchione
Hi guys, I’m not sure why the describe library’s variant is always returning ‘simple regardless of numeric value. For instance, the docmentation says: (variant 1) ->

Re: [racket-users] [racket users] %app question

2020-08-14 Thread Kevin Forchione
> On Aug 13, 2020, at 1:05 PM, Jens Axel Søgaard wrote: > > Den tor. 13. aug. 2020 kl. 21.55 skrev Kevin Forchione <mailto:lyss...@gmail.com>>: > Hi guys, > > In Bracket [1] used your idea to produce s-expression, if the first argument > of #%app isn't a f

[racket-users] [racket users] %app question

2020-08-13 Thread Kevin Forchione
Hi guys, Pollen makes use of something like this: (require syntax/parse/define) (define-simple-macro (#%top . x) 'x) and it comes in handy in some of my projects. But I’m wondering if there’s an equivalent for redirecting an application that hasn’t been defined? In other words, if foo is

[racket-users] [racket users] struct #:methods question

2020-04-20 Thread Kevin Forchione
Hi guys, How do you return an instance of the structure type from the struct’s #:methods? This is would seem to be a common situation, but it has me stumped. Kevin -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group

Re: [racket-users] [racket users] Generics question

2020-03-03 Thread Kevin Forchione
> On Mar 3, 2020, at 10:48 AM, Jon Zeppieri wrote: > > On Tue, Mar 3, 2020 at 12:37 PM Kevin Forchione wrote: >> >> Thanks! That brings me a little closer in appreciating the comments I’ve >> read about replacing object-oriented code with structs and m

Re: [racket-users] [racket users] Generics question

2020-03-03 Thread Kevin Forchione
> On Mar 3, 2020, at 9:19 AM, Jon Zeppieri wrote: > > (struct A (this other) #:transparent > #:methods gen:foo > [(define/generic generic-foo do-foo) > (define (do-foo foo) > (printf "other=~a ~a" > (A-this foo) > (generic-foo (A-other foo]) Thanks! That

[racket-users] [racket users] Generics question

2020-03-03 Thread Kevin Forchione
Hi guys, If I create a generic, say foo, for a particular struct and then later reference that method on a different type of struct from within the handler method I get an error because the call goes to the original structs method and not to the method of the other struct. Is there a way to do

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

2020-02-03 Thread Kevin Forchione
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

Re: [racket-users] [racket users] make-keyword-procedure follow-up

2019-08-30 Thread Kevin Forchione
> On Aug 30, 2019, at 1:19 AM, Philip McGrath wrote: > > Hi Kevin, > > This is interesting! A number of people have wanted conveniences around > `keyword-apply` and accepting the same keywords as some other function. (The > trouble is, different people have different ideas of what those

[racket-users] racket users] make-keyword-procedure follow-up

2019-08-29 Thread Kevin Forchione
> On Aug 29, 2019, at 1:24 PM, Kevin Forchione wrote: > > Hi guys, > I’ve been working for a little while with the idea of being able to pass > keyword arguments through a function that doesn’t define them. Additionally I > wanted to allow the “pass-through” function

[racket-users] [racket users] make-keyword-procedure follow-up

2019-08-29 Thread Kevin Forchione
Hi guys, I’ve been working for a little while with the idea of being able to pass keyword arguments through a function that doesn’t define them. Additionally I wanted to allow the “pass-through” function to define its own keywords. Additionally didn’t want to have to pre-specify what function

[racket-users] [racket users] Contracts and make-keyword-procedure question

2019-08-23 Thread Kevin Forchione
Suppose I have the following: (define/contract foo (-> ??? any/c symbol? symbol? any/c any) (make-keyword-procedure (lambda (kw kv a b . args) do-something …))) What sort of contract would I give to the kw parameter so that it basically accepts a list of unspecified keywords? What I’m doing

[racket-users] [racket ursers] Keyword question

2019-08-22 Thread Kevin Forchione
> On Aug 22, 2019, at 1:33 PM, Kevin Forchione wrote: > > Hi guys, > Suppose I have something like the following: > > (define (f g . args) > (apply g args)) > > How would I be able to pass keyword arguments to g? After racking my brains for th

[racket-users] [racket ursers] Keyword question

2019-08-22 Thread Kevin Forchione
Hi guys, Suppose I have something like the following: (define (f g . args) (apply g args)) How would I be able to pass keyword arguments to g? Kevin -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and

Re: [racket-users] [racket users] module question

2019-08-07 Thread Kevin Forchione
> On Aug 7, 2019, at 8:55 AM, Kevin Forchione wrote: > > > >> On Aug 6, 2019, at 4:06 PM, Sorawee Porncharoenwase > <mailto:sorawee.pw...@gmail.com>> wrote: >> >> (module B racket >> (require (submod ".." A)) >> (printf &q

Re: [racket-users] [racket users] module question

2019-08-07 Thread Kevin Forchione
> On Aug 6, 2019, at 4:06 PM, Sorawee Porncharoenwase > wrote: > > (module B racket > (require (submod ".." A)) > (printf "X=~a~%" X)) Why doesn’t printf display anything ? Kevin -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To

[racket-users] [racket users] module question

2019-08-06 Thread Kevin Forchione
Is there a way to define 2 modules within a file and reference them or is a file limited to 1 module only (but may have multiple submodules)? Here’s a small sample: #lang racket (module A racket ˘ (provide X) (define X 'foo)) (module B racket (require 'A) (printf "X=~a~%" X))

[racket-users] [racket users] make-posn question

2019-08-06 Thread Kevin Forchione
Hi guys, I love working with the 2htdp/universe and 2htdp/image packages. But polygon requires posts (and some of the other functions do too). 2htdp/image doesn’t include a definition. What’s the best library to require for these? I tried making my own struct and was surprised that the

[racket-users] Contracts referring to earlier elements?

2019-07-18 Thread Kevin Forchione
Hi guys, This is a little tricky to explain, so I’ll give a small example: [define/contract [foo x) (-> integer? not-x/c) body …) In this case the not-x/c is what I’m asking about. Some way that the contract can refer to a previous argument value? Ordinarily this would be a predicate, but the

Re: [racket-users] datatypes

2019-07-17 Thread Kevin Forchione
> On Jul 16, 2019, at 10:36 PM, Alex Knauth wrote: > > > >> On Jul 17, 2019, at 12:16 AM, Kevin Forchione > <mailto:lyss...@gmail.com>> wrote: >> >> Hi guys, >> Is there any function in Racket that will return a symbol representation of

[racket-users] datatypes

2019-07-16 Thread Kevin Forchione
Hi guys, Is there any function in Racket that will return a symbol representation of a value’s datatype? We can interrogate them with predicates, but it occurs to me that this information must be carried in the object’s syntax somewhere… otherwise the syntax->datum wouldn’t work. Of course I

Re: [racket-users] Contracts in lambda?

2019-07-11 Thread Kevin Forchione
> On Jul 11, 2019, at 12:34 PM, Alex Knauth wrote: > > > >> On Jul 11, 2019, at 1:15 PM, Kevin Forchione > <mailto:lyss...@gmail.com>> wrote: >> >>> On Jul 10, 2019, at 9:14 PM, Matthias Felleisen >> <mailto:matth...@felleisen.org>&g

Re: [racket-users] Contracts in lambda?

2019-07-11 Thread Kevin Forchione
> On Jul 10, 2019, at 9:14 PM, Matthias Felleisen > wrote: > > > [(contract (-> string? integer?) (λ (x) x) 'a 'b) > "hello”] By the way, I’ve been playing around with this (and define/contract) and it seems that ‘a in the above refers to the function itself, while to the best of my

Re: [racket-users] Contracts in lambda?

2019-07-11 Thread Kevin Forchione
> On Jul 10, 2019, at 9:14 PM, Matthias Felleisen > wrote: > > > [(contract (-> string? integer?) (λ (x) x) 'a 'b) > "hello”] Incidentally, I’m not sure why, it must be something to do with the way I take apart and put together the world (i.e. the way I “learn” :) , but until a few posts

Re: [racket-users] Contracts in lambda?

2019-07-11 Thread Kevin Forchione
> On Jul 10, 2019, at 9:14 PM, Matthias Felleisen > wrote: > > > [(contract (-> string? integer?) (λ (x) x) 'a 'b) > "hello”] > Nice! Thanks! Kevin -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and

[racket-users] Contracts in lambda?

2019-07-10 Thread Kevin Forchione
Hi guys, Is there a way to apply contracts to a lambda without associating it with an identifier? What I want is to be able to pass lambda functions around without having to bind them to a symbol. I could use raise-argument-error/ raise-result-error but the contract system is more powerful and

Re: [racket-users] Capturing print?

2019-07-10 Thread Kevin Forchione
> On Jul 10, 2019, at 1:53 PM, bruno cuconato wrote: > > there's > https://docs.racket-lang.org/reference/port-lib.html#%28def._%28%28lib._racket%2Fport..rkt%29._with-output-to-string%29%29 > >

[racket-users] Capturing print?

2019-07-10 Thread Kevin Forchione
Hi guys, Is there a wrapper or something like that that I can place around a print expression so that it captures it and returns a string value? Something like: [capture-print [printf “hello, world!”)) => “hello, world!” There are times when testing I’d like to capture the output and compare

Re: [racket-users] [racet-userx] Syntax Class Question

2019-07-08 Thread Kevin Forchione
> On Jul 8, 2019, at 10:50 AM, David Storrs wrote: > > > > On Mon, Jul 8, 2019 at 12:59 PM Kevin Forchione <mailto:lyss...@gmail.com>> wrote: > Hi guys, > I’ve noticed that the library provides *some* syntax classes: id, str, char, > expo… for various

Re: [racket-users] raise-argument-error missing list?

2019-07-08 Thread Kevin Forchione
> On Jul 8, 2019, at 10:41 AM, David Storrs wrote: > > Nothing specific that I'm aware of, but others could answer this better. If > there are then they're probably related to speed. > > Personally, I'm quite fond of them because they eliminate the need for a lot > of tests and make the

Re: [racket-users] raise-argument-error missing list?

2019-07-08 Thread Kevin Forchione
> On Jul 8, 2019, at 8:17 AM, David Storrs wrote: > > Note that in many cases it can be better to use a contract as opposed to an > explicit check. For example, you could replace this: > > (define (feed-animals cow sheep goose cat) > (if (not (eq? goose 'goose)) >

[racket-users] [racet-userx] Syntax Class Question

2019-07-08 Thread Kevin Forchione
Hi guys, I’ve noticed that the library provides *some* syntax classes: id, str, char, expo… for various datatypes, but not all. Obviously being such a handy aspect of syntax-parse there’s probably a reason for this. Having spent a few days trying to roll my own for procedure I have to suspect

Re: [racket-users] raise-argument-error missing list?

2019-07-05 Thread Kevin Forchione
> On Jul 5, 2019, at 10:51 AM, Matthew Flatt wrote: > > DrRacket hides the other arguments to make the error message initially > more compact. Click "..." in DrRacket to expose the arguments. > Thanks! The explanation has suddenly made it “intuitive” to me :) Kevin -- You received this

[racket-users] raise-argument-error missing list?

2019-07-05 Thread Kevin Forchione
Hi guys, Been adding raise-argument-error to my functions to catch errors and have noticed that the 2nd version of the form doesn’t actually list the other arguments - even for the example in the docs: >(define (feed-animals cow sheep goose cat) (if (not (eq? goose 'goose))

Re: [racket-users] symbols question

2019-06-21 Thread Kevin Forchione
> On Jun 20, 2019, at 10:18 PM, Sorawee Porncharoenwase > wrote: > > #lang racket > > (require syntax/parse/define) > > (define-simple-macro (#%top . x) 'x) > > (define x 42) > x ;=> 42 > y ;=> 'y > (string-length (symbol->string abcdef)) ;=> 6 > Unbound identifiers are wrapped with #%top

[racket-users] symbols question

2019-06-20 Thread Kevin Forchione
Hi guys, Every now and then I wonder about the decisions behind the languages we work with and of late I’m wondering about symbols. By default symbols reveal their binding value unless you explicitly tell them not to — in other words unless you quote them. And that’s pretty useful. In macros I

Re: [racket-users] macro guard question (ellipsis)

2019-06-19 Thread Kevin Forchione
> On Jun 18, 2019, at 9:03 PM, Sorawee Porncharoenwase > wrote: > > Also note that with syntax/parse, it becomes much easier: > > (require (for-syntax syntax/parse)) > > (define-syntax (foo stx) > (syntax-parse stx > [(_ (key:id val:id ...) ...) > #'(quote (list ((quote key)

[racket-users] macro guard question (ellipsis)

2019-06-18 Thread Kevin Forchione
Hi guys, I’ve been trying to figure out the syntax for a guard when the pattern has ellipsis and you want to guard one of the variables. Here’s an uninteresting macro but it shows what I mean. #lang racket (define-syntax (foo stx) (syntax-case stx () [(_ (key val ...) ...) (and

Re: [racket-users] macros and let/cc

2019-06-03 Thread Kevin Forchione
> On Jun 3, 2019, at 9:42 AM, Matthias Felleisen wrote: > > > >> On Jun 3, 2019, at 12:33 PM, Kevin Forchione wrote: >> >> Oh! I see! That solves the expansio issue! Wonderful. You’ve opened up a >> whole new set of possibilities for me. Thanks, M

Re: [racket-users] macros and let/cc

2019-06-03 Thread Kevin Forchione
> On Jun 3, 2019, at 9:09 AM, Matthias Felleisen wrote: > > > Or, > > #lang racket > > (require (for-syntax ) racket/stxparam) > > (define-syntax-parameter return (syntax-rules ())) > (define-syntax-parameter false (syntax-rules ())) > > (define-syntax fn > (syntax-rules () > [(_ (arg

Re: [racket-users] macros and let/cc

2019-06-03 Thread Kevin Forchione
> On Jun 3, 2019, at 8:51 AM, Matthias Felleisen wrote: > > > My code run your examples. Whay is missinng? > Here’s what I’ve been trying to run. #lang racket (require (for-syntax racket/syntax) racket/stxparam) (define-syntax-parameter false (lambda (stx)

Re: [racket-users] macros and let/cc

2019-06-03 Thread Kevin Forchione
> On Jun 3, 2019, at 4:54 AM, Alex Knauth wrote: > > > >> On Jun 3, 2019, at 1:02 AM, Kevin Forchione > <mailto:lyss...@gmail.com>> wrote: >>> On Jun 2, 2019, at 7:13 PM, Matthias Felleisen >> <mailto:matth...@felleisen.org>> w

Re: [racket-users] macros and let/cc

2019-06-02 Thread Kevin Forchione
> On Jun 2, 2019, at 7:13 PM, Matthias Felleisen wrote: > > > >> On Jun 2, 2019, at 9:41 PM, Kevin Forchione > <mailto:lyss...@gmail.com>> wrote: >> >> Hi guys, >> I’ve been working with macros and let/cc and have a situation where I h

[racket-users] macros and let/cc

2019-06-02 Thread Kevin Forchione
Hi guys, I’ve been working with macros and let/cc and have a situation where I have the 2nd macro bound to the let/cc return of the first. No idea how I’d do that, but here’s an example of what I’m attempting to do: #lang racket (require (for-syntax racket/syntax)) (define-syntax (fn stx)

Re: [racket-users] Macro guards question

2019-05-29 Thread Kevin Forchione
> On May 29, 2019, at 11:09 AM, Sorawee Porncharoenwase > wrote: > > (foo a) ;=> 1 > (foo "a") ;=> 2 > (foo 10) ;=> 3 > (foo 'a) ;=> 4 > (foo (bar x)) ;=> 5 Ah… thanks so much for the explanation. That’s put me much closer (I hope!) to the solution I’m after. A bit of stumbling around

[racket-users] Macro guards question

2019-05-29 Thread Kevin Forchione
Hi Guys, What are the rules for macro guards? I’ve only seen examples with (identifier? #’val) being used. What about (number? #’val) or (spring? #’val)? When I try these I get a foo: bad syntax so I’m suspecting these can’t be used or there’s some trick to them. What I’ve been trying to

Re: [racket-users] Macro help

2019-05-24 Thread Kevin Forchione
> On May 24, 2019, at 7:35 AM, Stephen Chang wrote: > > 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 >

[racket-users] Macro help

2019-05-23 Thread Kevin Forchione
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

[racket-users] [racket users] Struct property question

2019-03-01 Thread Kevin Forchione
Hi guys, I’m trying to understand an example from the Racket manuals. (struct mood-procedure (base rating) #:property prop:procedure (struct-field-index base)) (define happy+ (mood-procedure add1 10)) (happy+ 2) <= 3 How does this work? It appears that prop:procedure is predefined. It

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Kevin Forchione
> On Sep 16, 2018, at 10:07 PM, Matthew Butterick wrote: > > >> On Sep 16, 2018, at 2:13 PM, Kevin Forchione > <mailto:lyss...@gmail.com>> wrote: >> >> Thanks! That’s just what I wanted. Is there a way in Racket to determine if >>

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-17 Thread Kevin Forchione
> On Sep 16, 2018, at 10:07 PM, Matthew Butterick wrote: > > #lang racket > (require rackunit) > > (define-syntax (bound-to-proc? stx) > (syntax-case stx () > [(_ 'x) > (and (identifier? #'x) (identifier-binding #'x)) > #'(procedure? x)] > [_ #'#f])) > > (define

Re: [racket-users] [Racket Users] Macros and literals question

2018-09-16 Thread Kevin Forchione
(check-eqv? (foo 10) 10) > (check-eq? (foo hello) 'hello) > (check-pred procedure? (foo (λ (x) (* 2 x > > -Philip > > > On Sat, Sep 15, 2018 at 9:17 PM Kevin Forchione <mailto:lyss...@gmail.com>> wrote: > Hi guys, > Is there a way to define a

[racket-users] [Racket Users] Macros and literals question

2018-09-15 Thread Kevin Forchione
Hi guys, Is there a way to define a macro so that an argument will be quoted only when it is a symbol? Something like this: (foo 10) => 10 (foo hello) => ‘hello (foo (lambda (x) (* 2 x))) => etc. Kevin -- You received this message because you are subscribed to the Google Groups "Racket

Re: [racket-users] Testing & global variables

2018-08-08 Thread Kevin Forchione
> On Aug 7, 2018, at 10:56 AM, Alexis King wrote: > > I guess I’ll take the bait and give the obvious-but-unhelpful answer, > “Don’t use global variables.” :) > > I’m joking, but only just barely. It seems difficult to give concrete > advice without knowing more details about your program

Re: [racket-users] Testing & global variables

2018-08-07 Thread Kevin Forchione
> On Aug 7, 2018, at 10:56 AM, Alexis King wrote: > > I guess I’ll take the bait and give the obvious-but-unhelpful answer, > “Don’t use global variables.” :) > > I’m joking, but only just barely. It seems difficult to give concrete > advice without knowing more details about your program

Re: [racket-users] Testing & global variables

2018-08-07 Thread Kevin Forchione
I’ve got a library that takes maintains global variables. I’d like to be able to test different test files that require this library, but of course if I require those files into a single test file for testing various combinations of data it corrupts the global variables, which are only valid

[racket-users] let-syntax example?

2018-04-03 Thread Kevin Forchione
Hi Guys, Does anyone have an analogous example for let-syntax to something as simple as this? (let ([a 3]) a) Something like…. (let-syntax ([a 3]) ….) At which point I’m stumped as to what expression in the body would return 3. There are no examples in the Reference.

Re: [racket-users] Struct general question

2018-03-26 Thread Kevin Forchione
> On Mar 26, 2018, at 11:03 AM, Eric Griffis wrote: > > The `struct` form is defined in `struct.rkt` [1]. As you can see, `struct` > wraps `define-struct/derived` [2], which uses many things exported from > `struct.c` [3]. The "Inside: Racket C API" doc [5] describes some

Re: [racket-users] Struct general question

2018-03-26 Thread Kevin Forchione
> On Mar 26, 2018, at 9:36 AM, Jens Axel Søgaard <jensa...@soegaard.net> wrote: > > 2018-03-26 17:58 GMT+02:00 Kevin Forchione <lyss...@gmail.com > <mailto:lyss...@gmail.com>>: > In another thread on structs it was confirmed that structs are in essence a

Re: [racket-users] struct-copy question

2018-03-20 Thread Kevin Forchione
Just read your GitHub link and see the problem goes beyond my simple #:auto issue. Thanks for that link. I’m pretty green to all the thorny issues when it comes to dressing primitive datatypes up in fancy bindings and hope the magicians of indirection can somehow pull a rabbit out of the hat

Re: [racket-users] struct-copy question

2018-03-20 Thread Kevin Forchione
On Mar 20, 2018, at 9:21 AM, Kevin Forchione <lyss...@gmail.com> wrote: > > Sorry, wrong example! >(struct fish (color (weight #:auto)) #:transparent) >(define marlin (fish 'orange-and-white)) >(define dory (struct-copy fish marlin [color 'blue])) ../../Applications/R

Re: [racket-users] struct-copy question

2018-03-20 Thread Kevin Forchione
On Mar 19, 2018, at 2:35 PM, Alexis King wrote: > > I’m late to this thread, but perhaps I can clarify some things that I > don’t think have been made entirely clear. > > First of all, you are absolutely correct that structures, at runtime, > know nothing whatsoever

Re: [racket-users] struct-copy question

2018-03-17 Thread Kevin Forchione
> On Mar 17, 2018, at 9:24 AM, Eric Griffis wrote: > > How about a list of identifiers bound to getters or setters? The > `extract-struct-info` procedure in Section 5.7 of the Racket Reference > appears to give you that. > > Eric Souned promising, but it sounds like you

Re: [racket-users] struct-copy question

2018-03-16 Thread Kevin Forchione
> On Mar 16, 2018, at 2:38 PM, Kevin Forchione <lyss...@gmail.com> wrote: > > Hi guys, > I’ve noticed that struct-copy doesn’t appear to work when fields are defined > with #:auto. So this leads to my question, which may not be answerable since > it would presumab

[racket-users] struct-copy question

2018-03-16 Thread Kevin Forchione
Hi guys, I’ve noticed that struct-copy doesn’t appear to work when fields are defined with #:auto. So this leads to my question, which may not be answerable since it would presumably be used to fix struct-copy, but is there a way to retrieve a list of struct fields for a struct? I have a

[racket-users] Struct initialization?

2018-03-09 Thread Kevin Forchione
Is it possible to initialize a struct field based on values from previously defined fields? Something equivalent to let* where >(struct foo (A B C)) >(foo 1 2) would produce (foo 1 2 3) for example? Thanks! Kevin -- You received this message because you are subscribed to the

[racket-users] struct question

2018-03-07 Thread Kevin Forchione
Hi guys, Can we associate more than 1 generic with a struct? Something like: (struct foo (..) #:methods gen:bar [] gen:baz [] …) 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

[racket-users] Datalog Question

2018-01-31 Thread Kevin Forchione
Can anyone tell me how I would use the datalog = and != tokens? The documentation says they can separate terms, such as != . In the program below, how would I create a query for foo(x, ?) where ? is not 3? #lang datalog foo(bil, 1). foo(bob, 3). foo(joe, 2). I imagine I’d have to create a

[racket-users] Apparent Datalog error?

2018-01-31 Thread Kevin Forchione
Walking through the datalog tutorial I got the following transcript: Welcome to DrRacket, version 6.12 [3m]. Language: datalog, with debugging; memory limit: 512 MB. > parent(john, douglas). > parent(john, douglas)? parent(john, douglas). > parent(john, evlyn)? > parent(bob, john). > parent(A,

Re: [racket-users] Macro calling macro question

2016-05-20 Thread Kevin Forchione
id. > Hopefully this explanation made some sense. > > - Sam > > On Fri, May 20, 2016 at 5:36 PM, Kevin Forchione <lyss...@gmail.com > <mailto:lyss...@gmail.com>> wrote: > Hi guys, > I’ve been interested in having a macro build a series of defines. So

[racket-users] Macro calling macro question

2016-05-20 Thread Kevin Forchione
Hi guys, I’ve been interested in having a macro build a series of defines. So I decided to start small, trying to get to a macro that would do something like the following to begin with: >(foo 3) (define foo1 1) (define foo2 2) (define foo3 3) I start with a macro that appears to do a single

[racket-users] Racket gui choice% enabled #f question

2016-05-18 Thread Kevin Forchione
Hi guys, What does “enable” do for choice%? I’ve noticed that other wedges prevent interaction when enabled #f, but not choice%. Here’s an example: #lang racket (require racket/gui) (define frame (new frame% [label "Testing"] [x 0] [y

[racket-users] format-id question

2016-05-09 Thread Kevin Forchione
Hi guys, I’ve been working with Racket 6.5 refreshing my macro knowledge and ran into a situation with format-id that baffles me. There’s an example of format-id on the “Fear of Macros” webpage that puzzles me. >(require (for-syntax racket/syntax)) >(define-syntax (hyphen-define/ok3 stx)

[racket-users] Making a text editor

2016-01-31 Thread Kevin Forchione
Hi guys, I’ve been perusing the documentation on Racket GUI and am interested in making a text editor. Is there any source code to model from? The documentation got me started, but there are features such as indenting, line numbering and keybindings that I’m interested in implementing. I’ve