Observations on new features

Everything else that doesn't fall into one of the other PB categories.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Observations on new features

Post by dmoc »

After seeing Danilo's post on the German site (re COM)...

(PS: These comments are not specifically aimed at or about Danilo's code)

- He is redefining a constant in a procedure. I thought this would not be possible anymore?

- Given that COM could be used a lot, code would be much cleaner if the pointer "*" notation was dropped or, to pacify the hoards now gasping, it was made optional. Remember when considering this suggestion that for all other var types, the type can be defined and then effectively forgotton, ie, it's up to you as the programmer to remember what you are dealing with. The fact that a pointer var is followed by "\" should be enough to identify it (in most situations, eg, spot the redundancy in "*this_data\") and I would further suggest that "^" could be used (or anything else, I don't care) when referring to the pointer itself rather than what it points to. I feel crosshairs homing in on me :D but please give it some serious thought because one of BASIC's strength's is it's readability.

- If you are going to be sharing code (esp COM related) consider adopting one of the more common notations around. (again note this is a general comment, not a critiscism aimed at Danilo)

- "Partial Includes" anyone? Look at Danilo's sTEST2 structure. I think this is going to crop up frequently. It would be good to have something like "StructureInclude" (like "StructureUnion") to plug it in automatically. This idea maybe needs more thought but it at least could help keep things consistent if the "inherited" class (in the loosest sense) is modified. Your thoughts? Maybe this adds to the case for a flexible pre-compiler as discussed recently.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

> - He is redefining a constant in a procedure. I thought this
> would not be possible anymore?

i hope it stays possible, i always put all my constants and hide them in a procedure whatever_init()... unless you limit it to REdefinition...
freak
PureBasic Team
PureBasic Team
Posts: 5947
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

> - He is redefining a constant in a procedure. I thought this
> would not be possible anymore?

If the second definition has the same value, it is allowed, only if you thy to
change the value, you get an error.

Timo
quidquid Latine dictum sit altum videtur
Amiga5k
Enthusiast
Enthusiast
Posts: 329
Joined: Fri Apr 25, 2003 8:57 pm

Post by Amiga5k »

I think they have a name for a constant that can be redefined: a variable! :lol:

Constants are supposed to be just that: Constant

If you want 'local' constants that can be used in a procedure, fine, but I don't see the point since this local constant could just as easily be made global - thus, a normal constant.

Luckily, I just noticed in 3.8 that constants are back to normal :D and enumeration is here! Yay!

Russell
*** Diapers and politicians need to be changed...for the same reason! ***
*** Make every vote equal: Abolish the Electoral College ***
*** www.au.org ***
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Observations on new features

Post by Fred »

dmoc wrote:After seeing Danilo's post on the German site (re COM)...
- Given that COM could be used a lot, code would be much cleaner if the pointer "*" notation was dropped or, to pacify the hoards now gasping, it was made optional. Remember when considering this suggestion that for all other var types, the type can be defined and then effectively forgotton, ie, it's up to you as the programmer to remember what you are dealing with. The fact that a pointer var is followed by "" should be enough to identify it (in most situations, eg, spot the redundancy in "*this_data") and I would further suggest that "^" could be used (or anything else, I don't care) when referring to the pointer itself rather than what it points to. I feel crosshairs homing in on me :D but please give it some serious thought because one of BASIC's strength's is it's readability.

- If you are going to be sharing code (esp COM related) consider adopting one of the more common notations around. (again note this is a general comment, not a critiscism aimed at Danilo)

- "Partial Includes" anyone? Look at Danilo's sTEST2 structure. I think this is going to crop up frequently. It would be good to have something like "StructureInclude" (like "StructureUnion") to plug it in automatically. This idea maybe needs more thought but it at least could help keep things consistent if the "inherited" class (in the loosest sense) is modified. Your thoughts? Maybe this adds to the case for a flexible pre-compiler as discussed recently.
You aren't forced to use the '*' with interface at all. Stuff.IDirectDraw will do it too, so feel free to use it :).

About partial structure, it's planned to add the 'Extends' keyword support to structure.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Hi Fred, thanks for the info. For some time now I have suspected that a lot of my code contains work-arounds for various "features" in past PB releases. Maybe when you have some free time (if ever) it would be good to do some short topics titled "Did you know you can now do..." or some such thing? Everyone's code could benefit from a bit of a spring clean, eh, winter clean :?
Fred
Administrator
Administrator
Posts: 18350
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Sounds like a good idea. Where to start ? May be with all your workarounds, so I can comment it and then make a final document, which could even be included in the help.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

This is why I said "suspect" :D An example that pops to mind would be getting the address of a sub-structure, eg, at the mo I have a lot of...

vc.l = @myobj\colour\r

...which is iffy at best (what if "r" was no longer the first element). So maybe I can now do...

vc.l = @myobj\colour

...and yes! A quick check and the correct address is returned. So how many other fixes, improvements and shortcuts are hidden in there. I am reminded of a certain person on tv recently saying "There are things we know that we know, there are things that we know that we don't know, there are things that we don't know that we know and then there are the things that we don't know that, eh, we don't know". Drugs are bad for you, ohkaaay :twisted:

Edit: And another (if only I knew!)... logic prevails, yahooooo!...

Code: Select all

n = 1
m = 0

r1 = n = 1
r2 = m = 0

Debug r1
Debug r2
...now everyones code can look less cryptic. more, more, more.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

Very strange!!! 8O

My last posting in this thread contained this (simple) code...

Code: Select all

n = 1 
m = 0 

r1 = n = 1 
r2 = m = 0 

Debug r1 
Debug r2 
...I was happy because both r1 and r2 computed to 1 (or "true"). This is no longer the case!!! I'm not sure at the time of posting if I had applied the 6th Oct update or not but I definately have in the mean time. The only other thing I have upgraded is jaPBe. Was I just hallucinating or what?
User avatar
einander
Enthusiast
Enthusiast
Posts: 744
Joined: Thu Jun 26, 2003 2:09 am
Location: Spain (Galicia)

Post by einander »

I'm confused with this:

Code: Select all

Debug n = 10 ;False : must be 0 ? 
Debug m = 0  ;True : must  be 1 ?  
May be this is for the wishlist :roll:
Post Reply