Optional declaration of types for Variables in Structures

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Optional declaration of types for Variables in Structures

Post 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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Optional declaration of types for Variables in Structure

Post by Josh »

Nearly 10 years later :mrgreen:

Is there any reason, that types in structures don't use the standardtype if not specified?
sorry for my bad english
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Optional declaration of types for Variables in Structure

Post 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.
BERESHEIT
User avatar
nco2k
Addict
Addict
Posts: 1344
Joined: Mon Sep 15, 2003 5:55 am

Re: Optional declaration of types for Variables in Structure

Post 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. :D

>> 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. :P

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
If OSVersion() = #PB_OS_Windows_ME : End : EndIf
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Optional declaration of types for Variables in Structure

Post by netmaestro »

@nco2k: Good points all. Shows there's certainly room for discussion.
BERESHEIT
Post Reply