language-design Questions
12
Solved
I can't understand why Python doesn't have a sign function. It has an abs builtin (which I consider sign's sister), but no sign.
In python 2.6 there is even a copysign function (in math), but no s...
Madid asked 31/12, 2009 at 16:56
9
The pre/post increment/decrement operator (++ and --) are pretty standard programing language syntax (for procedural and object-oriented languages, at least).
Why doesn't Ruby support them? I und...
Trek asked 7/9, 2010 at 16:25
9
Solved
I'm making a simple compiler for a simple pet language I'm creating and coming from a C background(though I'm writing it in Ruby) I wondered if a preprocessor is necessary.
What do you think? Is a...
Bathetic asked 30/5, 2010 at 21:38
8
Solved
Before I read this article, I thought access control in Ruby worked like this:
public - can be accessed by any object (e.g. Obj.new.public_method)
protected - can only be accessed from within the...
Houseyhousey asked 20/8, 2010 at 20:1
2
Solved
Someone could point out sites/books where I can find introductory documentation about the architecture of the Python VM?
I'm interested in the C version, but if there are easy-to-follow ref...
Cheesecloth asked 25/3, 2009 at 17:42
5
Solved
In Swift, when you call a function, you are required to label the arguments, unless the author of the function has explicitly allow you not to. Is there a reason for this in terms of language desig...
Raleigh asked 11/10, 2019 at 17:50
2
I really like the indentation-based syntax of Python; it makes code much more terse.
Is there a reason why Julia was not chosen to be indentation-based as well?
Please note that my intention is s...
Photochromy asked 12/2, 2016 at 12:1
3
Solved
This is an rvalue reference:
void foo(int&& a);
It does not bind to lvalues:
int i = 42;
foo(i); // error
This is a universal reference:
template<typename T>
void bar(T&a...
Semiology asked 13/1, 2013 at 11:7
3
I am learning Perl for school, and currently am learning about the use of the my keyword and about scoping in Perl. (For reference, I was looking at How should I use the "my" keyword in P...
Bivens asked 9/12, 2020 at 23:2
8
Solved
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 ...
Nomi asked 20/9, 2011 at 19:34
5
Solved
I was coding today and noticed something. If I open a new interpreter session (IDLE) and check what's defined with the dir function I get this:
$ python
>>> dir()
['__builtins__', '__doc_...
Campanulate asked 24/6, 2012 at 21:56
6
Solved
It is universally agreed that a list of n distinct symbols has n! permutations. However, when the symbols are not distinct, the most common convention, in mathematics and elsewhere, seems to be to ...
Footwork asked 30/6, 2011 at 12:3
3
Solved
If an interface specifies a property or method to return another interface, why is it not allowed for implementations of the first interface to "change" the return type into a more specific type?
...
Withoutdoors asked 29/5, 2012 at 9:44
1
Solved
Since R3.0, a for loop returns NULL (as documented):
x <- for(i in 1:3) {i+1}
x
# NULL
However, using the right-arrow assignment, it seems to returns the last value:
for(i in 1:3) {i+1} -> x...
Lookeron asked 16/8, 2020 at 3:46
3
Solved
In J. Barkley Rosser's "Logic for Mathematicians" he uses a notation to avoid too many parentheses. Although I don't know when logicians start using this notation, but I know that book first publis...
Pettifogging asked 29/8, 2013 at 12:7
3
Assume that we have an interface called Animal that have two methods called move() and makeSound().
This means we can send the messages move() and makeSound() on a variable of type Animal, and we c...
Nichols asked 15/7, 2020 at 4:19
9
Solved
This is something that has always been bugging me as a feature of C++ lambda expressions: The type of a C++ lambda expression is unique and anonymous, I simply cannot write it down. Even if I creat...
Mccaskill asked 30/7, 2020 at 12:1
7
Solved
So, I was playing around with Python while answering this question, and I discovered that this is not valid:
o = object()
o.attr = 'hello'
due to an AttributeError: 'object' object has no attribut...
Trapezius asked 7/10, 2009 at 1:7
5
I understand that constructors with one (non-default) parameter act like implicit convertors, which convert from that parameter type to the class type. However, explicit can be used to qualify any ...
Holiness asked 17/12, 2010 at 2:17
4
I am taking a class in C++ and I noticed there are only a few math operators to use.
I also noticed that C++ does not come with an exponential operator within its math library.
Why must one alwa...
Catalan asked 23/9, 2010 at 3:24
13
Solved
I am dabbling in PHP and getting my feet wet browsing SO, and feel compelled to ask a question that I've been wondering about for years:
When you write an entirely new programming language, what do...
Prepuce asked 27/10, 2009 at 8:59
5
Solved
One of the most useful features of Java 8 are the new default methods on interfaces. There are essentially two reasons (there may be others) why they have been introduced:
Providing actual default...
Sexagesimal asked 4/5, 2014 at 6:25
0
C#9 was officially announced a couple days ago, and one of the biggest additions to the language is the new "record" type using the data keyword. This new feature feels very similar to the re...
Ceremonious asked 21/5, 2020 at 16:54
1
Solved
The official documentation as well as tons of articles on the internet say that 'some string' is a primitive value, meaning that it creates a copy each time we assign it to a variable.
However, th...
Pedant asked 25/4, 2020 at 15:4
5
Solved
with Java5 we can write:
Foo[] foos = ...
for (Foo foo : foos)
or just using an Iterable in the for loop. This is very handy.
However you can't write a generic method for iterable like this:
...
Uprear asked 21/7, 2009 at 15:49
© 2022 - 2024 — McMap. All rights reserved.