Page 1 of 1
Optional declaration of types for Variables in Structures
Posted: Wed Apr 11, 2007 6:43 pm
by nco2k
hi fred,
if you dont declare a type for procedures or variables, the default type will be used, which is a good thing. so why not for variables in structures too??
Code: Select all
Structure Struct
Variable; will use the default type, if not declared otherwise. no need to write .l anymore
EndStructure
Debug SizeOf(Struct\Variable)
so everything without a type, will be declared with the default type automatically.
c ya,
nco2k
Re: Optional declaration of types for Variables in Structure
Posted: Sun Nov 20, 2016 8:33 am
by Josh
Nearly 10 years later
Is there any reason, that types in structures don't use the standardtype if not specified?
Re: Optional declaration of types for Variables in Structure
Posted: Mon Nov 21, 2016 7:30 pm
by netmaestro
So three years from now the team goes with a different default type and suddenly thousands of structures are wrong.
Also, such a thing would be very unusual on the general coding scene and unique to PureBasic - standard approaches should be adhered to where possible.
You would effectively remove the self-documenting nature of structures, leaving newer PB coders wondering just what the hell is the size of this damn thing anyway.
If you're sharp you'll have picked up on the fact that I don't think this is a good idea.
Re: Optional declaration of types for Variables in Structure
Posted: Tue Nov 22, 2016 2:27 am
by nco2k
@netmaestro
>> So three years from now the team goes with a different default type and suddenly thousands of structures are wrong.
why? Structure\Var would be the same as Structure\Var.i. one day, when we have 128bit cpus in mainstream computers, it will simply use the default data type from that architecture, so how would that break anything?
>> Also, such a thing would be very unusual on the general coding scene and unique to PureBasic - standard approaches should be adhered to where possible.
there are a lot of things that are very unusual and unique to purebasic though.
>> You would effectively remove the self-documenting nature of structures, leaving newer PB coders wondering just what the hell is the size of this damn thing anyway.
the same goes for non-structured variables, where .i is optional and somehow the world didnt end so far.
it would be like With/EndWith. some people like it, some people dont. you can use it, but you dont have to. i dont see any drawback in this request, other than "i dont like it" and thats fine. thats why it would be optional.
c ya,
nco2k
Re: Optional declaration of types for Variables in Structure
Posted: Tue Nov 22, 2016 2:54 am
by netmaestro
@nco2k: Good points all. Shows there's certainly room for discussion.