EnableExplicit
Define.i a = 12, b = 42, c$ = "test"
Debug a
Debug b
Debug c$
works without an error. I personally expected this to give a compile-time erorr because I'm declaring a string in a line of a bunch of integers, but if this was intentional it's actually convenient for functions where I declare a bunch of local ints and then just one or two strings. Hence, I'm curious if this is intentional or not?
Thanks.
Oh you're right, it works with any type, not just $. You can override the default type for Define/Protected. I didn't know that, from what I remember reading the docs years ago, the default type can't be overridden, but obviously I'm wrong. Just goes to show that it doesn't hurt to revisit things like this every once in a while.
Also I agree with you about it generally being bad practice, but there are some times when it's necessary.
Quin wrote: Sat May 03, 2025 9:34 pm
Oh you're right, it works with any type, not just $. You can override the default type for Define/Protected. I didn't know that, from what I remember reading the docs years ago, the default type can't be overridden, but obviously I'm wrong. Just goes to show that it doesn't hurt to revisit things like this every once in a while.
Also I agree with you about it generally being bad practice, but there are some times when it's necessary.
An unspecified type is one one in which there is no type specified using the period or dot notation. The default type for variables with unspecified types is '.i'. In PureBasic's past, the keyword 'Define' used by itself with the dot notation (i.e. Define.c) allowed changing the default type for all future unspecified types.
Things were later changed to limit the default to each individual use of 'Define' instead of all future ones. It was always permitted to specify something different than the default fir each individual variable declared in the Define statement.
Even so, as infratec said it may not show good form to specify groups of variables of the same type innermixed with variables of other types. Along with the possibility of specifying a variable's initial value those things are a matter of personal style and preference. Some coding styles want to combine everything in one statement while others want only variables of ore type in a Define or for things to be easily understandable at a glance when reviewing or debugging the code later and still other styles want to avoid declaring initial values in the Define statement.