On Sun, 27 Jan 2013, Alexander Klenin wrote:
On Sun, Jan 27, 2013 at 4:43 AM, Sven Barth <pascaldra...@googlemail.com> wrote:
Based on the results of the "for-in-index" thread I've decided to come up
with a draft for the Tuple type which is thought by many people to be a
better alternative to "for-in-index".
Please note the following points:
* This is not the final specification for Tuples and thus open to discussion
(there are still some issues with this draft that need to be solved)
* I won't implement this feature myself (at least not in the near future) as
I have other topics on my list (most importantly generics once type helpers
are commited), so Alexander is free to give the task for implementation to
his student.
Heh, I have started to write similar in form, but different in
substance proposal, but needed some sleep,
and you have beaten me to it :)
I want to quickly summarize the most important points of my proposal
before writing it out in length:
1) In a form proposed by Sven (and, IIUC, implemented in Oxygen),
tuples are not different enough from records
(so perhaps a term like "anonymous records" is preferable, as well of
re-using keyword "record").
I agree that anonymous records might be good, but I consider them a
separate, and weaker, extension.
2) The most important differentiating features of my proposal are:
2.1) Tuples are always temporary and anonymous. You can not store a
tuple, define tuple type, of variable of tuple type.
So tuples are 100% static, compile-time feature -- no change to
RTTI, variants etc.
No.
I think that tuples should be a full fledged type, not an anonymous
one with all the restrictions that come from it. Pascal is declarative.
So, you must declare a tuple when you want one.
As for notation:
Adding the () brackets to indicate a tuple adds to clarity, simply
relying on the comma to indicate a tuple is not acceptable.
Pascal IS a verbose language. If you want unreadable: go for Javascript.
I consider Sven's proposal the one to go for.
It is more in line with what Object Pascal stands for.
The idea of a tuple is already a concession to avoid the "for in index"
monstrosity.
So let's not get carried away too much.
Michael.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel