static-typing

are there statically-typed functional languages?

杀马特。学长 韩版系。学妹 提交于 2019-12-21 03:37:09
问题 this is a hard thing to google, maybe SO has better answers? i'm coming from a statically-typed background and investigating functional programming, but i'm not entirely excited about dynamic typing. curious what kind of options are out there. one answer to start: ActionScript 3 is statically-typed and offers some functional paradigms, though AS3 programs don't often use them. 回答1: There are many. Haskell, OCaml and F# come to mind. If you are a Windows developer, F# is very nice and is well

Is there support for static typing in ECMAScript 6 or 7?

雨燕双飞 提交于 2019-12-21 03:12:50
问题 Is there any support for static typing in ECMAScript 6? How about ECMAScript 7? 回答1: No. But on the ECMA-Script Wikipage there is a paragraph about changes in ECMA-Script 7: The Seventh Edition is in a very early stage of development, but is intended to continue the themes of language reform, code isolation, control of effects and library/tool enabling from ES6. New features proposed include promises/concurrency, number and math enhancements, guards and trademarks (an alternative to static

Do you know of a language with Static Type checking where Code is Data? [closed]

丶灬走出姿态 提交于 2019-12-20 17:39:06
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Can you name languages with static type checking (like Java) and where code is data (like in LISP)? I mean both things in one language. 回答1: Qi is a statically-typed Lisp dialect. Also, many other Lisp dialects have (optional) static typing. Java itself has very limited

TypeScript: problems with type system

浪尽此生 提交于 2019-12-20 08:31:10
问题 I'm just testing typescript in VisualStudio 2012 and have a problem with its type system. My html site has a canvas tag with the id "mycanvas". I'm trying to draw a rectangle on this canvas. Here's the code var canvas = document.getElementById("mycanvas"); var ctx: CanvasRenderingContext2D = canvas.getContext("2d"); ctx.fillStyle = "#00FF00"; ctx.fillRect(0, 0, 100, 100); Unfortunately VisualStudio complains that the property 'getContext' does no exist on value of type 'HTMLElement' It marks

In Python 3.5, how can I specify a function as a type hint?

空扰寡人 提交于 2019-12-19 19:49:33
问题 What is the appropriate type hint to specify that a variable should be a function (the equivalent of a delegate, Func<T> or Action in C#)? Is it also possible to specify the function argument types in a generic fashion as well (for example Func<int, int> )? I cannot find any relevant details in the documentation. 回答1: According to the docs, you can use Callable, imported from typing. You can view more details in PEP 0484. 来源: https://stackoverflow.com/questions/35315824/in-python-3-5-how-can

What special rules does the scala compiler have for the unit type within the type system

北城余情 提交于 2019-12-18 18:40:11
问题 The Unit gets special handling by the compiler when generating byte code because it's analogous to void on the jvm. But conceptually as a type within the scala type system, it seems like it also gets special treatment in the language itself (examples below). So my question is about clarifying this and understanding what mechanisms are used and if there really is special treatment for the Unit type. Example 1: For "normal" scala types like Seq , if a method returns Seq , then you must return

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

自闭症网瘾萝莉.ら 提交于 2019-12-17 22:56:35
问题 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. 回答1: Here's a list of a few interesting systems. It is not exhaustive!

Python 3 and static typing

笑着哭i 提交于 2019-12-17 22:29:03
问题 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

Is there a Haskell idiom for updating a nested data structure?

风流意气都作罢 提交于 2019-12-17 02:38:10
问题 Let's say I have the following data model, for keeping track of the stats of baseball players, teams, and coaches: data BBTeam = BBTeam { teamname :: String, manager :: Coach, players :: [BBPlayer] } deriving (Show) data Coach = Coach { coachname :: String, favcussword :: String, diet :: Diet } deriving (Show) data Diet = Diet { dietname :: String, steaks :: Integer, eggs :: Integer } deriving (Show) data BBPlayer = BBPlayer { playername :: String, hits :: Integer, era :: Double } deriving

What is the difference between a strongly typed language and a statically typed language?

蓝咒 提交于 2019-12-17 02:00:11
问题 Also, does one imply the other? 回答1: What is the difference between a strongly typed language and a statically typed language? A statically typed language has a type system that is checked at compile time by the implementation (a compiler or interpreter). The type check rejects some programs, and programs that pass the check usually come with some guarantees; for example, the compiler guarantees not to use integer arithmetic instructions on floating-point numbers. There is no real agreement