Skip to main content

Questions tagged [static-typing]

For questions relating to languages whose variables' data types are known at compile time, and type systems supporting this.

Filter by
Sorted by
Tagged with
6 votes
1 answer
119 views

Understanding the "operational" reading of typing judgements in PFPL by Robert Harper, Chapter 4 Statics

I'm reading Practical Foundations for Programming Languages by Robert Harper and am confused by the exercises in Chapter 4, "Statics", where he discusses a (monomorphic) type system. The ...
Jay Lee's user avatar
  • 223
1 vote
1 answer
273 views

Type-checking Python vs Typescript

mypy is very slow, pyright is fast but not quick enough in a large codebase, and tsc gives an immediate intellisense and type errors. I do not know whether it is because Python has more complex type ...
mq7's user avatar
  • 113
15 votes
6 answers
5k views

"Testing" that something does not compile in metaprogramming

Use case Some languages offer techniques to ensure certain requirements at compile time. For example, rust has the NonZeroU32 type that will ensure at compile time ...
mousetail's user avatar
  • 8,289
9 votes
1 answer
2k views

Is Epic Games' Verse gradually typed?

I've just watched an interview on YouTube with Simon Peyton Jones where they talk about Epic's Verse language. Here (at roughly 51:30) they start talking about the type system. Simon mentions that ...
Timo's user avatar
  • 193
9 votes
5 answers
1k views

How to make logical operators that return operands consistent in a statically typed language?

In C++, 3 || 4 returns true. But in Python, 3 or 4 returns 3 instead. That's a logical operator that returns its operand. I don'...
user23013's user avatar
  • 2,430
19 votes
4 answers
3k views

To what extent is type theory relevant to dynamically typed languages?

There seem to be two conflicting views regarding the status of "type systems" used in dynamically typed languages: That dynamically typed languages are actually just unityped static ...
Caleb Thomas's user avatar
3 votes
2 answers
413 views

What are the possible variations of the type of "this" or "self"?

In the class definitions of an object oriented language, this refers to the object instance the code is about to work upon. Naturally, it should have the same type ...
user23013's user avatar
  • 2,430
8 votes
1 answer
358 views

How, if at all, do kinds fit into the type universe hierarchy?

As I understand it, as a (value-level) function f that takes a value x of type T and returns ...
user570286's user avatar
26 votes
6 answers
1k views

Why don't many languages have integer range types?

An integer range type like 0..100 means that a value can be any integer in that range. Arithmetic operations on range types produce other range types, for example ...
kaya3's user avatar
  • 19.4k
10 votes
1 answer
361 views

What are some options for integrating subtyping with Damas-Hindley-Milner inference?

Type inference in a Damas-Hindley-Milner type system with subtyping is known to be undecidable in general. What makes it so difficult? What options are there to get around undecidability which could ...
Pseudonym's user avatar
  • 4,706
4 votes
1 answer
168 views

Supporting a statically-typed language in an IDE?

I'm almost finishing my open-source language's verifier. It performs parsing and verification, which ensures a set of programs are valid both syntatically and semantically at compile-time. To start ...
Hydroper's user avatar
  • 1,017
11 votes
3 answers
304 views

How can a language statically ensure a required index exists in a list?

Suppose a language has a conventional list data structure that contains some dynamic number of values indexed sequentially. Some operations to access a value from the list require that a certain index ...
Michael Homer's user avatar
  • 12.9k
13 votes
5 answers
396 views

What strategies did Go use to circumvent the lack of generics?

Go (was) famous for its lack of generics. However, the lack of generics in a statically typed language makes quite a few things harder. For example (in a pseudocode because I don't know Go): ...
Seggan's user avatar
  • 2,683
12 votes
4 answers
1k views

Why does Python ignore type hints?

In Python, everything is treated as an object. This means that CPython interpreter will decide on the fly, what is the type of each variables or the function return type depending on the current state....
Hemanth Haridas's user avatar
11 votes
1 answer
437 views

How can I have mutually-exclusive properties in a structural type system?

I have a structurally-typed object-oriented language, and I'd like to allow for types with some mutually-exclusive properties/attributes/slots/methods. That is, an object having more than one of these ...
Michael Homer's user avatar
  • 12.9k
10 votes
1 answer
205 views

How can optional properties be made sound in a static structural type system?

Typescript's structural type system is known to be (intentionally) unsound, in the sense that the value of an expression at runtime is not always necessarily assignable to its type determined at ...
kaya3's user avatar
  • 19.4k
5 votes
3 answers
204 views

How can I reconcile “all functions are variables” with a typeclass type system?

In my WIP language, all functions are really just variables with a callable type. That is, a function call foo(bar) is parsed into the following AST: ...
Seggan's user avatar
  • 2,683
11 votes
2 answers
331 views

What are the run-time implications of gradual typing?

Statically-typed languages specify the types of variables and functions and reject programs they know won't work before they run. Dynamically-typed languages don't include these annotations or checks, ...
Michael Homer's user avatar
  • 12.9k
9 votes
4 answers
601 views

What are the pros and cons of static typing?

Static typing means the type of a variable is known at compile time. This means that either you have to specify the type, or the compiler has to infer it (usually both). You also can't change the type ...
naffetS's user avatar
  • 1,057
7 votes
2 answers
280 views

How to Add Static Typing to a Stack Language?

What level of static typing can be added to a stack-based language? I know it's impossible to fully statically type some stack languages: ...
lyxal's user avatar
  • 1,775
6 votes
3 answers
408 views

What are common approaches to representing types within a compiler?

I'm implementing my own statically-typed programming language and I'm not too happy with my own approach to types. At the moment, I'm relying on mapping a textual representation of a type to an index ...
springogeek's user avatar