Multiple assignment is barely OK, but I would never use it since I use automated parsing tools.
And I rarely use colons.
This is annoying, lazy and crazy:

Protected x$, y.d, z.i = "123", 123.00, 123
I agree that multiple assignment wouldn't reduce reliability.kenmo wrote:3. It would reduce reliability?
It would have zero change on the compiled executable.
The team has implemented features 100x more complex than this.
I think they can handle parsing this:Code: Select all
Define.d x, y, z = 0.0, 1.0, 2.0
Code: Select all
Define.d x=0.0, y=1.0, z=2.0
Well, the ability of procedures to return multiple values would be the main advantage of all this.kenmo wrote:PS. I think we complicated this thread by bringing up multiple returns from procedures.
THAT is a much bigger change, a fundamental change to the language.
Yes, that is ugly. But you're choosing to make it thatProtected x$, y.d, z.i = "123", 123.00, 123
That is pretty close to what is being requested here. Which is why (I like this feature request but) it's not urgent at all.Define.d x=0.0, y=1.0, z=2.0
I don't think so. These are two separate features. One a minor syntax shorthand. The other a big change to how procedures work.Well, the ability of procedures to return multiple values would be the main advantage of all this.
The possibility of multiple assignment without the possibility of procedures returning multiple values is pretty pointless.
Code: Select all
width, height = 640, 480 ; just simple shorthand, compiles the same as width=640 : height = 480
width, height = CalcSize() ; (these vars) = (unpack the multi-value result of a multi-return procedure)
I'm learning the Rust programming language recently (started 2 month ago),kenmo wrote:It makes the most sense for pairs or triples of the same type, such as screen dimensions, xyz coordinates, etc.
It's very common for coordinates and vectors to be written as (a, b, c, ...) in mathematics, engineering, pseudocode, math-focused languages... it's not unreadable or confusing if it's just a few values of the same type.
Code: Select all
fn main() {
let tup = (500, 6.4, 1); // create tuple
let (x, y, z) = tup; // destructuring the tuple
println!("The value of y is: {}", y);
}
These two features, as proposed, are obviously related.kenmo wrote:I don't think so. These are two separate features. One a minor syntax shorthand. The other a big change to how procedures work.Well, the ability of procedures to return multiple values would be the main advantage of all this.
The possibility of multiple assignment without the possibility of procedures returning multiple values is pretty pointless.
The language could implement one, the other, neither, or both.
Code: Select all
Procedure MyProcedure()
ProcedureReturn 3, 4
EndProcedure
a, b = MyProcedure()
Code: Select all
Define.d x, y, z = 0.0, 1.0, 2.0
Code: Select all
Define.d x=0.0, y=1.0, z=2.0
Yes, that is advantageous!Danilo wrote:I'm learning the Rust programming language recently (started 2 month ago),
and what you are talking about here is called Tuple's there:Code: Select all
fn main() { let tup = (500, 6.4, 1); // create tuple let (x, y, z) = tup; // destructuring the tuple println!("The value of y is: {}", y); }
Code: Select all
x, y = 100, 50
Code: Select all
Procedure test()
Static a.Point = 1,2
Debug a\x
Debug a\y
EndProcedure
+1Little John wrote:I have to correct myself. Apart from the possibility that procedures could return multiple values, and apart from the introduction of new datatypes into PureBasic, the following would be a use of multiple assignment that would really be a benefit:see this threadCode: Select all
Procedure test() Static a.Point = 1,2 Debug a\x Debug a\y EndProcedure
Code: Select all
;proposed syntax
;a new 'list expression type' is a list of comma separated values or expressions between { and }.
; strings
Define m.i = 12
Define k.s = "start" + {-3, "middle", Str(3 + 5), m}
Debug k ; outputs start-3middle812
Debug {"hello", 5, 2.0, 5 - 3, "done"} ;outputs hello52.00000002done
;arrays, single dimension only
Dim g.i(7), n.Point(3)
g(1) = {1, 3, 5, 4, 2, 0} ; set array elements 1 through 6
n.point(0) = {{9, -2}, {3 + 6, 2 * g(3)}, {-2, height}} ; set array elements 0 through 2
;NOT addressed are multidimensional array assignment.
;The further syntactic complexities that would need to be addressed include
;row order or column order and the assignments of less than a full set of elements.
;lists
NewList h.Point()
AddElement(h())
h.Point() = {6, 3} ; assign list element
:structures
Structure foo
a.s
b.f
c.i
Array d.i(5)
EndStructure
ReDim g(5) ; needs to match structure array size for next step
Define t.foo = {"real", 7.0, 2, g()} ; set structure elements