Hello X#-Team,
This is more out of curiosity but it could also be interesting for other X# developers.
What is a tuple literal? I asume from the help file and by experimenting with it that X# supports Tuples like in C# but I have no clue how to instantiate one. The help file is mentioning that I would have to use a tuple literal.
Tuples could be an alternative when a method shall return more than one value. I would prefer tuples over ref parameters.
May be its worth mentioning in the X# language talk tomorrow.
Kind regards,
Peter
What is a tuple literal?
What is a tuple literal?
Hi Peter,
Is this really mentioned in the help? Where? I might be missing something, but I do not think this is implemented yet, but Robert may need to correct me of course! (Here or in an online session )
A tuple literal is something like this:
VAR oMyTuple := (1,"abc")
which creates a tuple with two generic parameters, an INT and a STRING and assigns their values. I think we have decided that this is the syntax that will be used in X# as well (same to c#).
Is this really mentioned in the help? Where? I might be missing something, but I do not think this is implemented yet, but Robert may need to correct me of course! (Here or in an online session )
A tuple literal is something like this:
VAR oMyTuple := (1,"abc")
which creates a tuple with two generic parameters, an INT and a STRING and assigns their values. I think we have decided that this is the syntax that will be used in X# as well (same to c#).
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
What is a tuple literal?
Hi Robert,
It was a false alarm. The System.Tuple class was only used as an example for being able to use >> for declaring generics in the section Changes in 0.2.2.
And there are several error mesages like XS8138 that states "use the tuple syntax to define tuple names" etc.
What striked me was error XS8181 - 'new' cannot be used with tuple type. Use a tuple literal expression instead.
But thats ok. It would be definitely a helpful feature in a future release.
Regards,
Peter
It was a false alarm. The System.Tuple class was only used as an example for being able to use >> for declaring generics in the section Changes in 0.2.2.
And there are several error mesages like XS8138 that states "use the tuple syntax to define tuple names" etc.
What striked me was error XS8181 - 'new' cannot be used with tuple type. Use a tuple literal expression instead.
But thats ok. It would be definitely a helpful feature in a future release.
Regards,
Peter
What is a tuple literal?
While in curiosity mode: I read that you may at max set 8 params in a tuple. And "the main purpose of tuples is to safely return multiple values from a method without resorting to out parameters".Chris wrote:VAR oMyTuple := (1,"abc")
which creates a tuple with two generic parameters, an INT and a STRING and assigns their values. I think we have decided that this is the syntax that will be used in X# as well (same to c#).
In what differs this from a crippled Vo-style array?
EDIT: did further reading, ok, there's quite more behind main difference being tuples "value type" with mutable elements - makes me wonder, what trickery they do behind the scenes to make this work...
Regards
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
Karl
(on Win8.1/64, Xide32 2.20, X#2.20.0.3)
What is a tuple literal?
Hi Karl,
I would say that the main difference is that the tuple parameters are strongly typed and the length of the parameters is known at compile time and they can even have "names". So you cannot access by mistake an element of the VO array that does not exit, or is of the wrong type (because of a mistake in the element number) etc.
I would say that the main difference is that the tuple parameters are strongly typed and the length of the parameters is known at compile time and they can even have "names". So you cannot access by mistake an element of the VO array that does not exit, or is of the wrong type (because of a mistake in the element number) etc.
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu