Re: [fpc-devel] Templates / Generics
On Tue, 8 Nov 2005 [EMAIL PROTECTED] wrote: Michael Van Canneyt wrote: Then they have to publish their specs real soon now. And I mean not something in a blog, but more something like documentation. We can't wait another 5 years, until they finally make up their mind. Generics are already standardized. Which standard is that ? C++ ? C# ? VB ? ECMA Standard 334 But this is a standard for C#, so totally useless for Pascal syntax-wise. Why useless? You can do exactly the same in a Pascal-styled way. We need just a minor part from the standard for the FPC compiler. You stated that we could know already what the delphi-syntax will be, if they add generics over two years. But we can't, since we don't know what 'pascal-styled' way they will choose. I would say that a pascal-way is adding the 'interface' keyword. Like in array's and such. This is already mentioned. The chances that Borland will choose another pascal-styled-syntax is huge. Besides of that, I don't find that delphi-incompatibility is a no-go-area. Especially if we (or they - the core team) are the first ones who implement this feature. And incompatibilities can be solved in Delphi mode. And in general: If we can do something better then Delphi, I choose for loosing the compatibility. Joost. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Generics Basics
Daniël Mantione wrote: Ok, lets put it blunt. It is absolutely not important to have templates at all. We've been able to develop top class code of the best kind without templates. That is true. Yet I really like the type-safety of templates. Advantages include: - you have to type less type casts - in an IDE like Lazarus you can directly use code completion (result of the previous item) - less potential bugs due to storing an object of the 'wrong' class in a container It will speed up the development process in complex applications where you need all kinds of containers all the time. And it's cool. And type casts look like hacks :) So perhaps generics can be characterized as a hype, but I think the real advatages of generics are apparent. I also like dynamic arrays. (Note that they weren't available in FPC in the past.) They make things type-safer too. People were asking for case studies in this thread. Well, I'm creating a report generator. This is more or less an example of the above mentioned 'complex software where you need all kinds of containers all the time'. For example: - I'd be very happy to replace all TLists by TListspecific types. - Also, adding caches (hash tables) would be a lot easier. Caches can for example prevent you from including the same resource (image, font) multiple times in the output file. Motto: No more type casts, only CTRL+Space :) (Ok, maybe I'm exaggerating a little bit, but don't you agree generics /are/ useful?) There's a big risk involved with templates; code bloat. Namely, with templates, you can instantiate classes without realising that you are adding tens of kilobytes of code. I.e. in C++ if you instantiate a vectorclass_a *, vectorclass_b *, vectorclass_c *, you have three implementations of the vector in your code, which are all an array of pointers! Surely Pascal's Tcollection/Tlist is much more efficient. Won't the compiler sometimes be able to handle this smarter? When the code generated for vectorTClassA and vectorTClassB is equivalent, we only need to include it once in the resulting executable, right? The only thing is we have to see when this situation occurs. Things can go wrong when for example - an overloaded method or operator is called on T - a method of T is called (but this is no problem when it concerns the same (virtual) method for the actual type parameters under consideration) - class of T is used - RTTI info is requested for T But if I am correct, this is in general not the case for container classes like vectorT (or: TListT). Templates can save typing. People are demanding them, because there is a hype. Lack of templates is seen as a deficiency of Pascal against C++. Somehow people from the well known ACM programming contest seem to see Pascal as a 'deficiency' itself: From The Rules of the 2005 ICPC Regional Contests (http://icpc.baylor.edu/icpc/regionals/About.htm): The programming languages of the regional contest will include C/C++. Additional programming languages may be used. The programming languages of the 2006 World Finals are Java, C/C++, and Pascal. Prior to the World Finals, the judges will have solved all problems in Java and C/C++, but not necessarily in Pascal. Pascal is a legacy language that is provided at the World Finals as a courtesy to the teams that are still dependent on it. Pascal will no longer be available starting with the 2007 World Finals. I think that indeed C++'s STL and Java 1.5 rule over Pascal at the moment for programming contests. Perhaps generics a nice container library using generics can help getting Pascal back (but I don't know all the considerations of the ACM World Finals' organisers!) Regards, Bram ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Generics Basics
Daniël Mantione wrote: Op Wed, 9 Nov 2005, schreef Bram Kuijvenhoven: Daniël Mantione wrote: (Ok, maybe I'm exaggerating a little bit, but don't you agree generics /are/ useful?) Certainly I do agree. However, they *will* be used to introduce the bloated programming I described. I don't think we should be happy with that. You are right, unfortunately it will be used in that way too. Won't the compiler sometimes be able to handle this smarter? When the code generated for vectorTClassA and vectorTClassB is equivalent, we only need to include it once in the resulting executable, right? The only thing is we have to see when this situation occurs. These tricks have been used in some C++ compilers with very limited success. The problem is that class_a has a different virtual methods/constructors/destructors than class b, so the code to be generated for them will be different, even though they are still just basically arrays of pointers. If a class only uses the :=, = and operators on the generic type, the code could be the same for all specializations for classes, or am I mistaking here? (The only problem is RTTI perhaps.) Is there a problem with C++ that they can't use this? Or am I just overlooking something? (that is of course not unlikely) Can you give an example please? No. Pascal is not a deficient language in any way; it has way more usefull features than C++ has. What will save it is good, very good development tools and good, very good libraries. If you think templates will save Pascal, or it will die without, that is a very naive thought. The most used language is stil standard C. Why? You are right that good libraries and development tools are *very* important for the future of Pascal. Generics support is not the most important thing for that. (Though I think it is at least quite important) And you are right, Pascal definitely has some advantages over C++. For algorithm programming contests, perhaps XML or compression libraries are not so important. Generics (and a corresponding container library) can help a lot there though. On the other hand, use for programming contests doesn't measure to what extent a language is 'alive' - e.g. PHP is a popular language, but not used at the ACM contests (ok, it is a scripting language, but still). BTW I'd like to help writing a container library, but plan to wait for Generics support first. Bram ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Generics Basics
Op Wed, 9 Nov 2005, schreef Bram Kuijvenhoven: These tricks have been used in some C++ compilers with very limited success. The problem is that class_a has a different virtual methods/constructors/destructors than class b, so the code to be generated for them will be different, even though they are still just basically arrays of pointers. If a class only uses the :=, = and operators on the generic type, the code could be the same for all specializations for classes, or am I mistaking here? (The only problem is RTTI perhaps.) Is there a problem with C++ that they can't use this? Or am I just overlooking something? (that is of course not unlikely) Can you give an example please? In C++ an assignment involves calling a copy constructor. If a type has no copy constructor (i.e. a struct), believe it or not, it gets a constructor automatically. It is also possible to get automatic destructors. Don't know how, but it happens. This means that all template methods that use assignments or new, destroy, etc. need a call to a different constructor/destructor, depending on the template type. No. Pascal is not a deficient language in any way; it has way more usefull features than C++ has. What will save it is good, very good development tools and good, very good libraries. If you think templates will save Pascal, or it will die without, that is a very naive thought. The most used language is stil standard C. Why? You are right that good libraries and development tools are *very* important for the future of Pascal. Generics support is not the most important thing for that. (Though I think it is at least quite important) And you are right, Pascal definitely has some advantages over C++. For algorithm programming contests, perhaps XML or compression libraries are not so important. Generics (and a corresponding container library) can help a lot there though. On the other hand, use for programming contests doesn't measure to what extent a language is 'alive' - e.g. PHP is a popular language, but not used at the ACM contests (ok, it is a scripting language, but still). Important for a programming contest is the ability to build datastructures, i.e. building trees and graphs in PHP can be a challenge. Performance is bad. That is why PHP is not used. Having some data structures readily available is an advantage, and this advantage can be implemented with templates. However, coding in Pascal isn't bad at all. First, it's fast. Standard input is way more simple that Java for example. Usage of sets can save a load of memory compares to C programmers that use arrays of bytes, not to mention that memory constraint are a real punishment for Java programmers. BTW I'd like to help writing a container library, but plan to wait for Generics support first. It can take a while until the development version is stabilized. Not sure if that is a good idea. Enjoy FPC's new language features in the meantime; they aren't used a lot unfortunately :( Daniël___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] Inline
Noticed that Procedure fpc_AnsiStr_Decr_Ref (Var S : Pointer); is not inlined. Tried it and it seems to work. P Davidson http://CoraxNetworks.com ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Templates / Generics; Vote
[EMAIL PROTECTED] wrote: Delphi.Net2.0 is using Chrome is using C# is using C/C++ is using Why should FPC use generics ??? Because it is more readable. is an operator and therefore should not be used as bracket in generic definition. That b.s. will break the Delphi code base! What is b.s.? If it means (somehow) syntax for generics, then this argument is easy to refute: 1. There is no native (i.e. win32) Delphi code base (yet) that uses generics, so that won't be broken. 2. Delphi.Net 2.0 code is not yet released and exact syntax is therefore subject to change, so it cannot be used as example. Vincent. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] CrossFPC article (in german)
http://www.toolbox-mag.de/data/tx62005artikel1.pdf ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Templates / Generics; Vote
[EMAIL PROTECTED] wrote: Delphi.Net2.0 is using Chrome is using C# is using C/C++ is using Why should FPC use generics ??? Why should FPC be Pascal-ish? Is that your question? :-) mm ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Templates / Generics; Vote
On Wed, 09 Nov 2005 19:16:46 +0100 [EMAIL PROTECTED] wrote: Delphi.Net2.0 is using Uncertain. Chrome is using Not inventive enough to come up with something of their own and simply following .NET C# syntax. C# is using Duh. It's a C derivative. C/C++ is using Duh, they like short symbols. Why should FPC use generics ??? Because we like it? That b.s. will break the Delphi code base! Who the *hell* are you with that tone?! Come on, we're just discussing pros and cons, who knows what the final syntax will be? Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
[fpc-devel] License of RTL
Some files of RTL core are under the full GPL license, not a LGPL. Is it a new politics of FPC? There are some files which are necessary. As example, rtl/linux/i386/syscallh.inc, etc. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Templates / Generics; Vote
Micha Nelissen wrote: Come on, we're just discussing pros and cons, who knows what the final syntax will be? Ok, to prove this, I've added some ugly examples posted on IRC in the wiki. Look at the bottom of generic keyword syntax examples. Anyone an idea ? :-) Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Templates / Generics; Vote
Pro reason will probably be: compatibility. Pro generic will probably be: more Pascal-alike/readability. Delphi.Net2.0 is using Chrome is using C# is using C/C++ is using Why should FPC use generics ??? Why not if it is better readable and in the parser? None of the template using code in these will port to FPC regardless. People that can't memorise this difference shouldn't be using generics at all :) ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel
Re: [fpc-devel] Templates / Generics; Vote
Micha Nelissen wrote: Ok, to prove this, I've added some ugly examples posted on IRC in the wiki. Look at the bottom of generic keyword syntax examples. Anyone an idea ? :-) Ok I've posted under Suggestion 2 a slightly modified syntax. Let me know what you think. Micha ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel