Forum
DEFAULT Type - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Wishlist (https://www.boriel.com/forum/forumdisplay.php?fid=14)
+---- Thread: DEFAULT Type (/showthread.php?tid=495)



DEFAULT Type - LCD - 09-04-2012

How about a addition?
Usually the variable type is allways float by default, and you can change the type of variables using DIM variable AS Type. Would it be possible to change the default type from float to different type (except String), using DEFAULT directive. E.g. DEFAULT UINTEGER will change the type of all uninitialised variables from Float to Uinteger.


Re: DEFAULT Type - boriel - 09-04-2012

Hmm. I see.
But instead of the classical DEFAULT a-z or the like, just declare someting like:
Code:
DEFAULT As Integer
' Or
DIM DEFAULT As Integer
' OR
DIM As Integer By Default
Or something like that? Anyway, I think it's a good idea (I created the compiler with a default type in mind, and can be easily set up Wink)


Re: DEFAULT Type - LCD - 09-04-2012

boriel Wrote:Hmm. I see.
But instead of the classical DEFAULT a-z or the like, just declare someting like:
Code:
DEFAULT As Integer
' Or
DIM DEFAULT As Integer
' OR
DIM As Integer By Default
Or something like that? Anyway, I think it's a good idea (I created the compiler with a default type in mind, and can be easily set up Wink)
Excellent!
I think, the best would be
Code:
DEFAULT As Integer



Re: DEFAULT Type - britlion - 09-04-2012

Default what?

:-)

I think logically it has to say DIM in it - something like DEFAULT DIM uinteger or DIM DEFAULT uinteger

Otherwise, it might be unclear what you are defaulting? (Okay, when we know the language, it's obvious - but it's just a thought that "default as uinteger" doesn't actually say, which feels like poor logic)


Re: DEFAULT Type - boriel - 09-04-2012

britlion Wrote:Default what?

:-)

I think logically it has to say DIM in it - something like DEFAULT DIM uinteger or DIM DEFAULT uinteger

Otherwise, it might be unclear what you are defaulting? (Okay, when we know the language, it's obvious - but it's just a thought that "default as uinteger" doesn't actually say, which feels like poor logic)
This is why I proposed
Code:
DIM As Uinteger By DEFAULT



Re: DEFAULT Type - britlion - 09-04-2012

Yes - I was pretty much supporting you, there, Boriel :-)


Re: DEFAULT Type - LCD - 09-04-2012

Then you could also make
Code:
DIM AS Uinteger
with no variable name...
or as boriel said,
Code:
DIM DEFAULT AS Uinteger
DEFAULT will be a reserved word anyway.