zengmor
2021-1-22 09:04:37

@zengmor has joined the channel


laurent.orseau
2021-1-22 15:21:27

#lang racket (struct human (group)) (struct human-group (humans)) ; identifier already defined in: human-group :disappointed: me want . as field separator


sorawee
2021-1-22 15:23:32

Here’s a word of advice: (define-syntax (struct+ stx) ...) :wink:


sorawee
2021-1-22 15:23:50

Well, several words. One line.


laurent.orseau
2021-1-22 15:24:42

if based on struct, the fields will still be defined, or do you know a way to not or un-define them?


laurent.orseau
2021-1-22 15:24:51

Could be based on vectors otherwise


sorawee
2021-1-22 15:26:03

You don’t really need to undefine them I think. Just generate them in macro scope, so that they are not visible anywhere else, but in macro, alias them with names you generate that are not in macro scope.


laurent.orseau
2021-1-22 15:29:01

What about the non-field bindings? You need to ‘alias’ them too, it’s quite annoying


sorawee
2021-1-22 15:29:36

Yeah…


sorawee
2021-1-22 15:29:52

Another possibility


sorawee
2021-1-22 15:30:03

Generate a submodule


sorawee
2021-1-22 15:30:27

Use filtered-out to rename only things that you want to rename


sorawee
2021-1-22 15:31:22

filtered-out can work on regex, as shown in the example, so it’s kinda hacky, but also effective for your use case I think


laurent.orseau
2021-1-22 15:31:25

aha, that’s interesting


sorawee
2021-1-22 15:32:25

Well, actually


sorawee
2021-1-22 15:32:30

If you know the prefix already


sorawee
2021-1-22 15:32:36

there’s no need to even use regex


laurent.orseau
2021-1-22 15:32:50

but that won’t be for today, I just renamed to (struct human (the-group)) and be done with it :slightly_smiling_face:


sorawee
2021-1-22 15:32:55

lol


sorawee
2021-1-22 15:33:31

I guess another disadvantage of this solution is that you can’t define struct in internal definitions.


notjack
2021-1-22 23:58:36

thing I want: a way for an identifier to be define-syntax’d to a list of other identifiers, and when you do a.b it looks up b in the list


notjack
2021-1-22 23:59:31

(and for this to be integrated with structs, match patterns, syntax-parse, scribble, etc.)


me1890
2021-1-23 00:02:10

so structs, but use . instead of - as a symbol joiner? doesn’t sound too hard to make


notjack
2021-1-23 00:03:16

not a symbol joiner, I want them to be actual namespaces


notjack
2021-1-23 00:03:39

\|a.b\|.b should be possible


me1890
2021-1-23 00:04:51

oh, got it


me1890
2021-1-23 00:04:59

that’ll be an interesting one


notjack
2021-1-23 00:05:00

and module->exports should list a as the only provided binding


me1890
2021-1-23 00:05:26

I’m a big proponent of namespaces in langauges, this would be nice to make in racket


notjack
2021-1-23 00:05:59

this is definitely possible to make too, it just needs lots of work to integrate it with other stuff


me1890
2021-1-23 00:06:09

from the last line of the python zen: > Namespaces are one honking great idea — let’s do more of those!


notjack
2021-1-23 00:06:20

heh, yup :p


me1890
2021-1-23 00:07:54

so you’re suggesting some sort of infix syntax where \|foo\|.\|bar\| could be resolved(?) to a \|bar\| inside of \|foo\|, right?


notjack
2021-1-23 06:24:24

right, yup