ryanc
2020-12-2 09:09:32

How are you counting the groups?


ryanc
2020-12-2 10:29:28

Well, just in case: if rx is the string form of a regexp, then (format "(?:~a)?" rx) produces a regexp that accepts the empty string and produces the same number of sub-matches as rx.


popa.bogdanp
2020-12-2 10:41:13

I’ll try that. Thanks!


notjack
2020-12-2 12:09:26

I haven’t thought it through much at all really. I just know that there’s a fixed number of identifiers so that limits the regexp complexity, and I’d like to catch regexp mistakes at compile time as much as possible.


lupino8211
2020-12-2 13:54:17

@lupino8211 has joined the channel


jhemann
2020-12-2 14:14:18

@jhemann has joined the channel


kellysmith12.21
2020-12-2 14:14:49

How stable/reliable are the <https://docs.racket-lang.org/syntax/Experimental.html?q=syntax%2Dparse|experimental libraries of syntax/parse?>


soegaard2
2020-12-2 14:15:17

That’s a question for @ryanc I think.


ryanc
2020-12-2 14:50:04

They’re stable. I don’t plan to remove or make breaking changes to any of them.


kellysmith12.21
2020-12-2 14:51:09

Are there any caveats regarding the libraries?


ryanc
2020-12-2 14:55:45

None come to mind right now.


gknauth
2020-12-2 16:27:45

What happens if the regexp fails to match?


gknauth
2020-12-2 16:29:37

I see, thanks. I’ll try that.


lupino8211
2020-12-2 17:34:24

Hi all! I started to learn racket a while ago, for language creating purposes. I wanted to create small language that will utilize racket’s ffi abilities, but now i’m desperate and don’t know how to make language work… https://github.com/readysloth/REPLify

Main idea was to separate loading library and defining foreign functions in two macroses: + use — creates dynamic library binding + header — creates function binding for library

Currently launching racket example.ffi spits out ffiREPL.rkt:73:9: define-lib-func: unbound identifier in: define-lib-func location...: ffiREPL.rkt:73:9 context...: Which is in header macro. As I understand it is because two identifiers bound separately. Where am I wrong? Thank you.


soegaard2
2020-12-2 17:44:33

Does it help to move (define-syntax-rule (use lib) (define-ffi-definer define-lib-func (ffi-lib lib))) into the expansion?


lupino8211
2020-12-2 18:03:54

Can you elaborate, please?


soegaard2
2020-12-2 18:18:46

Well, if define-lib-func can’t be seen where it is, then you need to move, so it becomes bound where you reference it.

