[racket-users] Error location in test submodules

2019-04-02 Thread zeRusski
I am a big fan of having tests alongside code so (module+ test ...) is magic. The only annoyance I've been running into lately is error reporting. If I have many test chunks spread around my code and some code change throws an exception or a contract violation it is impossible to tell which

Re: [racket-users] Error location in test submodules

2019-04-03 Thread zeRusski
> #lang racket/base > (define f (λ _ (error 'FAIL))) > (module+ test > (require rackunit) > (define OK (string->unreadable-symbol "OK")) > (define-syntax-rule (check-OK-form expr) > (let ([val expr]) > (with-check-info (['input 'expr] ['expected OK] ['actual val]) >

[racket-users] Does Racket have a sexp-syntax regular expressions?

2019-03-27 Thread zeRusski
I swear someone told me there was a Racket lib equivalent of Emacs Lisp rx or Shivers's trx regular expressions, yet I failed to find one. Any pointers? Thanks -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group

Re: [racket-users] Does Racket have a sexp-syntax regular expressions?

2019-03-27 Thread zeRusski
r 27, 2019 at 8:45 AM zeRusski > wrote: > >> No wait. I meant SRE-like to match strings, not TRX to match trees. >> Messed up there, sorry >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Racket Users" group.

Re: [racket-users] Error location in test submodules

2019-04-04 Thread zeRusski
> If you want your tests to catch exceptions you need to wrap them in > exception handlers, which you could write a macro to do for you; as Eric > noted though you need to be careful to preserve source locations. > This gave me an idea, so I've been reading *rackunit* docs finally. I'm about

[racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-04 Thread zeRusski
While reading *rackunit* source I stumbled on a pattern that I can't figure out. Why the heck does it work? Condensed to its essence it amounts to introducing indirection with a macro-generated define: #lang racket > (require (for-syntax syntax/parse) > syntax/parse/define) >

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread zeRusski
> If I understand correctly, the fourth paragraph here is relevant? > > > https://docs.racket-lang.org/reference/syntax-model.html#%28part._transformer-model%29 > > > I dreaded someone pointing me there. I read it a year ago, took a lot of head scratching and careful reading before I

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-05 Thread zeRusski
A simple model to keep in your head: > Each macro keeps a count, i, of how many times it has been applied. > Each time a the output of a macro contains a definition of name not > present in the input it appends _i to the name. > Ha, I get it. That's a good little heuristic. I'm keeping

[racket-users] How to install local dir package replacing pre-installed one

2019-04-05 Thread zeRusski
I thought about hacking on /rackunit/ a bit and if it pans out maybe send my changes upstream. Typically I would clone a repo and then do raco pkg install in its folder so that I have it linked and code that may require it picks up latest changes. Very convenient workflow. Except /rackunit/ is

[racket-users] Re: How to install local dir package replacing pre-installed one

2019-04-05 Thread zeRusski
If I'm reading docs right, then it should've worked, hm: Conflict checking disallows installation of the same or conflicting package > in different scopes, but if such a configuration is forced, collections are > found first in packages with user package scope >

Re: [racket-users] Pattern: reusing the same name in macro-generated definitions

2019-04-04 Thread zeRusski
I know in principle but on occasion I fail to understand the implications. Let me think aloud. I don't have to be perfectly accurate, maybe just about right. Hygiene here means that every symbol there e.g. arguments my macro receives carry their "environment" with them. There exists some

Re: [racket-users] Re: How to install local dir package replacing pre-installed one

2019-04-06 Thread zeRusski
Alright, I managed to install from local clone. Thank you Philip! Some observations here. You were right, I should've cloned from my fork. Else `raco pkg update` keeps pulling from the original (Racket central) URL. Docs tell us we can supply alternative URL, and it works but sadly not for

[racket-users] Re: Error location in test submodules

2019-04-07 Thread zeRusski
Alright, tried to fix it as I see fit. Naturally, my understanding of rackunit source doesn't go far, but here's the PR: https://github.com/racket/rackunit/pull/107 Just keeping it real with Racket, I guess. -- You received this message because you are subscribed to the Google Groups "Racket

[racket-users] Generics: delegate to a parent

2019-03-20 Thread zeRusski
Hi all. I am trying to make good use of Generic Interfaces, but can't figure out if its at all possible to delegate calls up the struct inheritance chain. So, something like `call-next`, or even better maybe there's a way to do explicit dispatch? So something like having two structs: (struct

Re: [racket-users] Generics: delegate to a parent

2019-03-22 Thread zeRusski
> > object system (which also cooperates with generics) TBH I've been avoiding Racket object system since my needs are typically limited and don't call for full blown OOP. I only casually looked at what its capable of, I guess may need to revisit. I was rather hoping for something as simple

[racket-users] Thread safe operations and shared memory

2019-03-22 Thread zeRusski
Racket documentation doesn't tell much on the subject. The only two things I've found are *box-cas! *and this passage from Evaluation Model that to me remains a bit cryptic. Threads are created explicitly by functions such as thread > . > > In terms of the evaluation model, each step in

Re: [racket-users] Thread safe operations and shared memory

2019-03-22 Thread zeRusski
Thank you George for thorough explanation. (set!) of a box, an mcons, or a *struct field* is atomic WRT threads So, the `foo-struct-set!` would be atomic, but (hash-set! (foo-struct-field-with-table foo) key value) would not (assuming a mutable hash-table value there), correct? -- You

Re: [racket-users] Re: How to install local dir package replacing pre-installed one

2019-04-06 Thread zeRusski
My celebration was a bit premature. Strangely jumping to definition now worked and sent me to the right location but no code changes were picked up. I read the docs some more and noticed that raco pgk show showed actual checksum for /rackunit/ packages instead of #f and the source said /clone/

[racket-users] Is there a way to find where some feature is implemented in racket?

2019-04-16 Thread zeRusski
I suspect I'm not the first to ask, but my search-fu has failed me here. Apologies if the question has already been answered on that list. When I read Racket docs I sometimes wonder how a particular feature is implemented. Looking at the source sometimes shed light or simply teaches you

[racket-users] Mutating hash-map while iterating

2019-06-03 Thread zeRusski
Is it ok to mutate a hash while iterating over it say in one of ~for~ forms? Specifically I want to filter (that is drop) some keys, but I'm also interested in mutation in general. I guess the answer lies in whether forms like ~in-dict~ etc create lazy streams that hold on to the table?

[racket-users] Re: New Package: Dynamic FFI - Write C Code Inline

2019-06-03 Thread zeRusski
Oh wow! IIUC it is super awesome. Would a natural next step be #lang terra ? Hey Jay McCarthy would you like to mentor that effort ;-) On Saturday, 1 June 2019 20:06:29 UTC+1, David Benoit wrote: > > Hi All, > > I've recently released a new library >

Re: [racket-users] Mutating hash-map while iterating

2019-06-04 Thread zeRusski
Thank you Ben. That answers my question. About what I expected - be defensive when in doubt. On Monday, 3 June 2019 19:07:44 UTC+1, Ben Greenman wrote: > > You want the paragraph just above the caveat about concurrent > modification: > > > A hash table can be used as a two-valued sequence (see

[racket-users] Re: [ann] marionette: control Firefox from Racket

2019-06-11 Thread zeRusski
Brilliant! Thank you for this -- 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...@googlegroups.com. To view this discussion on the web

[racket-users] Re: grammar-based fuzzing

2019-06-11 Thread zeRusski
cool wasn't aware of Xsmith! Surprised to find RACR backing it - I looked at its source a while back for some attribute grammar magic - ended up not doing anything though - was it lack of docs - can't recall. IIRC it has some true scheme magic in there. Academics often suck at marketing ;) For

[racket-users] First class compound datatypes that can Racket

2019-05-22 Thread zeRusski
This would probably sound like rambling but that's only because I am struggling a little bit. I implemented a little language that offers its own compound data type: first class and users can extend it in various ways. Naturally, it is implemented as a Racket struct. As I started using the

Re: [racket-users] First class compound datatypes that can Racket

2019-05-22 Thread zeRusski
> > p.s. While you "have the hood open", you might also want to do something > similar for `prop:procedure`? > I would agree that it is A solution to this particular problem with this particular prop. The "passthrough" of some form or other works well and is always open to me as the language

[racket-users] Re: Racket Mode documentation

2019-05-24 Thread zeRusski
this is pretty cool Greg! I, too, had a brief excursion into documenting with Org. It still needs work, but here is an org-source that can be executed to generate the REAME.org

[racket-users] Re: Racket Mode documentation

2019-05-24 Thread zeRusski
this is pretty cool Greg! I, too, had a brief excursion into documenting with Org. It still needs work, but here is an org-source that can be executed to generate the REAME.org

Re: [racket-users] Re: tilda - a threading macro full of itself

2019-05-12 Thread zeRusski
> For example, it's better if a threading macro expands using the `#%app` > bound at the macro use site. (Whereas by default, macros expand using > identifiers bound where the macro is defined.) > > https://github.com/lexi-lambda/threading/issues/3 > > Got this one right in the ~> macro,

[racket-users] Re: how do you read, manipulate, debug scope sets?

2019-05-12 Thread zeRusski
> > #+begin_src racket > ;; inside syntax-parse > (datum->syntax this-syntax '<~) > #+end_src > > Notice that the second argument to datum->syntax should be a symbol here, > rather than a syntax object. If you provide a syntax object as you did in > your original code, datum->syntax simply

Re: [racket-users] how do you read, manipulate, debug scope sets?

2019-05-07 Thread zeRusski
Thanks Matthew I'll have a look > > All: I published a link to the code I had in mind in a separate thread , so if interested check it out. I don't want to pollute this one if someone takes on the challenge of answering in more

[racket-users] tilda - a threading macro full of itself

2019-05-07 Thread zeRusski
I asked in a separate thread how one debugs set of scopes in Racket macros. I appreciate the question may read a bit hand-wavy and abstract, so I split out the piece of code I had in mind into a separate package so that

Re: [racket-users] tilda - a threading macro full of itself

2019-05-07 Thread zeRusski
> > It just names the threaded value. Did I overlook anything? That's right, nothing fancy. Think let-binding the threaded value at that point. #:with id ~ would achieve the same thing, so as it is now #:as is redundant. With #:do both #:with and #:as are redundant, really. > Let me point

Re: [racket-users] tilda - a threading macro full of itself

2019-05-07 Thread zeRusski
> > It just names the threaded value. Did I overlook anything? That's right, nothing fancy. Think let-binding the threaded value at that point. #:with id ~ would achieve the same thing, so as it is now #:as is redundant. With #:do both #:with and #:as are redundant, really. > Let me point

Re: [racket-users] Inline tests for library and corresponding lang result in a loading cycle

2019-04-19 Thread zeRusski
> > PS the `lang/reader.rkt` fandango is no longer necessary in modern Racket; > if you like, you can use a `reader` submodule in your primary language file. > Made me curious. Maybe I'm dense, but do you suggest that I delete foo/bar/lang and add this to foo/bar/main.rkt (module reader

[racket-users] catch and bind an unbound id in a macro

2019-04-19 Thread zeRusski
Here's what I've been trying and failing to do in Racket. The smallest example I could think of is a macro that sets a key in a hash-table, so basically this transformation: (set/define ht 'key 42) ;; => (hash-set! ht 'key 42) but if ht there is an unbound identifier it must bind it to a

[racket-users] Inline tests for library and corresponding lang result in a loading cycle

2019-04-19 Thread zeRusski
I wrote a library foo/bar.rkt and I also allow to use it as a #lang. Roughly the structure is like this: foo ├── bar │ ├── lang │ │ └── reader.rkt │ └── main.rkt ├── bar.rkt Most of the work happens in the library foo/bar.rkt, so naturally all of the tests reside there. I'd like to be

Re: [racket-users] catch and bind an unbound id in a macro

2019-04-19 Thread zeRusski
Matthias, FWIW your first solution gave me a flashback from last year's Summer School. I remember using this trick. Now I hope I don't forget when I actually need it. Thank you Michael and Matthias -- You received this message because you are subscribed to the Google Groups "Racket Users"

Re: [racket-users] catch and bind an unbound id in a macro

2019-04-19 Thread zeRusski
Luke, thanks. You were the first to get there and somehow I missed your reply :( On Friday, 19 April 2019 22:31:41 UTC+1, luke.whittlesey wrote: > > `identifier-binding` might be useful if a binding can be defined outside > of set/define > > >

Re: [racket-users] catch and bind an unbound id in a macro

2019-04-19 Thread zeRusski
Not quite what I had in mind. The following examples must all work without errors: #lang racket ;; set/define defined here (set/define h a 1) (set/define h a 2) (hash-set! h 'b 42) (define bar (make-hash)) (set/define bar a 1) (define (foo) (set/define local-h a 1) (set/define local-h a

Re: [racket-users] catch and bind an unbound id in a macro

2019-04-19 Thread zeRusski
On Friday, 19 April 2019 22:39:10 UTC+1, Michael Murdock MacLeod wrote: > > I'm in no ways a macro expert, but will this work? It uses > identifier-binding > to check if the identifier for the hash table is bound. > Yep, looks like the winner. I should've inferred from the fact that "unbound

Re: [racket-users] Inline tests for library and corresponding lang result in a loading cycle

2019-04-20 Thread zeRusski
> If you want to invoke the language as `#lang foo/bar` then you would put > this `reader` submodule in "foo/bar.rkt". This would make > "foo/bar/lang/reader.rkt" obsolete. > Duh. I think I understand how this resolves now and I have a flat structure, which I think works nicely: foo*/:* -

[racket-users] how do you read, manipulate, debug scope sets?

2019-05-06 Thread zeRusski
I wrote a macro which introduced an implicit binding <~ so that it could be used in expressions at the use-site. Initially did it with #+begin_src racket ;; inside syntax-parse (datum->syntax this-syntax #'<~) #+end_src followed by macro introduced expr that binds it, then the use-site

[racket-users] Re: Impromptu racket meetup in London Friday, 19 July at 12pm-3pm

2019-07-12 Thread zeRusski
argh, wish you'd go with after work hours or the weekend. Sorry, won't be able to make it. On Friday, 12 July 2019 09:20:58 UTC-6, Stephen De Gabrielle wrote: > > Hi, > > Next Friday, 19 July at 12pm-3pm there will be an impromptu Racket meetup > at the cafe at the British Library 'The Last

[racket-users] Being a good macro citizen: patterns to follow for good error reporting

2019-04-21 Thread zeRusski
I just had an epiphany, or rather a very painful revelation, that if your macro does not report errors in terms of user code, say, when inputs are wrong, you ought to be ostracized by the community if not banished from any social interactions altogether. You don't deserve the good life.

Re: [racket-users] Re: catch and bind an unbound id in a macro

2019-04-21 Thread zeRusski
On Saturday, 20 April 2019 23:55:50 UTC+1, Stephen Chang wrote: > > fwiw, I think here is a working version along the lines of your > original attempt. > I see what you did there. This is both icky (as requested) and cute :0 Thanks, it's actually illuminating -- You received this message

[racket-users] Re: How would you implement autoquoted atoms?

2019-04-23 Thread zeRusski
One thought that only just occurred to me is that we certainly want to allow creating kws dynamically, so a piece of code may generate some. IIUC this means it can no longer be a purely reader-based feature. Either reader and runtime have to communicate the global table somehow or the entire

[racket-users] How would you implement autoquoted atoms?

2019-04-23 Thread zeRusski
I must apologies for what follows will be more of a rambling than an exercise in clear thinking. That is because I am a bit stuck and thought I'd seek help. I have been thinking some about languages and how it isn't always easy to clearly separate language being implemented from the language

[racket-users] How would you implement autoquoted atoms?

2019-04-23 Thread zeRusski
I must apologies for what follows will be more of a rambling than an exercise in clear thinking. That is because I am a bit stuck and thought I'd seek help. I have been thinking some about languages and how it isn't always easy to clearly separate language being implemented from the language

Re: [racket-users] Is there a way to find where some feature is implemented in racket?

2019-04-17 Thread zeRusski
> > Open DrRacket. > Use the feature in a syntactically correct way. > Click (depending on your OS) on the identifier to open defining file. > ah, that works great least for identifiers in module body, thank you for showing this to me. I sometimes forget drracket packs some neat stuff. This

Re: [racket-users] How would you implement autoquoted atoms?

2019-04-23 Thread zeRusski
On Tuesday, 23 April 2019 15:57:52 UTC+1, Matthew Flatt wrote: > > This response will be rambling, too. :) And here I thought I asked an embarrassingly silly question :) While implementing a "naive" version I ran into two issues that I kind of predicted upfront, but just wanted to make sure

[racket-users] Strange Loop talk about Racket is up

2019-09-16 Thread zeRusski
https://youtu.be/yU-HUb8Xykg I'd estimate 10-15min total overlaps with my RacketCon talk here and there, 25-30min is my take on metaprogramming, Lisps and, of course, Racket. Haven't watched it myself, yet - need some hard liquor to numb the pain of listening to ones own voice :) -- You

[racket-users] Embedding Racket CS

2020-03-27 Thread zeRusski
How I might go about embedding Racket CS in a fairly big C codebase, about 100KLOC big. It is exceptionally well written C authored by people who knew what they were doing. I am sadly not one such person, so I'd rather not muddy things with my exceptionally terrible C. C code will be driving

Re: [racket-users] Embedding Racket CS

2020-03-29 Thread zeRusski
to use the API defined in C from Racket. Thank you Matthew! On Friday, 27 March 2020 22:53:42 UTC, Matthew Flatt wrote: > > At Fri, 27 Mar 2020 15:48:13 -0700 (PDT), zeRusski wrote: > > How I might go about embedding Racket CS > > The current development version (as reflected

Re: [racket-users] Embedding Racket CS

2020-03-29 Thread zeRusski
hat hello.h which I tried to include. > > On Friday, 27 March 2020 22:53:42 UTC, Matthew Flatt wrote: >> >> At Fri, 27 Mar 2020 15:48:13 -0700 (PDT), zeRusski wrote: >> > How I might go about embedding Racket CS >> >> The current development version (as ref

Re: [racket-users] Embedding Racket CS

2020-03-30 Thread zeRusski
successfully called Racket CS from C. I'll try what you suggest re calling C from Racket at some point and report any problems. Thank you! On Sunday, 29 March 2020 21:41:46 UTC+1, Matthew Flatt wrote: > > At Sun, 29 Mar 2020 13:13:08 -0700 (PDT), zeRusski wrote: > > First, CS snaps

Re: [racket-users] How to avoid all packages when building from source?

2020-05-08 Thread zeRusski
> You can do "make base" instead, which installs no packages. Or you can do > something like 'make PKGS=drracket' which just installs DrRacket and > dependencies, or similar with other packages. > I am installing in-place but racket cs, not racket bc, so IIUC `make base` isn't what I want.

[racket-users] How to avoid all packages when building from source?

2020-05-08 Thread zeRusski
I just rebuilt Racket from git repo checkout. It takes a while but most of that time is spent in `raco setup` which appears to be building all packages in existence. E.g. games, redex-examples, realm of Racket chapter 6 (really?), plai, algol, etc. Why do I end up with the entire jungle? Is

[racket-users] How to run multiple Racket installations?

2020-05-08 Thread zeRusski
I have two builds of Racket on my local machine. Racket CS resides in one directory and was built with `RACKETCS_SUFFIX=""` and stardard Racket also built from source in a separate directory. Normally I have my .bashrc setup PATH as needed to use e.g. Racket CS. I ran into a problem with an

[racket-users] Replace pre-installed rackunit with git source

2020-07-22 Thread zeRusski
Hi all. Latest commit to rackunit haven't made it into 7.7 so I attempted to replace the rackunit installed as part of the distribution in racket/share/pkgs by cloning the repo then: cd rackunit raco pkg update --force --type dir raco pkg show would show the `rackunit` linked as expected,

Re: [racket-users] Replace pre-installed rackunit with git source

2020-07-23 Thread zeRusski
cket-lang.org one. > > Sam > > On Wed, Jul 22, 2020 at 9:03 AM zeRusski > wrote: > > > > Hi all. Latest commit to rackunit haven't made it into 7.7 so I > attempted to replace the rackunit installed as part of the distribution in > racket/share/

[racket-users] Does Racket interpreter exist?

2020-07-26 Thread zeRusski
Hi all. I wonder if such a thing exist or even possible? Question triggered by the trade off between "compile slowly now to run fast later" vs "start fast". Racket like other modern(ish) Scheme derivatives appear to have settled on being in the former camp. Is there anything in the language

Re: [racket-users] Does Racket interpreter exist?

2020-07-29 Thread zeRusski
This is a really cool piece of history! Thank you. I'll admit I'm somewhat fuzzy here - it maybe a bit too meta for me or perhaps I don't quite understand what you're trying to say. Isn't interpreting n levels deep also linear in n? Only difference between the two approaches I see is that

Re: [racket-users] Does Racket interpreter exist?

2020-07-27 Thread zeRusski
Thank you for this fantastic reply Sam! I now think I had a very naive model of "interpreter" when I asked the question. My CS degree from the nowhere university has it that language interpreters walk the tree and you know "execute" be it in the host language or generating native code. I feel

Re: [racket-users] Does Racket interpreter exist?

2020-07-27 Thread zeRusski
> > The best way to distinguish compilers from interpreters is that a > compiler takes a program and produces another program, whereas an > interpreter takes a program (along with some input) and produces an > answer. > Doesn't this trivialize the difference a bit too much? Does it really

Re: [racket-users] Does Racket interpreter exist?

2020-07-31 Thread zeRusski
Thank you Arthur. Indeed Lisp in Small Pieces cites this paper in the chapter about fast interpreters among two others but sadly in French :) On Thursday, 30 July 2020 15:45:01 UTC+1, Arthur Nunes-Harwitt wrote: > > Hi, > >While you're enumerating these possibilities, I think it's

Re: [racket-users] Does Racket interpreter exist?

2020-07-29 Thread zeRusski
> > -- hendrik > > I hope this set of answers clarifies the distinction between an > interpeter and compiler, how the distinction gets blurred in practice, > and what the criteria are for choosng between them. > This was both detailed, insightful and truly helpful. I can't thank you enough