Is there a compiled* programming language with dynamic, maybe even weak typing?
I believe Lisp fits that description. http://en.wikipedia.org/wiki/Common_Lisp
I believe Lisp fits that description. http://en.wikipedia.org/wiki/Common_Lisp
Record update syntax comes standard with the compiler: addManStk team = team { manager = (manager team) { diet = (diet (manager team)) { steaks = steaks (diet (manager team)) + 1 } } } Terrible! But there’s a better way. There are several packages on Hackage that implement functional references and lenses, which is … Read more
I’d suggest you check out Angelscript. We used it on Warsow and it’s pretty good. It has all the features you’d expect like classes, memory management, etc. Since it’s statically typed, it can make better optimizations for you, and so the bytecode ends up faster than other scripting languages. However, AS is not as easy … Read more
The big difference is that Scala doesn’t have Hindley-Milner global type inference and instead uses a form of local type inference, requiring you to specify types for method parameters and the return type for overloaded or recursive functions. This isn’t driven by type erasure or by other requirements of the JVM. All possible difficulties here … Read more
What the standard says [intro.abstract]/1: The semantic descriptions in this document define a parameterized nondeterministic abstract machine. This document places no requirement on the structure of conforming implementations. In particular, they need not copy or emulate the structure of the abstract machine. Rather, conforming implementations are required to emulate (only) the observable behavior of the … Read more
Thanks for reading my code! Indeed, it’s not hard to create a generic annotation enforcer in Python. Here’s my take: ”’Very simple enforcer of type annotations. This toy super-decorator can decorate all functions in a given module that have annotations so that the type of input and output is enforced; an AssertionError is raised on … Read more
For the code completion and type hinting in IDEs, just add static typing for the Person and Address classes and you are already good to go. Assuming you use the latest python3.6, here’s a rough equivalent of the typescript classes from your example: # spam.py from typing import Optional, Sequence class Address: street: str housenumber: … Read more
I figured out the answer on my own. I searched, but found no documentation for the 3 type parameters of Generator in the official typing documentation for Python 3.5.2 – beyond a truly cryptic mention of… class typing.Generator(Iterator[T_co], Generic[T_co, T_contra, V_co]) Luckily, the original PEP484 (that started all this) was far more helpful: “The return … Read more
Type ascription is just telling the compiler what type you expect out of an expression, from all possible valid types. A type is valid if it respects existing constraints, such as variance and type declarations, and it is either one of the types the expression it applies to “is a“, or there’s a conversion that … Read more
Yes, it’s very possible, although a standard HM-style type system is usually the wrong choice for most idiomatic Lisp/Scheme code. See Typed Racket for a recent language that is a “Full Lisp” (more like Scheme, actually) with static typing.