Board index » delphi » Re: Generics + D2007/win32

Re: Generics + D2007/win32


2006-06-05 05:09:40 AM
delphi159
You wrote before:
Quote

Those objects are created at runtime using reflection and still is that
container strongtyped!

Hi Jeroen,
The nice thing about LINQ resp. lambda expression is, that there's not much or no Reflection
needed to do this.
Jeroen Vandezande writes:
Quote

Here is a sample it is in C# (you will need the LINQ preview to run this) :
...

The compiler will build an expression tree, that the database provider can use to build SQL
statements. The result type of the query result is completely statically typed.
In this case, the query will return an IEnumerable<XElement>which can be placed as the 2nd
parameter of the outer XElement's constructor. (named "result")
db.Customers is a class, that has some attributes on it to provide the data base provider with
all infos to map element properties to columns or what table is to be used.
Queries on in-memory data structures can be done w/o any Reflection.
However, I don't know how efficient this could be. Compared to little more "hand crafted" code.
 
 

Re: Generics + D2007/win32

"Ingvar Nilsen" <XXXX@XXXXX.COM>writes
[..]
Quote
It is Delphi, not C#.
I know.
Your point being?
FTR, I was joking with "BUG". it is not really a bug but IMO not nice code
since you are evaluating one condition (B being something) twice).
 

Re: Generics + D2007/win32

Quote
The first serious language to provide OO was Simula-67 in 1967, BTW.
Did you learn it at school Jim? :-)
 

Re: Generics + D2007/win32

Quote
But it is plain stupid to require link permissions just because you're to
lazy to write a Comparison<T>... *g*
Require link permissions?
 

Re: Generics + D2007/win32

Quote
So I am still on the fence in regards to whether Generics are a big boon
I didn't realise how much difference they made until I started to use them a
couple of months ago. You can not experience productivity gain by merely
thinking about doing things differently :-)
 

Re: Generics + D2007/win32

Quote
So ultimately it is not a _requirement_, it is a nicety for easing the
burden your work, right?
Exactly! Just like the VCL! ;-)
 

Re: Generics + D2007/win32

Quote
The first serious language to provide OO was Simula-67 in 1967, BTW. By
the time Ada came out Smalltalk and C++ had preceded it as well (among
other things)
According to wikipedia, C++ was 1983, whilst Ada was 1977-1983 (The
preliminary Ada reference manual was published in ACM SIGPLAN Notices in
June 1979).
Oliver Townshend
 

Re: Generics + D2007/win32

Quote
Did you learn it at school Jim? :-)
I was only 6 at the time :-)
My lecturers told me Simula became popular not because of OO, but because it was
the cheapest way to get an Algol compiler. At the time such compilers were into
6 figures, slightly beyond the budget of my school. (You could probably have
built the whole school for that <g>). And people complain about how much Delphi
costs now :-)
Cheers,
Jim Cooper
_____________________________________________
Jim Cooper XXXX@XXXXX.COM
Skype : jim.cooper
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
_____________________________________________
 

Re: Generics + D2007/win32

I did say when Ada came out :-) It took donkeys years for it to be defined.
Preliminary manuals don't count - the design process was still happening at that
point.
Exact chronology aside, Robert was incorrect in his assertion that Ada was the
first mainstream OO language. Ada didn't go OO until about 1995, well after many
other things. Even Delphi was out by then :-)
Cheers,
Jim Cooper
_____________________________________________
Jim Cooper XXXX@XXXXX.COM
Skype : jim.cooper
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
_____________________________________________
 

Re: Generics + D2007/win32

Peter Morris [Droopy eyes software] writes:
Quote
>But it is plain stupid to require link permissions just because you're to
>lazy to write a Comparison<T>... *g*

Require link permissions?


I wrote before:

Sorter<Person>.Sort(persons, "Surname, Lastname desc, Age");

This would generate a DynamicMethod, that can be used as a
Comparison<Person>. Runtime code gen requires special permissions, that
are above those you have in a default internet zone setting.
 

Re: Generics + D2007/win32

Alessandro Federici writes:
Quote
"Ingvar Nilsen" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM... [..]
>It is Delphi, not C#.

I know.
Your point being?
Trying to be funny
Quote
FTR, I was joking with "BUG". it is not really a bug but IMO not nice
code since you are evaluating one condition (B being something)
twice).
Yes. I know. I'd not write such code myself. The point was to
over-exaggerate, to show how readable code can be as opposed to
optimised code (less use of text).
For 98% of the code I write myself today, this unnecessary double-check
of the Boolean will not be noticeable performance-wise. It is more than
6 years since I last wrote a compression algorithm or a bitmap pixels
function, nowadays I write business logic where the molasses in the
system is the user herself, not my compiled binaries :-)
BTW, I will soon write optimised code again, some new ideas are in the
works <g>
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Generics + D2007/win32

"Ingvar Nilsen" <XXXX@XXXXX.COM>writes
[..]
Quote
Trying to be funny
Ooops! :)
[..]
Quote
Yes. I know. I'd not write such code myself. The point was to
over-exaggerate, to show how readable code can be as opposed to
optimised code (less use of text).
Gotcha, altough I think that is really subject to personal interpretation.
Cases like that, to me, fall into basic writing patters and should be picked
up as "easy and natural to read" without problems. That said, I see your
point in general and I completely agree.
--
Alessandro Federici
 

Re: Generics + D2007/win32

Quote
any feedback on that?

regards
GŁnther
"Generics"/"Templates" as any other language structures can be VERY USEFUL or NOT USEFUL AT ALL, depending if what are you doing in your program.
Altought "Generics" can be combinated with "Inheretance" and classes, I found more useful the use of a "Generic Template" with records instead of classes, in programs data structures and memory usage are heavily used.
I'm not surprise that "Generics" are widely used in C++.Altought the C/C++/C# syntax, that is going to be ported to Delphi, is somehow confusing.
And language syntax, its one of the aspects where Delphi language is better than C++ language even that both languages support similar features...
1. C++ style Delphi syntax example:
-------------------
type
TGenericList = class<TMyBaseType>(TList, ISomeInterface)
private
...
protected
FFirstNode, FLastNode: <TMyBaseType>;
end;
var
X: TGenericList<Integer>;
-------------------
I'll prefer something like:
2. New Delphi syntax example:
-------------------
type
TGenericList = class(TMyBaseType) // <- generic parameters goes here
uses
TOtherSuperClass,
TList; // <- class inheretance moved here
supports
ISomeInterface; // <- interface inheretance moved here
private
...
protected
FFirstNode, FLastNode: TMyBaseType;
end;
var
X: TGenericList(Integer); <- generic parameters goes here
-------------------
Just my 2 cents.
mramirez
 

Re: Generics + D2007/win32

Alessandro Federici writes:
Quote
That said, I see your point in general and I completely
agree.
Good! Let's have a beer!
BTW, what I have said here also is in line with a session at my last
Borcon, in 2004, where the speaker pointed out that very "clever"
written code by a very good programmer can be counter productive the
day ordinary guys must take it over. Although not everything said at
Borcon may suit everyone, this definitely is right in most cases.
To sum it up, if the intricately written code doesn't serve any other
purpose than to impress the programmer in the neighbour cubicle, it
should better be avoided!
--
Ingvar Nilsen
www.ingvarius.com
 

Re: Generics + D2007/win32

mramirez writes:
Quote
2. New Delphi syntax example:
type
TGenericList = class(TMyBaseType) // <- generic parameters goes here
uses
TOtherSuperClass,
TList; // <- class inheretance moved here
supports
ISomeInterface; // <- interface inheretance moved here
Now that is just creepy.