Conversation
Edited yesterday

oof so as far as I can tell Racket has no way to get a field from an object based on a variable. like in Python you can do this:

class SomeClass:
    def __init__(self):
        self.foo = 666

obj = SomeClass()
field_name = "foo"
getattr(obj, field_name) # -> 666

but as far as I can tell #Racket literally will not let you do that T_T the field name basically has to be known at compile time or it won’t work. that is actually terrible because I’m trying to make a (get) form that is able to drill down into data structures given a list of keys:

(get some-data '(2 4 hash-key obj-field))

but I think it’s literally impossible for me to make it work with objects

1
0
1
complaining
Show content

the whole reason that I’m doing this is to fix Racket’s overly picky and verbose syntax for getting data from data structures but if Racket is just going to deliberately stop me from being able to then maybe I really should just use another language

1
0
2
re: complaining
Show content

also like, a huge part of why I like Lisps so much is because they let you essentially turn them into anything you want. like if you don’t like an aspect of the language then you can just change it completely or make your own version instead

and yet Racket is (as far as I can tell) deliberately stopping me from accessing the public fields of classes? why would you intentionally add that limitation to a language? that means I can’t fix anything. frustrating

1
0
3
re: complaining
Show content

I’m getting increasingly tempted just to make my own Lisp, but I’m pretty sure that would take actual years of work and nobody would use it anyway - since it seems like the folks who like lisps are happy with the weird jank that currently exists, and the folks who don’t like lisps are not going to suddenly like my version of a lisp lol. plus popularity is a catch-22

1
1
4
re: complaining
Show content

@kasdeya what features are you looking for in an ideal lisp? hammyeyes

1
0
1
re: complaining
Show content

@celestia I actually wrote a post about this! https://cryptid.cafe/notice/B5MSdlBZZE0JmoQ0KO

I pretty much want to copy the semantics of Lua but use the macro system and syntax of Lisps. I also want to steal Fennel’s syntax for accessing the properties of a table because it’s really convenient - especially compared to the nightmare that is accessing properties on Racket data structures

(also ideally I’d want my Lisp to be as statically-analyzable as possible. I’d want to build something like Racket’s contract system pretty deep into the language so that LSPs can see those contracts and figure out if you’re calling a function incorrectly, and also provide autocomplete hints. which are two things that Lisp LSPs tend to be very bad at in my experience)

1
1
1
re: complaining
Show content

@kasdeya thanks for sharing! blobcatheart

statically analyzable speaks to me hammyeyes most lisps don't pay any attention to that and it's sad

for all the nosense in it, I think python got many things right about getting static analysis as a dynamic language (typescript not so much imo) and it's worth looking at

1
0
1
re: complaining
Show content

@celestia thanks for being interested! 💙

and I totally agree. I’ve heard some vague criticisms of Python from functional folks, and I have to admit that it has a fair bit of stuff in it that I don’t like (each iteration of a loop uses the same variable, a lot of stuff is pretty magic/implicit compared to Lua, a few of the standard libraries have terrible documentation, lambdas can’t have statements or multiple expressions in them, etc.) it’s definitely the most comfortable language I’ve ever used - and the type annotations (and how statically analyzable they are) are a big part of that for me

1
0
1
re: complaining
Show content

@kasdeya fully agreed!

I always hated python until bro recently where static analyzers started getting good and now it's one of my favourite languages hehe

0
0
1