As I understand it, C#'s foreach iteration variable is immutable.
Which means I can't modify the iterator like this:
foreach (Position Location in Map)
{
//We want to fudge the position to hide the exact coordinates
Location = Location + Random(); //Compiler Error
Plot(Location);
}
I can't modify the iterator vari...
Duplicate of Learning to write a compiler and What are the best resources on designing a new language?
Can you point to what you think is the best documentation on creating a new programming language (--apart from the Dragon book, which I know of already). I am interested in both scripting language and general programming language desig...
I'm learning C and I'm reading about type equivalence.
I'm curious, does anyone have an opinion why they used structural equivalence for arrays and pointers but they used declaration equivalence for structs and unions?
Why the disparity there? What is the benefit of doing declaration equivalence with structs/unions and structural equi...
I write:
:CREATE TABLE Person (
:name CHAR(10),
:
:ssn INTEGER);
and save it to a file "a.sql" (colon represents beginning of line, is not in actual code.)
If I then run it by typing "@a" in the mysql command prompt, it will tell me that the line starting with "ssn" is not recognized as a command, and is ignored.
From what I gathe...
This is a discussion that pops a from time to time in our team. While a few quickly learned C# 3.0 features, other stick with classical techniques.
Some never use Linq, think that lambda expressions are confusing and yield is "scary". Sometimes they can hardly understand code that is written by people using all the new features. We can ...
I'm designing a high level, object oriented, garbage collected programming language, and I'm having a problem with how to do templates. I plan on creating a VM-type system, similar to .NET or JVM (but it will use LLVM under the hood). The problem is that I want to have powerful, C++-like templates, but with dynamic linking (so I could re...
If I wanted to modify or add my own extensions to C, and add them to the GCC C compiler, what would I need to do? I do not want to propose changes to the language, I want to know how the C compiler actually works.
I've had a look at the source code to GCC and it looks as if Objective-C is implemented as a simple parser that generates co...
int main()
{
int var = 0;; // Typo which compiles just fine
}
...
Consider the following code:
void f(byte x) {print("byte");}
void f(short x) {print("short");}
void f(int x) {print("int");}
void main() {
byte b1, b2;
short s1, s2;
f(b1 + b2); // byte + byte = int
f(s1 + s2); // short + short = int
}
In C++, C#, D, and Java, both function calls resolve to the "int" overloads... I a...
& has &&. | has ||. Why doesn't ^ have ^^?
I understand that it wouldn't be short-circuiting, but it would have different semantics. In C, true is really any non-zero value. Bitwise XOR is not always the same thing as logical XOR:
int a=strcmp(str1,str2);// evaluates to 1, which is "true"
int b=strcmp(str1,str3);// evaluates to 2, whic...
At the Boost library conference today, Andrei Alexandrescu author of the book Modern C++ Design and the Loki C++ library, spoke about why iterators are bad, and he had a better solution.
I tried to read the presentation slides, but could not get much out of them. I have these questions for the StackOverflow community:
Are iterators ba...
I am in the design phase of a programming language, currently thinking about the concurrency aspects. I need to figure out a consistency model, i.e. how data is handled by concurrent processes programmed in this language.
There are two important criteria:
I prefer ease-of-use over performance, as long as the consistency model allows g...
I do not understand why Java's String.substring() method is specified the way it is. I can't tell it to start at a numbered-position and return a specified number of characters; I have to compute the end position myself. And if I specify an end position beyond the end of the String, instead of just returning the rest of the String for ...
I am looking at writing a compiler and after I complete something in a "C" style I am looking at adapting it to other models. What are some syntactical constructs you would expect to see in a "natural" programming language?
The target platform for this compiler will be the CLR and I am currently using Oslo+MGrammar for the lexer/pars...
In .NET properties are supposed to be first class citizens however in the IL code property getters and setters are implemented as get_PropertyName and set_PropertyName.
class Property
{
int Value { get { return 42; } }
int get_Value() { return 6 * 9; }
void set_Value(int i) { } // Error even though Value is a read only prope...
Jeffery Palermo says 'Classic WebForms More Mature Than ASP.NET MVC': "Is Classic WebForms More Mature Than ASP.NET MVC?".
It seems to be subjective, but what I want to know is, what exactly "mature" software is?
...
The code:
function updateDashboardData() {
$.getJSON("includes/system/ajaxDataInterface.php", {recordcount:1}, function(data) {
$('.stationContainer').each(function(data) {
var bsID = $(this).attr("id");
var bsStatus = $(this).children('.stationStatus');
alert(data[bsID][0].time);
bsStatus.find('.bs_maxH...
My guess is it just made parsing easier, but I can't see exactly why.
So what does this have ...
do
{
some stuff
}
while(test);
more stuff
that's better than ...
do
{
some stuff
}
while(test)
more stuff
...
Can someone please tell me the point of the STL heap functions like make_heap? Why would anyone ever use them? Is there a practical use?
...
Imagine the following code:
class foreach_convert
{
public static void method2()
{
List<IComparable> x = new List<IComparable>();
x.Add(5);
foreach (string s in x)
{
//InvalidCastException in runtime
}
}
}
I wonder, why is this foreach behavior so... not C#-like?
What ha...