Originally Posted by
peter
It is funny that the innuendo on the word 'weaker' implies less than.
Sorry, that "weaker" is simply the official naming. Since the 60s there's been debates raging on which is better: weak/strong typing. The C-like languages (actualy a misnomer, it should rather be the Fortran-like languages: Ada/Basic/Pascal/C/C++/Java/C#/VB/etc.) tend to use strong typing (a few grey areas but only in special cases). If it's better depends on situation: if you need to type-check a lot, then having the compiler do it for you is obviously more efficient. If you want to mix types in a collection, then weak typing makes it a lot easier to work with.
My view of this is weak leaves types up to the programmer to manage. Strong restricts the programmer into what types to use where. There can be good and bad points on both sides.
Originally Posted by
peter
I have been playing around with Lists, Arrays, Structures, but nothing has the versatility of a LISP List.
That's exactly true. One of the difficult portions to accomplish using C#/VB.Net. The only true way to get around this is to use object inheritance in a strong typed language. If you want the closest matching structure to a Lisp-list from the default DotNet libs, then you might use something like:
Code:
System.Collections.Generic.LinkedList<object>
But then due to the strong typing you have to check what actual type each of those items are and then type-cast accordingly. This is where strong typing makes the programmer's life difficult.
Lately the var type's been added to C#, but restricted to only be usable inside a method as a local variable - you can't use it as a type for a datastructure.
If you really want to use a Lisp-like list, then you could use IronScheme's implementation of the Cons type: https://github.com/leppie/IronScheme...untime/Cons.cs But IMO it's not too much different to use than a LinkedList of objects, in fact it IS a linked list of objects, just implemented using CAR/CDR.
Even IronPython uses strong typing too (as does IronRuby), though they use dynamic typing (a sub-set of weak typing, unlike C#/VB/F#, but a lot like Lisp does) - i.e. a variable can contain anything, but it doesn't adjust to accommodate the use of a specific type inherently. I.e. the language itself doesn't add implied type casts for everything like Pearl/PHP/JavaScript does. Even Lisp is not fully weakly typed, e.g. you can't add a string containing numerals to an int and expect a result containing either a concatenated string or an int containing a total. That's actually why weak typing isn't fully implemented (in most cases) - there are usually ambiguity when 2 different types are combined, so either the language makes a call on which will always be used (like Pearl/PHP/JS does) or the language disallows such and makes the programmer specifically cast/parse to accommodate (like Lisp/Python/Ruby does). E.g. say you wanted to rather just append the integer's digits to the end of a string in Pearl instead of using its default of converting the string to an int and summing the 2 then returning a new int ... how would you do that?
In C# you can make an implied casting operator between an object and a list of objects (similar to the example I showed before between doubles and strings). You'd probably do one to an IEnumerable/ICollection type though after checking if the object actually contains such - else "throw an exception" (which is exactly what Lisp does, try to run nth on an atom value and see what happens).