standards

What's the purpose of allowing duplicate property names?

只愿长相守 提交于 2019-11-27 04:24:10
I'm reading the MDN javascript reference , accordingly the following code no longer returns false : function haveES6DuplicatePropertySemantics(){ "use strict"; try { ({ prop: 1, prop: 2 }); // No error thrown, duplicate property names allowed in strict mode return true; } catch (e) { // Error thrown, duplicates prohibited in strict mode return false; } } In ECMAScript 5 strict mode code, duplicate property names were considered a SyntaxError. With the introduction of computed property names making duplication possible at runtime, ECMAScript 6 has removed this restriction. My question is, what

Giving the script tag an ID

混江龙づ霸主 提交于 2019-11-27 04:23:21
问题 I came across a scenario where giving a script element an id attribute would solve a problem easily. However, after reading about the script element at w3schools and quirksmode, it seems doing so could have some unforeseen consequences. Has anyone come across any of these issues with browsers such as Chrome, Safari, FF3 up and IE 7 up? 回答1: It's fine in all current browsers. The only browser that got <script id> wrong was Netscape 4, which we stopped caring about a long, long time ago. That

Is a header necessarily a file?

蹲街弑〆低调 提交于 2019-11-27 03:55:24
问题 T.C. left an interesting comment to my answer on this question: Why aren't include guards in c++ the default? T.C. states: There's "header" and there's "source file". "header"s don't need to be actual files. What does this mean? Perusing the standard, I see plenty of references to both "header files" and "headers". However, regarding #include , I noticed that the standard seems to make reference to "headers" and "source files ". (C++11, § 16.2) A preprocessing directive of the form # include

Is the name of a cookie case sensitive?

断了今生、忘了曾经 提交于 2019-11-27 03:43:27
问题 A HTTP Cookie consists of a name-value pair and can be set by the server using this response: HTTP/1.0 200 OK Content-type: text/html Set-Cookie: name=value Set-Cookie: name2=value2; Expires=Wed, 09 Jun 2021 10:18:14 GMT Future requests from the client will then look like this: GET /spec.html HTTP/1.1 Host: www.example.org Cookie: name=value; name2=value2 Is the name of the cookie case sensitive? For example, if my server sends a response as such: HTTP/1.0 200 OK Content-type: text/html Set

Use RecursiveDirectoryIterator to list directories and files into array?

∥☆過路亽.° 提交于 2019-11-27 03:43:10
问题 I'm having a directory with this structure : main/ |- images/ |-- file1.jpg |-- file2.jpg |-- file3.jpg |- documents/ |-- private/ |--- blahblahblah.docx |-- test.doc |-- test.xls |-- test.txt I can create a function to complete the work but the RecursiveDirectoryIterator class is much faster and less memory usage this time. How can I use RecursiveDirectoryIterator to list these directory into an array like this : array( "main/" => array( "images/" => array( "file1.jpg", "file2.jpg", "file3

Does new[] call default constructor in C++?

佐手、 提交于 2019-11-27 03:34:42
When I use new[] to create an array of my classes: int count = 10; A *arr = new A[count]; I see that it calls a default constructor of A count times. As a result arr has count initialized objects of type A . But if I use the same thing to construct an int array: int *arr2 = new int[count]; it is not initialized. All values are something like -842150451 though default constructor of int assignes its value to 0 . Why is there so different behavior? Does a default constructor not called only for built-in types? sharptooth See the accepted answer to a very similar question . When you use new[]

When can you omit the file extension in an #include directive?

不羁的心 提交于 2019-11-27 03:20:01
I'm playing around with gmock and noticed it contains this line: #include <tuple> I would have expected tuple.h . When is it okay to exclude the extension, and does it give the directive a different meaning? Michael Burr The C++ standard headers do not have a ".h" suffix. I believe the reason is that there were many, different pre-standard implementations that the standard would break. So instead of requiring that vendors change their exiting "iostream.h" (for example) header to be standards compliant (which would break their existing user's code), the standards committee decided that they'd

Which JS function-declaration syntax is correct according to the standard?

给你一囗甜甜゛ 提交于 2019-11-27 03:14:15
问题 var foo = function(){ return 1; }; if (true) { function foo(){ return 2; } } foo(); // 1 in Chrome // 2 in FF //I just want to be sure, is FF 4 not "standard" in this case? Edit: what if we have this: var foo = function(){ return 1; }; if (true) function foo(){ return 2; } foo(); // is 1 standard or is 2 standard? 回答1: The original poster's code isn't permitted by the ECMAScript standard. (ECMAScript the official name for the JavaScript language specification, for legal reasons.) It is,

If I don't odr-use a variable, can I have multiple definitions of it across translation units?

笑着哭i 提交于 2019-11-27 03:14:09
问题 The standard seems to imply that there is no restriction on the number of definitions of a variable if it is not odr-used (§3.2/3): Every program shall contain exactly one definition of every non-inline function or variable that is odr-used in that program; no diagnostic required. It does say that any variable can't be defined multiple times within a translation unit (§3.2/1): No translation unit shall contain more than one definition of any variable, function, class type, enumeration type,

Can a conversion from double to int be written in portable C

不打扰是莪最后的温柔 提交于 2019-11-27 03:09:41
问题 I need to write function like double_to_int(double val, int *err) which would covert double val to integer when it's possible; otherwise report an error (NAN/INFs/OUT_OF_RANGE). so pseudo code implementation would look like: if isnan(val): err = ERR_NAN return 0 if val < MAX_INT: err = ERR_MINUS_INF return MIN_INT if ... return (int)val There are at least two similar questions on SO: in this answer it's solved in enough clean way, though it's C++ solution - in C we do not have portable digits