language-design

Clojure Protocols vs Scala Structural Types

心已入冬 提交于 2019-12-02 18:33:27
After watching the interview with Rich Hickey on Protocols in Clojure 1.2, and knowing very little about Clojure, I have some questions on Clojure Protocols: Are they intended to do the same thing as Structural Types in Scala? What benefits do Protocols have over Structural Types (performance, flexibility, code clarity, etc.)? Are they implemented through reflections? Questions on interoperability with Scala: Can Protocols be used instead of Structural Types in Scala? Can they be extended (if 'extension' term can be applied to Protocols) in Scala? Totally unrelated. Scala is a statically typed

What is the difference between static and dynamic binding?

我怕爱的太早我们不能终老 提交于 2019-12-02 17:11:12
Binding times can be classified between two types: static and dynamic. What is the difference between static and dynamic binding? Could you give a quick example of each to further illustrate it? In the most general terms, static binding means that references are resolved at compile time . Animal a = new Animal(); a.Roar(); // The compiler can resolve this method call statically. Dynamic binding means that references are resolved at run time . public void MakeSomeNoise(object a) { // Things happen... ((Animal) a).Roar(); // You won't know if this works until runtime! } It depends when the

Why are most string manipulations in Java based on regexp?

久未见 提交于 2019-12-02 15:47:22
In Java there are a bunch of methods that all have to do with manipulating Strings. The simplest example is the String.split("something") method. Now the actual definition of many of those methods is that they all take a regular expression as their input parameter(s). Which makes then all very powerful building blocks. Now there are two effects you'll see in many of those methods: They recompile the expression each time the method is invoked. As such they impose a performance impact. I've found that in most "real-life" situations these methods are called with "fixed" texts. The most common

What are Haskell's strictness points?

半腔热情 提交于 2019-12-02 15:45:29
We all know (or should know) that Haskell is lazy by default. Nothing is evaluated until it must be evaluated. So when must something be evaluated? There are points where Haskell must be strict. I call these "strictness points", although this particular term isn't as widespread as I had thought. According to me: Reduction (or evaluation) in Haskell only occurs at strictness points. So the question is: what, precisely , are Haskell's strictness points? My intuition says that main , seq / bang patterns, pattern matching, and any IO action performed via main are the primary strictness points, but

How to track newer C++ std documents of given topic?

家住魔仙堡 提交于 2019-12-02 15:38:18
Following is a C++ std document. The document number is N3721, which superseded the older N3634. Obviously, it's easy to track older documents of given topic. However, my question is: How to track newer documents of given topic? For example, if N3721 is superseded by a newer document, how to track the newer one? Shafik Yaghmour For the newer proposals (ones that start with the letter P ) you can use wg21.link redirect service to obtain the latest document: wg21.link - WG21 redirect service. Usage: wg21.link/nXXXX wg21.link/pXXXXrX Get paper. wg21.link/pXXXX Get latest public revision of paper.

Why are slices in Python 3 still copies and not views?

梦想与她 提交于 2019-12-02 15:24:28
As I only now noticed after commenting on this answer , slices in Python 3 return shallow copies of whatever they're slicing rather than views. Why is this still the case? Even leaving aside numpy's usage of views rather than copies for slicing, the fact that dict.keys , dict.values , and dict.items all return views in Python 3, and that there are many other aspects of Python 3 geared towards greater use of iterators, makes it seem that there would have been a movement towards slices becoming similar. itertools does have an islice function that makes iterative slices, but that's more limited

Why was the statement (j++); forbidden?

不羁的心 提交于 2019-12-02 14:59:06
The following code is wrong (see it on ideone ): public class Test { public static void Main() { int j = 5; (j++); // if we remove the "(" and ")" then this compiles fine. } } error CS0201: Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement Why does the code compile when we remove the parentheses? Why does it not compile with the parentheses? Why was C# designed that way? Eric Lippert Deep insights appreciated. I shall do my best. As other answers have noted, what's going on here is the compiler is detecting that an expression is being

New language on top of PHP?

强颜欢笑 提交于 2019-12-02 14:14:02
I'm a PHP developer. I like PHP! It is a really good language if you know how to use it, but I know it allows very bad design sometimes. It reminds me of JavaScript which has good parts and bad parts. One particular project, CoffeeScript, tries to focus only on the good parts, forcing you to write good code. I was thinking if something similar could be done with PHP... A new syntax that would be compiled only to good PHP code taking advatage of all the new and exciting stuff we can get with PHP 5.3. So, getting ahead of some people, I'll ask: Why create a new language on top of PHP if you can

Most interesting non-mainstream language? [closed]

匆匆过客 提交于 2019-12-02 14:01:44
I'm interested in compilers, interpreters and languages. What is the most interesting, but forgotten or unknown, language you know about? And more importantly, why? I'm interested both in compiled, interpreted and VM languages, but not esoteric languages like Whitespace or BF. Open source would be a plus, of course, since I plan to study and hopefully learn from it. I love compilers and VMs, and I love Lua. Lua is not as well supported as many other scripting languages, but from a mindset like yours I'm sure you will fall in love with Lua too. I mean it's like lisp, (can do anything lisp can

Is Lua based primarily on well-established programming-language ideas? [closed]

▼魔方 西西 提交于 2019-12-02 14:00:40
Lua occupies a good place in the space of languages that can be embedded. Are the primary ideas behind Lua's design new ideas from the implementors, or is Lua primarily a well-executed combination of well-established ideas? Comparison of properties and features of Lua to other PLs are particularly appropriate. Norman Ramsey This is a very interesting question. My day job is to study programming languages, and Lua will repay careful study. I would say that about very few other languages (perhaps Icon and CLU). Please note that it is the language as a whole , not the individual features, which