I skimmed the code and I can’t point to anything specific, but I am concerned about the use of plain lists such as (define (define-func str) (match (parse-proto str) ([list name sign] `(define-lib-func ,name ,(_fun (map make-ffi-type (rest sign)) -&gt; (make-ffi-type (first sign))))))) to construct your expansion.

It might work, but I expect you to have better results if you work with syntax objects instead.


notjack
2020-12-2 18:19:47

currently, a very useless error message


lupino8211
2020-12-2 18:24:25

So i need to merge use and header macros together?

Also i tried, but did not understand: should i return syntax object from these macros? Because then it just prints it out…


gknauth
2020-12-2 18:50:21

In Scala-world (and I suppose Haskell), you’d get a Some(result) or a None, then you could pattern-match on that.


soegaard2
2020-12-2 19:15:56

It’s too complicated for me to figure out what’s going on. Experience tells me, that constructing pieces of code as plain lists often leads to binding problems. The solution is often to use syntax objects. This is a vague answer, but I can’t be more precise.


lupino8211
2020-12-2 19:49:48

Thank you! I forgot to change function in mapping… I also changed list to syntax, but now map prints many ffi-defines because it executes in runtime (not in compile time), i guess Can i somehow shift it? '(#&lt;syntax:ffiREPL.rkt:87:11 (define-lib-func memmove (_fun _pointer _pointer _size -&gt; _pointer))&gt; #&lt;syntax:ffiREPL.rkt:87:11 (define-lib-func memset (_fun _pointer _int _size -&gt; _pointer))&gt; #&lt;syntax:ffiREPL.rkt:87:11 (define-lib-func memcmp (_fun _pointer _pointer _size -&gt; _int))&gt; ...


notjack
2020-12-2 20:37:29

I think I’d like it to work just like (match-define (list a b c) #f) does except with an error message saying why the regexp didn’t match


gknauth
2020-12-2 20:43:22

Ok. Is it normal that a non-match is an error? Or, “it didn’t work out so let’s see if something else works?” I’m thinking someone could supply input that would inadvertently cause a program to give up. Unless you catch the error and recover that way.


notjack
2020-12-2 20:44:54

It seems roughly the same as any other kind of unexpected input: either raise a contract error or wrap everything to handle it some other way


notjack
2020-12-2 20:45:13

and in this case I’m mostly interested in streamlining the happy path


gknauth
2020-12-2 20:50:19

I’m persnickety because I parse NWS weather bulletins, which follow a pretty regular pattern, regular enough that we have regular expressions (going back to 2006) that handle most of the bulletin types. Except once in a while a human does something human (at NWS) and we get a bulletin that is missing something (usually lat/lon polygons) or something is malformed. Downstream we get all kinds of alarms from the database checks, the global this doesn’t match country that, a county supervisor calls HQ “How could we didn’t get an alert for that flood?” or “How come you alerted us for a tornado that wasn’t near us?” etc. We go digging, find the original alert text, and somewhere in there it was a regexp that didn’t match, so a piece of a bulletin was effectively missing.


gknauth
2020-12-2 20:52:58

The best error ever of this type (which was no fault of a regexp) was a call from someone in St. Louis, upset that there was an alert for a flood when there was no flood in St. Louis. But there was a flood 50 miles west, and the multipolygon for St. Louis included a little square 50 miles west of the city that was city property that was nowhere near the city, and that little square did have a flood.


notjack
2020-12-2 21:22:07

Oh yeah, that kind of use case definitely requires planning for failure isolation


notjack
2020-12-2 21:26:19

hmm, maybe I could build something on top of the guarded-block macro: (guarded-block (define string "aabbbbc") (regexp-guard (as bs cs) #rx"(a*)(b*)(c*)" string else "regexp didn't match!") (+ (string-length as) (string-length bs) (string-length cs))) (context for guarded-block macro: https://groups.google.com/g/racket-users/c/H-EppBmQ7oU)


sorawee
2020-12-3 03:14:02

Two problems/questions about the Makefile.

  1. Are JOB_OPTIONS and PLT_SETUP_OPTIONS supposed to function in the same way? I tried:

  2. PLT_SETUP_OPTIONS="-D" make both
  3. make both JOB_OPTIONS="-D".

The latter succeeds. The first does not (meaning it still builds the documentation).

  1. For the latter, it issues -D -D to raco setup, so it errors with the “can’t have more than one -D” error. Is there a way to make it work?

jsx610278856
2020-12-3 03:15:41

Hello, I am writing a web application. I created a hash table (make-hash) in the application. When the web application is running, i can’t use hash-remove! to remove a data. But hash-remove! can work in interactive window.


notjack
2020-12-3 03:18:34

@jsx610278856 when you say you “can’t use” it, do you mean that there’s an error message? or that it just doesn’t remove it and it looks like nothing happened?


jsx610278856
2020-12-3 03:20:26

it just doesn’t remove it and it looks like nothing happened, thank you



jsx610278856
2020-12-3 03:24:11

I use Racket 7.9.


mflatt
2020-12-3 03:53:28

Did you mean to use make both PLT_SETUP_OPTIONS=-D? If you put PLT_SETUP_OPTIONS=-D at the front, that means something different (in a shell like bash).


mflatt
2020-12-3 03:55:25

I’m not sure JOB_OPTIONS wouldn’t work, although it’s intended for -j &lt;N&gt;.


sorawee
2020-12-3 04:07:03

Oh, I read

> JOB_OPTIONS as a makefile variable and PLT_SETUP_OPTIONS as an environment variable and thought that PLT_SETUP_OPTIONS is a real environment variable, so PLT_SETUP_OPTIONS="-D" make both ought to work. Isn’t that the case?


mflatt
2020-12-3 04:23:05

Ah, I see. That description as an environment variable is a holdover from an old strategy that didn’t work out.


mflatt
2020-12-3 04:23:39

So, I’ll fix the build docs.


mwblakley
2020-12-3 05:08:08

looks like there is a missing symbolify call to get the key in delete!


jsx610278856
2020-12-3 06:24:34

Thank you