[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

[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

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

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

[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] 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

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

[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

[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

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

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

[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] [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] 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] 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 >

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

[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] 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 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 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] 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 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] 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] 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] 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] 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] 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] 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

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

[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] 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] 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] 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

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

[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-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)) >

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] [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] [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 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

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

[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] [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))

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

[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