I'm interesting in some design choices of C# language.
There is a rule in C# spec that allows to use method groups as the expressions of is operator:
class Foo {
static void Main() { if (Main is Foo) Main(); }
}
Condition above is always false, as the specification says:
7.10.10 The is operator
• If E is a method group or ...
Most binary arithmetic operators are left-associative in most
programming languages. However, most compilers are free to evaluate
the operands of a binary operator in either order. Are these
statements contradictory? Why or why not?
EDIT
This comes from the book I am reading "Programming Language Pragmatics" Chapter 6, Exercise 6.1, I ...
I came from a mostly C/C++ background before I began using C#. One of the things I did with my first project in C# was make a class like this
class Element{
public uint Size;
public ulong BigThing;
}
I was then mortified by the fact that this requires casting:
int x=MyElement.Size;
as does
int x=5;
uint total=MyElement.Size+x;...
The following declaration in C:
int* a, b;
will declare a as type int* and b as type int. I'm well aware of this trap, but what I want to know is why it works this way. Why doesn't it also declare b as int*, as most people would intuitively expect? In other words, why does * apply to the variable name, rather than the type?
Sure you ...
It looks strange especially for C++ developers. In C++ we used to mark parameter as const in order to be sure that its state will not be changed in method. There are also other C++ specific reasons also like passing const ref in order to pass by ref and be sure that state will not be changed. But why we can't mark as const method paramet...
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 ...
Javascript is a powerful language but I can't get it why there are several ways to OOP, don't you think that it is adding a frontline barrier for new developers which have to work harder to master the libraries?
...
Guys... Girls, I'm working on a project which I think could be enhanced by implementing a Domain Specific Language for defining a set of rules and/or conditions for some type of work-flow.
I want to get a firm grasp on the subject, fundamentals, best practices, etc. specially how to implement them somehow with Java.
What do you sugges...
Hey All,
I'm writing a little scripting language just for a bit of fun and the learning of the codes :P
I would just like your opinions/suggestions. I have an idea but I don't want to include something that people are going to want to spit on. I plan on making this language open source once, soon.
Does anybody think that it would be c...
Why does PHP require you to explicitly write $this? I would understand if you had to use $this here:
function foo($bar) {
$this->bar = $bar;
}
But you must write it explicitly in verbose code that looks like this:
$this->var3 = globalFun($this->var, $this->var2[$this->anotherVar], $this->method());
as opposed to:
$var3 = globaF...
When you are designing a new programming language, or comparing existing programming languages, what types of code examples should you write? They should:
emphasize the important features of the language(s)
take considerations into important/common features
allow learning by examples.
Also, list some simple algorithms that worth to b...
In Java there are a bunch of methods that all have to do with manipulating Strings.
The simplest example is the String.split("something") method.
Now the actual definition of many of those methods is that they all take a regular expression as their input parameter(s). Which makes then all very powerful building blocks.
Now there are tw...
If you are forced to simplify C# keywords that can be used for looping, choose only one you want to preserve.
for
do-while
while
goto-label-if
foreach
Is there any performance consideration regarding your decision?
Actually I don't know the internal mechanism of them, so here I want interview those of you know the details. However...
Paul Graham writes:
For example, types seem to be an
inexhaustible source of research
papers, despite the fact that static
typing seems to preclude true macros--
without which, in my opinion, no
language is worth using.
What's the big deal with macros? I haven't spent a whole lot of time with them, but from the legacy C/C...
Inspired by this SO question:
Why doesn't C# have a keyword for non-virtual calling convention?
EDIT: I mean "why is there no keyword for non-virtual IL calls, given that the C# compiler always uses IL virtual calls by default"?
...
I faced with a sample code in Java and it brought me a question.
Java sample code is:
...
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary) Native.loadLibrary((Platform.isWindows() ? "msvcrt" : "c"), CLibrary.class);
void printf(String format, Object... args);
}
public static void main(String[] args) t...
I once read that having nullable types is an absolute evil. I believe it was in an article written by the very person who created them(in Ada?) I believe this is the article
Anyway, so what if by default a language like C# used non-nullable types? How would you replace some of the common idioms in C# or Ruby or any other common language...
I've seen Scala using both interchangeably, but I don't know when to use one or the other.
Is there a convention?
For instance these are equivalent
"hello" toString
and
"hello".toString()
And they can even be mixed
"hello".toString() length
What's the convention?
...
Some people say that every programming language has its "complexity budget" which it can use to accomplish its purpose. But if the complexity budget is depleted, every minor change becomes increasingly complicated and hard to implement in a backward-compatible way.
After reading the current provisional syntax for Lambda (≙ Lambda expres...
I begin with an otherwise well formed (and well working) grammar for a language. Variables,
binary operators, function calls, lists, loops, conditionals, etc. To this grammar I'd like to add what I'm calling the object construct:
object
: object_name ARROW more_objects
;
more_objects
: object_name
| object_name ARROW more_ob...