static-typing

How to deal with Python ~ static typing? [closed]

家住魔仙堡 提交于 2019-11-29 06:15:05
I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do you like Python's typing? Do you have an example where it helped in a big project? Isn't it a bit error prone? Static type checking is undecidable in the general case. This means that there are programs which are statically type-safe but for which the type-checker cannot prove that they are statically type-safe, and thus the type-checker must reject those programs. In other words: there are type-safe programs that the type-checker will not allow you to write. Or

Which languages are dynamically typed and compiled (and which are statically typed and interpreted)?

青春壹個敷衍的年華 提交于 2019-11-28 22:26:06
In my reading on dynamic and static typing, I keep coming up against the assumption that statically typed languages are compiled, while dynamically typed languages are interpreted. I know that in general this is true, but I'm interested in the exceptions. I'd really like someone to not only give some examples of these exceptions, but try to explain why it was decided that these languages should work in this way. Here's a list of a few interesting systems. It is not exhaustive! Dynamically typed and compiled The Gambit Scheme compiler, Chez Scheme , Will Clinger's Larceny Scheme compiler, the

Are there any static duck-typed languages?

不羁的心 提交于 2019-11-28 20:33:11
Can I specify interfaces when I declare a member? After thinking about this question for a while, it occurred to me that a static-duck-typed language might actually work. Why can't predefined classes be bound to an interface at compile time? Example: public interface IMyInterface { public void MyMethod(); } public class MyClass //Does not explicitly implement IMyInterface { public void MyMethod() //But contains a compatible method definition { Console.WriteLine("Hello, world!"); } } ... public void CallMyMethod(IMyInterface m) { m.MyMethod(); } ... MyClass obj = new MyClass(); CallMyMethod(obj

Can someone tell me what Strong typing and weak typing means and which one is better?

瘦欲@ 提交于 2019-11-28 17:12:42
Can someone tell me what Strong typing and weak typing means and which one is better? That'll be the theory answers taken care of, but the practice side seems to have been neglected... Strong-typing means that you can't use one type of variable where another is expected (or have restrictions to doing so). Weak-typing means you can mix different types. In PHP for example, you can mix numbers and strings and PHP won't complain because it is a weakly-typed language. $message = "You are visitor number ".$count; If it was strongly typed, you'd have to convert $count from an integer to a string,

Disadvantages of Scala type system versus Haskell?

筅森魡賤 提交于 2019-11-28 15:52:44
I have read that Scala's type system is weakened by Java interoperability and therefore cannot perform some of the same powers as Haskell's type system. Is this true? Is the weakness because of type erasure, or am I wrong in every way? Is this difference the reason that Scala has no typeclasses? 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

Python 3 and static typing

喜你入骨 提交于 2019-11-28 15:17:51
I didn't really pay as much attention to Python 3's development as I would have liked, and only just noticed some interesting new syntax changes. Specifically from this SO answer function parameter annotation: def digits(x:'nonnegative number') -> "yields number's digits": # ... Not knowing anything about this, I thought it could maybe be used for implementing static typing in Python! After some searching, there seemed to be a lot discussion regarding (entirely optional) static typing in Python, such as that mentioned in PEP 3107 , and "Adding Optional Static Typing to Python" (and part 2 ) .

How to deal with Python ~ static typing? [closed]

早过忘川 提交于 2019-11-28 00:09:11
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago . I am from Java world and I wonder what is so great about dynamic typing in Python besides missing errors while compiling the code? Do

Tools for static type checking in Python

早过忘川 提交于 2019-11-27 19:37:14
I'm working with a large existing Python codebase and would like to start adding in type annotations so I can get some level of static checking. I'm imagining something like Erlang , Strongtalk , or Typed Scheme/Racket . I've seen quick-and-dirty decorators that insert dynamic checks based on function parameter and return type annotations, but I'm looking for something that is more robust and that performs checks at compile-time. What tools are available right now for this kind of thing? I'm familiar with compilers and type checking and am definitely willing to improve an incomplete tool if it

Are there any static duck-typed languages?

这一生的挚爱 提交于 2019-11-27 12:58:37
问题 Can I specify interfaces when I declare a member? After thinking about this question for a while, it occurred to me that a static-duck-typed language might actually work. Why can't predefined classes be bound to an interface at compile time? Example: public interface IMyInterface { public void MyMethod(); } public class MyClass //Does not explicitly implement IMyInterface { public void MyMethod() //But contains a compatible method definition { Console.WriteLine("Hello, world!"); } } ...

Why is C# statically typed?

走远了吗. 提交于 2019-11-27 12:21:37
I am a PHP web programmer who is trying to learn C#. I would like to know why C# requires me to specify the data type when creating a variable. Class classInstance = new Class(); Why do we need to know the data type before a class instance? Joel Coehoorn As others have said, C# is static/strongly-typed. But I take your question more to be "Why would you want C# to be static/strongly-typed like this? What advantages does this have over dynamic languages?" With that in mind, there are lots of good reasons: Stability Certain kinds of errors are now caught automatically by the compiler, before the