Re: [racket-users] Speeding up the conversion of flvectors to string

2021-06-29 Thread Jonathan Simpson
race unless we add what has > been deemed (quite reasonably, IMO) unacceptable overhead). > > hth,Robby > > > On Tue, Jun 29, 2021 at 11:11 AM Sam Tobin-Hochstadt > wrote: > >> On Tue, Jun 29, 2021 at 12:04 PM Jonathan Simpson >> wrote: >> > >>

Re: [racket-users] Speeding up the conversion of flvectors to string

2021-06-29 Thread Jonathan Simpson
On Monday, June 28, 2021 at 10:25:36 PM UTC-4 Sam Tobin-Hochstadt wrote: > On Mon, Jun 28, 2021 at 9:46 PM Jonathan Simpson wrote: > > > > On Sunday, June 27, 2021 at 10:29:55 AM UTC-4 Robby Findler wrote: > >> > >> Replacing ` (~r x #:precision 1)` with `(nu

Re: [racket-users] Speeding up the conversion of flvectors to string

2021-06-28 Thread Jonathan Simpson
On Sunday, June 27, 2021 at 10:29:55 AM UTC-4 Robby Findler wrote: > Replacing ` (~r x #:precision 1)` with `(number->string x)` and ditto for > `y` eliminates the overhead of contracts and brings about another 4x > speedup on my machine. > This is because the compiler is able to remove the con

Re: [racket-users] Retro 3D maze with Pict?

2020-04-19 Thread Jonathan Simpson
On Sunday, April 19, 2020 at 6:39:53 AM UTC-4, Dominik Pantůček wrote: > > > Funnily enough, I am working on a graphics side project right now and I > have a working 3D rendering pipeline completely in Racket which works > surprisingly fast even on 2560x1440. I plan to publish a series of > ar

Re: [racket-users] How to compile static racket binaries

2020-04-02 Thread Jonathan Simpson
On Thursday, April 2, 2020 at 10:24:58 AM UTC-4, Matthew Flatt wrote: > > > I'm not sure how well statically linking to the C library will work. I > get several linker warnings like this one: > > warning: Using 'getgrgid' in statically linked applications requires > at runtime the shared libr

[racket-users] Macro Stepper hang

2019-12-28 Thread Jonathan Simpson
The following program causes the Macro Stepper in Dr Racket to hang(it never opens): #lang magic 2 ubyte <34 Targa image data The code executes correctly as far as I can tell, but Macro Stepper doesn't like it. Changing "ubyte" to "byte" fixes the Macro Stepper problem. This problem has pers

Re: [racket-users] Reason why char=? accepts only one argument?

2019-11-25 Thread Jonathan Simpson
On Monday, November 25, 2019 at 6:44:49 AM UTC-5, Matthew Flatt wrote: > > > > In the documentation, "..." means "zero or more". So, > > (char=? char1 char2 ...) > > means that `char=?` takes at least one argument. > > Before version 7, the "..." in this place in documentation was a > "...+",

[racket-users] Reason why char=? accepts only one argument?

2019-11-24 Thread Jonathan Simpson
The documentation for char=? leaves the impression that it takes a minimum of two arguments: https://docs.racket-lang.org/reference/characters.html?q=expand#%28def._%28%28quote._~23~25kernel%29._char~3d~3f%29%29 If a single character is passed as argument 1, char=? returns true. To me, '='

Re: [racket-users] Syntax pattern to match a sequence with x identical elements?

2019-11-10 Thread Jonathan Simpson
that error is a bug in syntax/parse. I have reported it here: >> >> https://github.com/racket/racket/issues/2856 >> >> On Oct 12, 2019, at 21:45, Jonathan Simpson wrote: >> >> I'm not sure exactly why my syntax class wasn't working, but it is >> wor

Re: [racket-users] Using the top level to fix unbound identifier

2019-11-10 Thread Jonathan Simpson
UTC-4, Jonathan Simpson wrote: > > Thanks very much for this! I hadn't considered the effect that stripping > the syntax information from the input to query would have. It has always > been a goal of mine to go back and rewrite all the macros -- and especially > the ugly st

Re: [racket-users] Syntax pattern to match a sequence with x identical elements?

2019-10-13 Thread Jonathan Simpson
t here: > > https://github.com/racket/racket/issues/2856 > > On Oct 12, 2019, at 21:45, Jonathan Simpson > wrote: > > I'm not sure exactly why my syntax class wasn't working, but it is working > now. I had an extra set of parentheses around the ~between pattern, so it &

Re: [racket-users] Syntax pattern to match a sequence with x identical elements?

2019-10-12 Thread Jonathan Simpson
> > (require syntax/parse) > > (define-syntax-class mag-lvl > (pattern ({~datum level}))) > > (syntax-parse #'((level) (level) (level)) > [((~between lvls:mag-lvl 3 3) ...) >(attribute lvls)]) > > So I’m not sure what problem you’re bumping into, an

Re: [racket-users] Syntax pattern to match a sequence with x identical elements?

2019-10-12 Thread Jonathan Simpson
standing of the differences between using head patterns and single term patterns. -- Jonathan On Friday, October 11, 2019 at 10:55:19 PM UTC-4, Jonathan Simpson wrote: > > Thank you Alexis for the clear explanation. I now understand how to use > ~between and it is working for me. > > On

Re: [racket-users] Syntax pattern to match a sequence with x identical elements?

2019-10-11 Thread Jonathan Simpson
sort of implicitly expanded to ((~optional x:integer) ...), and the > same could be done for ~between. However, my guess is that it isn’t allowed > because ~between increments the ellipsis depth of its sub-pattern, and Ryan > thought it would be confusing for a pattern variable’s elli

[racket-users] Syntax pattern to match a sequence with x identical elements?

2019-10-10 Thread Jonathan Simpson
This seems like it should be simple but I've never been able to figure out how to do this. What I've been doing instead is this: (x:integer ...+) to match two or more integers. (x:integer y:integer ...+) to match three or more. And so on. I'm at a point now where I need to build patterns dynam

Re: [racket-users] Re: Macro behaves differently when run from different modules

2019-09-30 Thread Jonathan Simpson
ander-utils.rkt > is unbound, but the usage identifier in expander.rkt is bound by the `line` > definition, so they aren't free-identifier=?. > > On Sunday, September 29, 2019 at 9:21:13 PM UTC-4, Jonathan Simpson wrote: >> >> In expander-utils.rkt the macros work

Re: [racket-users] Re: Macro behaves differently when run from different modules

2019-09-29 Thread Jonathan Simpson
just don't understand why line also matches as a literal in expander-utils.rkt. Thanks for your help. -- Jonathan On Saturday, September 28, 2019 at 10:51:01 PM UTC-4, Ben Greenman wrote: > > On 9/28/19, Jonathan Simpson > wrote: > > It works when I change my

[racket-users] Re: Macro behaves differently when run from different modules

2019-09-28 Thread Jonathan Simpson
e was defined or not. So there must be something in the compilation environment that I'm missing. I'm still curious if anyone has a good explanation. I may hit issues with level further down the road as well. -- Jonathan On Saturday, September 28, 2019 at 6:30:54 PM UTC-4, Jonatha

[racket-users] Macro behaves differently when run from different modules

2019-09-28 Thread Jonathan Simpson
I've recently been rewriting some ugly code to make it fully hygienic with syntax-parse. I have an implementation that appears to work when testing it from the module that contains the macros, but it fails when I run it from my main program/another module. The macro in question is parse-level0,

Re: [racket-users] syntax-parse ellipsis question

2019-09-21 Thread Jonathan Simpson
>#'((~@ n ... x) ...)]) > > -Philip > > > On Sat, Sep 21, 2019 at 4:15 PM Jonathan Simpson > wrote: > >> Given this macro that I'm experimenting with: >> >> (syntax-parse #'(1 2 2 a 2 2 b 2 c) [(1 (~seq n:nat ...+ x) ...) #'((n >> ...

[racket-users] syntax-parse ellipsis question

2019-09-21 Thread Jonathan Simpson
Given this macro that I'm experimenting with: (syntax-parse #'(1 2 2 a 2 2 b 2 c) [(1 (~seq n:nat ...+ x) ...) #'((n ... x) ...)]) How would I change it so that it returns #'(2 2 a 2 2 b 2 c) instead of #'((2 2 a) (2 2 b) (2 c)) ? I don't want the parens around the individual sequences that I'

Re: [racket-users] Using the top level to fix unbound identifier

2019-08-18 Thread Jonathan Simpson
e tga-image) (line 1)) >(named-query (name test-scope) (line (use-name tga-image))) >(query (use-name test-scope > > [image: Screen Shot 2019-08-18 at 15.18.35.png] > > For your code, the next thing I would suggest looking into is to avoid > using syntax->datum

Re: [racket-users] Using the top level to fix unbound identifier

2019-08-14 Thread Jonathan Simpson
I will take a look at this as well. It may be a few days before I have time to devote to this again, but I appreciate everyone's help so far. -- Jonathan On Wednesday, August 14, 2019 at 1:00:54 AM UTC-4, Matthew Butterick wrote: > > > On 13 Aug 19, at 7:03 PM, Jonathan Simpson &

Re: [racket-users] Using the top level to fix unbound identifier

2019-08-13 Thread Jonathan Simpson
t is needed? Best, > Tom > > PS I've encountered similar issues a number of times and haven't taken the > time to figure out the right way to deal with it, so your issue is a nice > clear cut example. > > On Tue, Aug 13, 2019 at 7:45 PM Jonathan Simpson > wrote:

Re: [racket-users] Using the top level to fix unbound identifier

2019-08-13 Thread Jonathan Simpson
On Tuesday, August 13, 2019 at 10:41:33 PM UTC-4, Jonathan Simpson wrote: > > I changed the lines in named-query from > > [name (datum->syntax stx (string->symbol (syntax->datum #'magic-name))) > to > (format-id stx "~a" (syntax-e #'magic-name)) &

Re: [racket-users] Using the top level to fix unbound identifier

2019-08-13 Thread Jonathan Simpson
> https://docs.racket-lang.org/reference/syntax-util.html#%28def._%28%28lib._racket%2Fsyntax..rkt%29._format-id%29%29? > > If you just pass string->symbol and then use datum->syntax you will get > binding errors. > Tom > > On Tue, Aug 13, 2019 at 7:03 PM Jonathan S

[racket-users] Using the top level to fix unbound identifier

2019-08-13 Thread Jonathan Simpson
I have a bug I'm trying to fix in #lang magic( https://github.com/jjsimpso/magic). I'm pretty sure I know what the cause is and I know what I want to do, but I don't know how to do it. The situation is this: In the following magic code, a new function(called a named query in magic) tga-image is

Re: [racket-users] [ANN] Racket implementation of magic language

2019-08-01 Thread Jonathan Simpson
ancements that don't break compatibility. I'll also do some more work to improve the github README as you suggested. Thanks for your input! -- Jonathan On Thursday, August 1, 2019 at 1:07:36 AM UTC-4, Neil Van Dyke wrote: > > Jonathan Simpson wrote on 7/31/19 9:54 PM: > > #l

[racket-users] Re: [ANN] Racket implementation of magic language

2019-07-31 Thread Jonathan Simpson
And most importantly, here is the github :) https://github.com/jjsimpso/magic -- 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...@googlegro

[racket-users] [ANN] Racket implementation of magic language

2019-07-31 Thread Jonathan Simpson
#lang magic is my implementation of the mini language used by the Unix file command. I'm aiming for compatibility with Ian Darwin's version , found in most Linux and BSD distributions. #lang magic is a work in progress. It is missing a lot of functionality but s

Re: [racket-users] Trouble writing unhygienic macro

2019-05-28 Thread Jonathan Simpson
ay 28, 2019, at 7:11 AM, Jonathan Simpson > wrote: > > Both the function definition and function calls are created by similar > looking macros which pass strings as the function name. I've now taken > steps to break hygiene in the defining macro, but the calling macro just &g

Re: [racket-users] Trouble writing unhygienic macro

2019-05-28 Thread Jonathan Simpson
On Tuesday, May 28, 2019 at 1:45:35 AM UTC-4, Alexis King wrote: > > > On May 27, 2019, at 22:28, Jonathan Simpson > wrote: > > > > I may be missing something, but I didn't think I could use the name as > valid syntax since this is the form that is creating it.

Re: [racket-users] Trouble writing unhygienic macro

2019-05-28 Thread Jonathan Simpson
Sorry. It is probably better to ignore the part about the second syntax-case clause for now. I didn't provide the necessary background to make sense of it. Once I get past my current problem it probably won't be relevant anyway. I'm currently hitting the unbound identifier error in both clauses

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Jonathan Simpson
In case this helps, here is the output from the macro stepper for a sample macro invocation: (named-query (name-line (offset 0) (name-type "name") "always-true") (level) (line (offset 0) (type (default "default")) (test (truetest "x" -> (define:24 always-true

Re: [racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Jonathan Simpson
Thanks for the quick response. I wouldn't have gotten as far as I have so far without your 'Fear of Macros' page, so thanks for that as well! On Monday, May 27, 2019 at 10:54:50 PM UTC-4, Greg Hendershott wrote: > > If users of your `named-query` macro will supply the name as an > identifier --

[racket-users] Trouble writing unhygienic macro

2019-05-27 Thread Jonathan Simpson
Hi all, I'm writing a macro which needs to break hygiene to introduce a function definition. Here is my current hygienic -- and useless -- version: (define-syntax (named-query stx) (syntax-case stx (name-line) [(_ (name-line (_ 0) (_ "name") magic-name)) (with-syntax ([name (string->s

Re: [racket-users] Problem controlling macro expansion

2019-01-27 Thread Jonathan Simpson
gt; > > On Jan 27, 2019, at 5:15 PM, Jonathan Simpson > wrote: > > The code contained within lines-to-syntax-tree will run tests on an input > stream. My original plan was to have a function like run-query that would > execute the tests. So I'd need to quote the test

Re: [racket-users] Problem controlling macro expansion

2019-01-27 Thread Jonathan Simpson
19 kl. 22.06 skrev Jonathan Simpson >: > >> I'm having macro troubles with a DSL I'm writing. I have a macro that >> looks something like this: >> >> (define-syntax (query stx) >> (let ([lines (cdr (syntax->datum stx))]) >> (define lines

Re: [racket-users] Problem controlling macro expansion

2019-01-27 Thread Jonathan Simpson
> lines-to-syntax-tree? > > > On Jan 27, 2019, at 4:06 PM, Jonathan Simpson > wrote: > > I'm having macro troubles with a DSL I'm writing. I have a macro that > looks something like this: > > (define-syntax (query stx) > (let ([lines (cdr (syntax->d

[racket-users] Problem controlling macro expansion

2019-01-27 Thread Jonathan Simpson
I'm having macro troubles with a DSL I'm writing. I have a macro that looks something like this: (define-syntax (query stx) (let ([lines (cdr (syntax->datum stx))]) (define lines-syntax-tree (parse-to-tree lines)) (datum->syntax stx lines-syntax-tree))) So something like (query ...li

[racket-users] Re: Output values

2019-01-20 Thread Jonathan Simpson
Are you looking for the values function? https://docs.racket-lang.org/reference/values.html?q=values#%28def._%28%28quote._~23~25kernel%29._values%29%29 In your example you'd end EnumTriplet with this: (values x y z) -- Jonathan On Friday, January 18, 2019 at 8:49:30 AM UTC-5, Alain Bertrand

Re: [racket-users] Help debugging a custom language read/expansion error

2018-12-30 Thread Jonathan Simpson
On Sunday, December 30, 2018 at 8:51:25 PM UTC-5, Matthew Butterick wrote: > > Without seeing "reader.rkt" or "expander.rkt" — I'd guess that: > > 1) `read-syntax` isn't stripping all bindings from its parse tree before > returning it. Though this isn't mandatory, it's a wise practice to avoid

Re: [racket-users] Help debugging a custom language read/expansion error

2018-12-30 Thread Jonathan Simpson
or your help. -- Jonathan On Sunday, December 30, 2018 at 5:14:38 PM UTC-5, Jens Axel Søgaard wrote: > > Den søn. 30. dec. 2018 kl. 22.33 skrev Jonathan Simpson >: > >> On Sunday, December 30, 2018 at 3:58:50 PM UTC-5, Jens Axel Søgaard wrote: >> >>> The error &g

Re: [racket-users] Help debugging a custom language read/expansion error

2018-12-30 Thread Jonathan Simpson
] [(line (offset off) (type type-expr) (test test-expr) (message msg)) (magic-test (offset off) (type (quote type-expr) (quote test-expr)) (compare (quote test-expr)) msg)])) This is defined in my expander, and it seems to work from the REPL with expander.rkt loaded. -- Jonathan >

[racket-users] Help debugging a custom language read/expansion error

2018-12-30 Thread Jonathan Simpson
I'm bumbling through my first attempts at creating a language in Racket and am currently stuck debugging an error in expansion. I have a macro in my expander that works fine until I try to run the language. Here's what the macro stepper in DrRacket gives me: [Error] line: bad syntax (line (o

Re: [racket-users] with-input-from-file question

2018-12-16 Thread Jonathan Simpson
Ah, thanks! On Sunday, December 16, 2018 at 3:53:06 PM UTC-5, Jon Zeppieri wrote: > > > On Sun, Dec 16, 2018 at 2:59 PM Jonathan Simpson > wrote: > >> What is the difference between this code, which reads and returns "#lang" >> from the file: >> (def

[racket-users] with-input-from-file question

2018-12-16 Thread Jonathan Simpson
What is the difference between this code, which reads and returns "#lang" from the file: (define in-file (open-input-file "adventure.rkt")) (parameterize ([current-input-port in-file]) (read-string 5)) and this code which appears to still read from stdin: (with-input-from-file "adventure.rkt" (r

Re: [racket-users] Memory usage on Linux

2018-08-26 Thread Jonathan Simpson
26, 2018 at 9:02:47 PM UTC-4, gneuner2 wrote: > > > > On 8/26/2018 6:43 PM, Jonathan Simpson wrote: > > The fact that Racket isn't releasing the memory back to the OS appears > > to be causing the system to eventually run out of physical pages. > > Is this a clo

Re: [racket-users] Memory usage on Linux

2018-08-26 Thread Jonathan Simpson
On Sunday, August 26, 2018 at 7:43:20 PM UTC-4, Matthew Flatt wrote: > > > Racket's memory manager does not immediately release pages back to the > OS (i.e., unmap them) after a GC. In its current configuration, the GC > releases a page at the beginning of a major GC only if the page was > unu

Re: [racket-users] Memory usage on Linux

2018-08-26 Thread Jonathan Simpson
han On Sunday, August 26, 2018 at 5:52:59 PM UTC-4, gneuner2 wrote: > > > > On 8/26/2018 12:55 PM, Jonathan Simpson wrote: > > I have a Racket application that I need to run in a fairly memory > constrained environment(1 GB ram) and I've ran into something I don'

[racket-users] Memory usage on Linux

2018-08-26 Thread Jonathan Simpson
HI, I have a Racket application that I need to run in a fairly memory constrained environment(1 GB ram) and I've ran into something I don't quite understand. The application is deserializing a fairly large data structure from disk on startup. After loading, current-memory-use

Re: [racket-users] Weird problem with bytes-utf-8-length

2017-12-08 Thread Jonathan Simpson
ytes-utf-8-length) > > > At Fri, 8 Dec 2017 15:58:32 -0800 (PST), Jonathan Simpson wrote: > > Welcome to DrRacket, version 6.11 [3m]. > > Language: racket, with debugging; memory limit: 128 MB. > > > (if (bytes-utf-8-length (bytes 255)) 1 2) > > 1 > >

[racket-users] Weird problem with bytes-utf-8-length

2017-12-08 Thread Jonathan Simpson
Welcome to DrRacket, version 6.11 [3m]. Language: racket, with debugging; memory limit: 128 MB. > (if (bytes-utf-8-length (bytes 255)) 1 2) 1 > (bytes-utf-8-length (bytes 255)) #f > (not (bytes-utf-8-length (bytes 255))) #f Can anyone explain this to me? Surely the output of the last line should b