Is there any programming language that allows you to redefine a system of its type?

I am looking for programming languages โ€‹โ€‹that allow you to override their type system without having to hack the compiler. Is there anything that allows you to do this?

thanks

+4
source share
4 answers

In C, you can use DEFINE to override everything.

#DEFINE int double 

Good or bad can be found here:

What is the worst macro / preprocessor behavior you've ever encountered in the world?

+2
source

If you are talking about redefining a real-type system, for example, about creating a dynamically typed language or that a strongly typed language is strongly typed, then no.

Almost every language allows you to define your own types, so I donโ€™t think what you meant.

The only thing I can think of that can fit into what you are asking for is macros in Common Lisp that allow you to extend the syntax. This may lead to what you are looking for, but until you specify what exactly you are looking for, I cannot understand.

Also, OCaml and its related languages โ€‹โ€‹allow you to do pretty interesting things with types. You can basically define any type of type that you can think of, and then map it to pattern matching, which makes it especially useful for writing compilers.

+1
source

Javascript, Ruby, and Smalltalk, only I know, letting you do all kinds of things, even redefining on the fly what an object can do. Perl allows you to redefine almost the entire language. In principle, any decent scripting language, especially one that allows you to print on a duck, should have equal power. But this, apparently, is really common among functional languages โ€‹โ€‹and functionalities.

0
source

If I remember correctly, Ada has neat features for creating a type, especially for measures (for example, determining the minimum and maximum, checking operations between different measures ...). I saw this as an example to avoid very stupid mistakes.

0
source

All Articles