Tag Info

New answers tagged

0

If your input is serialized as XML or JSON, then you should prefer an existing XML or JSON parser. This makes it ultimately more likely that your parser will be correct, and that aids compatibility and interoperability with other systems. Note that XML is not really a language, but a system for defining new languages sharing common syntax. Writing a correct ...


4

You could use either to perform either task. The difference is what each is meant for. You can draw pictures or diagrams in Excel if you want to, but you can also draw a picture in something built for that purpose. JSON and XML libraries are designed around general purpose loading of documents, pulling parts out of them, or transforming their structures ...


1

A common use for events is in form controls. A form control can have a lot of events, a ListView for example has 79 different events. Having to create a delegate list for every event would mean that there would be a lot of those. With just a dozen controls there would be around a thousand delegate lists to create, but most of those would end up unused and ...


1

All delegates are effectively lists. The empty list is null, but you can still append to it with +=. The need to check for null before calling is very inconvenient, yes. But does not occur because they are not lists! It occurs because of how the empty list is represented. However you can avoid this by initialising the event: public event EventType MyEvent ...


3

I've also always found it kind of odd that regular functions are defined with = but lambdas with ->. Why not use the arrow for both? Or the equals for both? The equality symbol makes sense for named function definitions because it states that applying the named function to its arguments is equivalent to evaluating the right hand side of the equation. ...


1

The operator <- is used in two ways as described in Haskell operators: List comprehension generator; Single assignment operator in do-constr. List comprehensions are syntactic sugar like the expression import Data.Char (toUpper) [toUpper c | c <- s] where s :: String is a string such as "Hello". Strings in Haskell are lists of characters; the ...


-1

You could build the scripting language into the engine so that the engine can take some file formatted in your language and invent some grammars for your program to compile these script files during run-time and use a stack to push method calls, variable declarations etc. like a normal running program though I think it limits your scripting language to only ...


3

Rather than thinking of value types deriving from Object, it would be more helpful to think of storage-location types existing in an entirely separate universe from class instance types, but for every value type to have a corresponding heap-object type. A storage location of structure type simply holds a concatenation of the type's public and private ...


12

By analogy, C# is basically like a set of mechanic's tools where somebody has read that you should generally avoid pliers and adjustable wrenches, so it doesn't include adjustable wrenches at all, and the pliers are locked in a special drawer marked "unsafe", and can only be used with approval from a supervisor, after signing a disclaimer absolving your ...


6

This is from "C#: Why Do We Need Another Language?" - Gunnerson, Eric: Simplicity was an important design goal for C#. It's possible to go overboard on simplicity and language purity but purity for purity's sake is of little use to the professional programmer. We therefore tried to balance our desire to have a simple and concise language with ...


47

The reason C# (and Java and essentially every other OO language developed after C++) did not copy C++'s model in this aspect is because the way C++ does it is a horrendous mess. You correctly identified the relevant points above: struct: value type, no inheritance. class: reference type, has inheritance. Inheritance and value types (or more specifically, ...



Top 50 recent answers are included