language-design

PHP string type-hinting [closed]

﹥>﹥吖頭↗ 提交于 2019-12-08 15:19:14
问题 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 8 years ago . Why does PHP only support type hinting for arrays and objects? I want to use a type hint like the following: protected function

What was the reason for Swift assignment evaluation to void?

蓝咒 提交于 2019-12-08 14:56:02
问题 This question is about HISTORY (not your current opinions on the matter). While reading post about dropping support for increment/decrement operators for Swift I read such text "Swift already deviates from C in that the =, += and other assignment-like operations returns Void (for a number of reasons)". So at some time in the past developers consciously decided to evaluate assignments to void for some reasons. And I am looking for those historical (now) reasons. Pretty much as this thread is

Why is System.Net.Http.HttpMethod a class, not an enum?

▼魔方 西西 提交于 2019-12-08 14:37:55
问题 HttpStatusCode is implemented as an enum , with each possible value assigned to its corresponding HTTP status code (e.g. (int)HttpStatusCode.Ok == 200 ). However, HttpMethod is implemented as a class, with static properties to get instances for the various HTTP verbs ( HttpStatus.GET , HttpStatus.PUT etc). What is the rationale behind not implementing HttpMethod as an enum ? 回答1: From the documentation (emphasis mine): Remarks The most common usage of HttpMethod is to use one of the static

A proposal to add statemachine support to C++-like language

亡梦爱人 提交于 2019-12-08 05:40:41
问题 Lately as part of my day job I've been learning IBM Rhapsody and using it to generate code in C++ from the UML. Yesterday it struck me that it might be cool to think about adding state machine support to my C++ compiler, so I jotted a few notes here: http://ellcc.org/wiki/index.php/State_machines_and_Active_Classes My motivations for doing this are: It seems like a cool idea. The compiler could do much better semantic checking (with better error checking) than the current Rhapsody/normal C++

Why does main() require braces?

烂漫一生 提交于 2019-12-08 01:22:58
问题 I tried several variations on main() return; or main() if(); and obtained different errors, the most peculiar of which was /usr/lib/gcc/i686-linux-gnu/4.4.5/../../../../lib/crt1.o: In function `_start': (.text+0x18): undefined reference to `main' collect2: ld returned 1 exit status While it's uncommon for a program to require only one statement, why does main() make it a requirement to have braces? Could someone explain why the error was so peculiar when compiling just int main();? 回答1:

Why does math.ceil return a float? [duplicate]

好久不见. 提交于 2019-12-08 01:16:16
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Why do Python's math.ceil() and math.floor() operations return floats instead of integers? From the Python documentation of math.ceil ... math. ceil(x) Return the ceiling of x as a float, the smallest integer value greater than or equal to x . Why did they consider float to be better? After all, the ceil of a number is by definition an integer and operations requiring real numbers can easily convert from int to

Good language to implement for senior project? [closed]

做~自己de王妃 提交于 2019-12-08 01:06:05
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 years ago . Its my last semester of college and I have to do a big presentation in December. I plan on designing a small language that not only works, but also has some nifty features to go with it. Does anyone have any interesting syntax ideas or features that would impress my professors? Note: I do not want to just copy a

String/Range comparison problem

本小妞迷上赌 提交于 2019-12-07 23:27:19
问题 This make sense for things like : irb(main):001:0> ["b", "aa", "d", "dd"].sort => ["aa", "b", "d", "dd"] But doesn't for : irb(main):002:0> ("B".."AA").each{ |x| print "#{x}," } => "B".."AA" should produce : B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,=> "B".."AA" but "B" > "AA" => true Unlike "B".."BA" ("B" > "BA" => false) : irb(main):003:0> ("B".."BA").each{ |x| print "#{x}," } B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR

Why Ruby has so many redundancies?

…衆ロ難τιáo~ 提交于 2019-12-07 22:46:18
问题 I love Ruby, for past couple of years it is my language of choice. But even since I started learning it, I was repelled with the fact that so often there are several ways to do the same (or equivalent) thing. I'll give couple of examples: methods often have aliases, so you always have to bother to choose the most adequate, popular or commonly accepted alternative and and or , besides && and || - just look at how much confusion precedence difference among them causes for keyword, used almost

How-to: short-circuiting inverted ternary operator implemented in, e.g. C#? Does it matter?

﹥>﹥吖頭↗ 提交于 2019-12-07 14:41:15
问题 Suppose you are using the ternary operator, or the null coalescing operator, or nested if-else statements to choose assignment to an object. Now suppose that within the conditional statement, you have the evaluation of an expensive or volatile operation, requiring that you put the result into a temporary variable, capturing its state, so that it can be compared, and then potentially assigned. How would a language, such as C#, for consideration, implement a new logic operator to handle this