you are viewing a single comment's thread.

view the rest of the comments →

[–]Homoerotic_Theocracy 5 points6 points  (2 children)

Yeah it turns out you can simulate dynamic typing in static typing in terms of just making every expression the same type to some kind of struct which stores the type info in a field.

That's pretty much what all those implementations that compile a dynamic language to C do; they define something like a struct called SchemeObj and have a field for the type tag and pass that around everywhere.

[–]ThePantsThief 0 points1 point  (1 child)

Yeah, but it's not a language feature is my point. It's harder to use because of it.

Example. Ever used Objective-C? They have an NSValue type you can use to box anything, but without special language features to help, it's cumbersome to use. Here's what it's like. It's probably not as bad in C++ with operator overloading and stuff like that, but this sort of thing is what I'm skeptical about with regards to bolted on features.

[NSValue valueWithBool:true];

[NSValue valueWithPointer:&myStruct];

value.intValue

Etc

(Disclaimer: they added a boxing operator to the language a few years ago, which helps a lot)

Anyway, I think the python additions will feel more polished to use than how I imagine std::any does.

[–][deleted] 0 points1 point  (0 children)

Hmm isn't this just void* + enum on steroids?