language-features

What's the bright side of Cobol? [closed]

社会主义新天地 提交于 2019-12-19 06:02:09
问题 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 7 years ago . I love spending my time investigating cool features of languages, even if I won't have a chance to use them anytime soon, but keep

How do you find the caller function? [duplicate]

此生再无相见时 提交于 2019-12-18 16:56:55
问题 This question already has answers here : Closed 11 years ago . Closed as exact duplicate of "How can I find the method that called the current method?" Is this possible with c#? void main() { Hello(); } void Hello() { // how do you find out the caller is function 'main'? } 回答1: Console.WriteLine(new StackFrame(1).GetMethod().Name); However, this is not robust, especially as optimisations (such as JIT inlining) can monkey with the perceived stack frames. 回答2: From here: System.Diagnostics

Are move semantics incomplete?

家住魔仙堡 提交于 2019-12-18 15:48:16
问题 Move semantics replace copy semantics in situations where copying is inefficient. Copy semantics deals fully with copyable objects, including const objects. Already, there exists a myriad of non-copyable objects in c++11, for example std::unique_ptr. These objects rely on move semantics completely because moving from an object allows for invalidating it. This is important (imho) for popular design patterns like RAII. A problem occurs when a const non-copyable object is assigned to an area of

Are move semantics incomplete?

≯℡__Kan透↙ 提交于 2019-12-18 15:48:00
问题 Move semantics replace copy semantics in situations where copying is inefficient. Copy semantics deals fully with copyable objects, including const objects. Already, there exists a myriad of non-copyable objects in c++11, for example std::unique_ptr. These objects rely on move semantics completely because moving from an object allows for invalidating it. This is important (imho) for popular design patterns like RAII. A problem occurs when a const non-copyable object is assigned to an area of

Why has Python decided against constant references?

流过昼夜 提交于 2019-12-18 12:51:24
问题 Note: I'm not talking about preventing the rebinding of a variable. I'm talking about preventing the modification of the memory that the variable refers to, and of any memory that can be reached from there by following the nested containers. I have a large data structure, and I want to expose it to other modules, on a read-only basis. The only way to do that in Python is to deep-copy the particular pieces I'd like to expose - prohibitively expensive in my case. I am sure this is a very common

Array/list vs Dictionary (why we have them at first place)

不打扰是莪最后的温柔 提交于 2019-12-18 12:42:13
问题 To me they are both same and that is why i am wondering why we have dictionary data structure when we can do everything with arrays/list? What is so fancy in dictionaries? 回答1: Arrays provide random access of a sequential set of data. Dictionaries (or associative arrays ) provide a map from a set of keys to a set of values. I believe you are comparing apples and oranges - they serve two completely different purposes and are both useful data structures. Most of the time a dictionary-like type

Is there anything like Enumerable.Range(x,y) in Java?

那年仲夏 提交于 2019-12-18 07:39:19
问题 Is there something like C#/.NET's IEnumerable<int> range = Enumerable.Range(0, 100); //.NET in Java? 回答1: Edited: As Java 8, this is possible with java.util.stream.IntStream.range(int startInclusive, int endExclusive) Before Java8: There is not such thing in Java but you can have something like this: import java.util.Iterator; public class Range implements Iterable<Integer> { private int min; private int count; public Range(int min, int count) { this.min = min; this.count = count; } public

In VB.NET why should I use Select, instead of If?

帅比萌擦擦* 提交于 2019-12-18 07:03:27
问题 I've recently graduated and started a real job. In our training they've been exposing us to VB.NET and a lot of the features they use here. In some of the examples, they've used Select statements (and in a few places they were used where an If/Else really should have been used). The only time that I've used a switch/select statement in other languages (other than assignments that required it) has been when I wanted the fall through to the next statement. Given than VB.NET has no fall through,

In VB.NET why should I use Select, instead of If?

时光怂恿深爱的人放手 提交于 2019-12-18 07:01:15
问题 I've recently graduated and started a real job. In our training they've been exposing us to VB.NET and a lot of the features they use here. In some of the examples, they've used Select statements (and in a few places they were used where an If/Else really should have been used). The only time that I've used a switch/select statement in other languages (other than assignments that required it) has been when I wanted the fall through to the next statement. Given than VB.NET has no fall through,

Is there a use of free floating block inside a method in Java?

China☆狼群 提交于 2019-12-18 05:40:52
问题 I didn't know methods could have floating blocks like this: class X { public static void main( String [] args ) { { //<--- start int i; } //<-- ends } } I was aware of floating blocks outside methods, but never tried them inside. This could probably be used to define local scope or something. Is there a use for floating blocks inside methods in Java? 回答1: Is there a use? Yes - to limit the scope of local variables. Is it a good idea? Probably debatable (and likely will be). The "pro" camp