Tag Info

New answers tagged

0

If you are trying to decide what you should do in a language you are designing, I would suggest providing syntactical forms programmers can use to indicate various expectations. As a hypothetical example (borrowing concepts from a few languages): let x = someValue; Create a new read-only identifier x, and expect that any code which can ever see the new ...


1

C++ treats int, const int, int&, and const int& as separate types with ways to convert to/from each type (except to const int or to const int&). If you know what types you have and what types are expected, then given a list of converters, you know if you can make each passed parameter pass as an argument parameter. Since there may also be ...


0

If class Foo accepts references to objects of its type from outside code and uses private members thereof, then outside code will need to use references of type Foo or one of its subtypes. If Foo didn't need to use private members of its own type, but it implemented an interface which included all the members it did need to use, then it would be possible ...


0

I have decided to go through with this design decision for the following reasons: Such a convention is actually more consistent with the functional nature of the language. All functions are unary (accept a single argument) -- those accepting multiple arguments are simply curried, and those accepting "none" (as per this decision) actually accept the sole () ...


4

Sure, that makes sense theoretically. Especially in functional languages, having a function that takes no input is weird. Though I would encourage you to prevent declaring parameterless functions, not prevent them in your type system. Consider parameter binding. If you have a unary function and bind a parameter to it, you would have a parameterless function ...


2

Scala returning () really just means that you should ignore the meaningless return value. Basically the same as void in C, right? But a function that takes no arguments can still return a usable value, so I'm not sure I see a one-to-one correspondence in the design. Forcing functionally parameterless functions to take a parameter of type Unit which is ...


3

It seems eminently possible to create a type system which categorises the performance characteristic of types (e.g. "fast/slow for serial access, "fast/slow for random access", "memory efficient/inefficient"). Those traits could be abstract types placed into the hierarchy in such a way that the more concrete types inherited from them. However, the ...


6

You could imagine a type system sophisticated enough to be related to WCET or complexity of the program. Then, the issue is to make a sound type analyzer (or checker) - i.e. typing rules - to make that possible, and implement it efficiently enough to make that reasonably useful. Most of the type systems are simple enough to be quick to compute in practice ...



Top 50 recent answers are included