language-design

Why couldn't Julia superset python?

谁说我不能喝 提交于 2021-02-18 23:51:07
问题 The Julia Language syntax looks very similar to python, while the concept of a class (if one should address it as such a thing) is more what you use in C. There were many reasons why the creators decided on the difference with respect to the OOP. Still would it have been so hard (in comparison to create Julia in first place which is impressive) to find some canonical way to interpret python to Julia and thus get a hold of all the python libraries? 回答1: Yes. The design of Python makes it

Why couldn't Julia superset python?

拟墨画扇 提交于 2021-02-18 23:47:30
问题 The Julia Language syntax looks very similar to python, while the concept of a class (if one should address it as such a thing) is more what you use in C. There were many reasons why the creators decided on the difference with respect to the OOP. Still would it have been so hard (in comparison to create Julia in first place which is impressive) to find some canonical way to interpret python to Julia and thus get a hold of all the python libraries? 回答1: Yes. The design of Python makes it

Why built-in types in C# are language keywords?

有些话、适合烂在心里 提交于 2021-02-18 20:43:11
问题 In C#, identifiers such as int or string are actually language level keywords. What is the reason for that? Note that if the authors wanted to disallow user types with these names, that could have made that a semantic error, not syntax error. Some clarifications based on answers: They are keywords because it makes parsing possible/easier I do not see why, as I am developing a parser, and having Type.Rule = Identifier is much simpler than Type.Rule = Identifier | "int" | "string" | ... . They

in java, why do closured variables need to be declared final?

梦想与她 提交于 2021-02-16 19:37:26
问题 final Object o; List l = new ArrayList(){{ // closure over o, in lexical scope this.add(o); }}; why must o be declared final? why don't other JVM languages with mutable vars have this requirement? 回答1: This is not JVM-deep, it all happens at syntactic-sugar level. The reason is that exporting a non-final var via a closure makes it vulnerable to datarace issues and, since Java was designed to be a "blue-collar" language, such a surprising change in the behavior of an otherwise tame and safe

Why are arrays covariant but generics are invariant?

孤人 提交于 2021-02-11 12:04:35
问题 From Effective Java by Joshua Bloch, Arrays differ from generic type in two important ways. First arrays are covariant. Generics are invariant. Covariant simply means if X is subtype of Y then X[] will also be sub type of Y[]. Arrays are covariant As string is subtype of Object So String[] is subtype of Object[] Invariant simply means irrespective of X being subtype of Y or not , List<X> will not be subType of List<Y>. My question is why the decision to make arrays covariant in Java? There

Why are arrays covariant but generics are invariant?

老子叫甜甜 提交于 2021-02-11 12:02:01
问题 From Effective Java by Joshua Bloch, Arrays differ from generic type in two important ways. First arrays are covariant. Generics are invariant. Covariant simply means if X is subtype of Y then X[] will also be sub type of Y[]. Arrays are covariant As string is subtype of Object So String[] is subtype of Object[] Invariant simply means irrespective of X being subtype of Y or not , List<X> will not be subType of List<Y>. My question is why the decision to make arrays covariant in Java? There

Why does the YAML spec mandate a space after the colon?

≡放荡痞女 提交于 2021-02-08 12:19:36
问题 The YAML spec clearly states: Mappings use a colon and space (“: ”) to mark each key: value pair. So this is legal: foo: bar But this, Ain't: foo:bar I see many people online that are ranting about the space. I think they have a point. I got burned by it several times myself. Why is the space mandatory? What was the design consideration behind it? 回答1: It's easy to miss, because that specification uses the bizarre convention of only highlighting the last character of an internal link, but the

Why are InputIterators one pass only?

岁酱吖の 提交于 2021-02-08 09:15:49
问题 From 24.2.3 Input iterators [input.iterators] 3) [...] Algorithms on input iterators should never attempt to pass through the same iterator twice. They should be single pass algorithms. [...] This IMO restricts some fairly straight-forward optimizations (such as passing through the container once to see how many elements it has) - alas, the motivation is outside the scope of the question. Why this requirement? 回答1: Input iterators are used to iterate over ranges that don't have a material

Why are InputIterators one pass only?

佐手、 提交于 2021-02-08 09:15:11
问题 From 24.2.3 Input iterators [input.iterators] 3) [...] Algorithms on input iterators should never attempt to pass through the same iterator twice. They should be single pass algorithms. [...] This IMO restricts some fairly straight-forward optimizations (such as passing through the container once to see how many elements it has) - alas, the motivation is outside the scope of the question. Why this requirement? 回答1: Input iterators are used to iterate over ranges that don't have a material

Is C++ considered a Von Neumann programming language?

别等时光非礼了梦想. 提交于 2021-02-07 13:40:34
问题 The term Von Neumann languages is applied to programming languages whose computational model is based on the Von Neumann computer architecture. Is C++ considered a Von Neumann language, or if it's not (e.g., because of asynchronous execution with the advent of threads) was it ever considered a Von Neumann language? Is there an architecture that C++'s computational model/abstract machine is based on and thus can be classified as a language of that architecture? 回答1: TL:DR: The C++ abstract