language-features

C++11 feature checking

做~自己de王妃 提交于 2019-11-27 18:22:04
问题 How do I check for presence of individual C++0x/C++11 language features? I know Clang has a nice system for this. What about GCC, Visual Studio or Boost? I guess one way to do it is to detect the compiler version and relate that to the features introduced in that version. But that is cumbersome. Has someone already done that? 回答1: boost config comes with a script to check for some but not all C++11 features. It generates a config-file with macros for each feature. 回答2: Your build-tool may be

What is the maximum length of a C#/CLI identifier?

∥☆過路亽.° 提交于 2019-11-27 15:26:27
Which other restrictions are there on names (beside the obvious uniqueness within a scope)? Where are those defined? From the PDF of ECMA-335 , Partition II, section 22, "Metadata preserves name strings, as created by a compiler or code generator, unchanged. Essentially, it treats each string as an opaque blob. In particular, it preserves case. The CLI imposes no limit on the length of names stored in metadata and subsequently processed by the CLI". If I've read this correctly and the context is correct then there's no actual limit to the length of an identifier in the CLR. In addition to the

C#: No implict conversion from Class<Child> to Class<Base>

半世苍凉 提交于 2019-11-27 15:22:28
Following snippet wouldn't compile. With following error: Cannot implicitly convert type 'Container<ChildClass>' to 'Container<BaseClass>' class BaseClass {} class ChildClass : BaseClass {} class Container<T> where T : BaseClass {} class Program { static void Main() { // why doesn't this work? Container<BaseClass> obj = new Container<ChildClass>(); } } Is this by design? If it is, what is the reason? Marc Gravell (made wiki, in case of dups) C# (3.0) doesn't support covariance of lists etc. C# 4.0 will support limited [co|contra]variance, but still not lists . The problem is that with:

What are the benefits of such flexible “self-identifiers” in F#?

﹥>﹥吖頭↗ 提交于 2019-11-27 14:45:25
问题 While I understand self-identifiers in F#, I am puzzled as to the benefits of such flexibility. Why does F# not just support this.Blah as C# does and be done with it? I'm guessing some people use it to improve readability, but even that seems a stretch. So, what are the uses/benefits of this language feature? For the un-initiated, below is an example that defines a type-wide self identifier "self" and a method scoped identifier "this". The example is taken from the MSDN article linked above.

What is the difference between VB and VBScript

好久不见. 提交于 2019-11-27 14:21:19
问题 What is the difference between VB and VBScript? 回答1: VB is a full-fledged programming language which can be used to create compiled applications, while VBScript is a sub-set of VB and is a scripting language that can be used to run a set of commands, similar to an old-school DOS batch file. Generally, a scripting language can not be used to create a full-fledged binary application and it can not be compiled down to a executable binary file. 回答2: VBScript is a variety of VB, just as VB6, VBA,

Scoped using-directive within a struct/class declaration? [duplicate]

萝らか妹 提交于 2019-11-27 12:24:23
This question already has an answer here: Why “using namespace X;” is not allowed inside class/struct level? 3 answers I find that my C++ header files are quite hard to read (and really tedious to type) with all the fully-qualified types (which goes as deep as 4 nested namespaces). This is the question (all the answers give messy alternatives to implementing it, but that's not the question): Is there a strong reason against introducing scoped using-directive in structs and classes in the C++ language (while it's permissible to have scoped using-declaration in functions)? e.g. class Foo :

Why does Java permit escaped unicode characters in the source code?

风格不统一 提交于 2019-11-27 11:52:35
I recently learned that Unicode is permitted within Java source code not only as Unicode characters (eg. double π = Math.PI; ) but also as escaped sequences (eg. double \u03C0 = Math.PI; ). The first variant makes sense to me - it allows programmers to name variables and methods in an international language of their choice. However, I don't see any practical application of the second approach. Here are a few pieces of code to illustrate usage, tested with Java SE 6 and NetBeans 6.9.1: This code will print out 3.141592653589793 public static void main(String[] args) { double π = Math.PI; System

Algorithm that converts numeric amount into English words

三世轮回 提交于 2019-11-27 11:45:10
问题 What is the most efficient way to convert numeric amount into English words e.g. 12 to twelve 127 to one hundred twenty-seven 回答1: That didn't take long. This is an implementation written in Java. http://snippets.dzone.com/posts/show/3685 Code public class IntToEnglish { static String[] to_19 = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; static

Why does HTML5 not include a way of loading local HTML into the document?

試著忘記壹切 提交于 2019-11-27 11:09:24
问题 I've thinking about this a lot lately. Why does HTML5 not really let you load HTML into your document to break up your HTML files? It has support for nearly every other asset (images, videos, audio). Yes we have iframes , embeds , and objects but they are sandboxed and don't follow the flow of the rest of the document. I was thinking of something like: <h2>My wonderful application</h2> <include src = "leftPane.html" type = "text/html" /> <include src = "main.html" type = "text/html" />

Javascript as a functional language

有些话、适合烂在心里 提交于 2019-11-27 10:33:28
I am looking get to grips with functional programming concepts. I've used Javascript for many years for client side scripting in web applications and apart from using prototypes it was all simple DOM manipulation, input validation etc. Of late, I have often read that Javascript is one of the languages that supports functional programming. With my familiarity and experience with Javascript, my preference is to use it to learn functional programming. I expect I would be able to concentrate more on the main functional concepts and not get bogged down or distracted by a completely new syntax. So