Page 2 of 2
Posted: Thu Nov 06, 2003 4:44 pm
by Fred
I don't see how it can be easier to understand when everyone doesn't speak the same language.. If some use InStr() instead of FindString(), what will happen when he will put his code in trick'n'tips for example ? It won't compile at all and nobody except the writer could understand it quickly. I hope you get my point

Posted: Thu Nov 06, 2003 5:36 pm
by Rings
every tip(snippet) will work if the Macro is included !
Posted: Thu Nov 06, 2003 5:58 pm
by GPI
Fred wrote:I don't see how it can be easier to understand when everyone doesn't speak the same language.. If some use InStr() instead of FindString(), what will happen when he will put his code in trick'n'tips for example ? It won't compile at all and nobody except the writer could understand it quickly. I hope you get my point

You misunderstand me a little bit.
Macros should handle like Constants and Structures/Interfaces. So it would be nice, when macros can be added in "res"-Files. So my example above can be included in the Purebasic-Default.res (also a good idea would be to replace the rgb()-function to a macro rgb=Red+Green<<8+blue<<16. Also many API-Macros, like HiWord, and so on, would be nice).
So this PB-Macros are default and all can use it. When a "Tip's and Tricks" is posted with own macros, so this macros must be included in the tip.
GPI
Posted: Thu Nov 06, 2003 8:09 pm
by Karbon
PHP started doing this crazy stuff - function aliasing. You'd have 1 function and 15 different names for it and all pointing to the same internal routine. It's REALLY confusing sometimes..
Macros sound great and if people want to stub out functions for some reason then I guess we'll have to let them - sounds like a bad idea to me though.
Posted: Thu Nov 06, 2003 8:20 pm
by Berikco
Karbon wrote:PHP started doing this crazy stuff - function aliasing. You'd have 1 function and 15 different names for it and all pointing to the same internal routine. It's REALLY confusing sometimes..
Macros sound great and if people want to stub out functions for some reason then I guess we'll have to let them - sounds like a bad idea to me though.
hey, you read my mind
I could not say it better, Karbon writes nice English.

Posted: Thu Nov 06, 2003 8:30 pm
by Karbon
I could not say it better, Karbon writes nice English.
Now
that is funny!
Doot!
Posted: Thu Nov 06, 2003 9:50 pm
by GPI
I don't think, that is is usefull, to create to many simple Warp-Macros. Findstring is a little bit special, because the default-name in other languages is INSTR().
(or maybe the compiler should give a special error, when instr() is used without declaration (something like:" INSTR() is not a function, linkedlist or array. Maybe you mean FindString(). Look in the manual".) (Only a crazy idea).
But macros can do more.
Best examples are simple Calculation, or small functions. In some cases it doesn't make sense to use function.
forexample: RGB()
At the moment RGB() call a function, calculate, return a value.
With a Macro it could be something like this:
Code: Select all
MACRO RGB(Red,Green,Blue)=Red+Green<<8+Blue<<16
debug RGB(10,20,30)
Which is identical to
And when the compiler now also calculate:
In this case, nothing must be calculated on runtime -> Programm is smaller and much faster!
And Again: My primary request for a macro are things like this, NOT many names for one function. (only for ONE double for default-names in other languages, like INSTR; In the manual this macro-warper should only meanted in the findstring()-explaination.)
GPI
Posted: Thu Nov 06, 2003 10:35 pm
by Karbon
Yea, my point too GPI. Macros are great but I think Fred is right in that people will abuse them. Regardless of potential abuse I'd like to see them included in PB!
Posted: Thu Nov 06, 2003 10:56 pm
by Fred
Wait, I never said I won't include them and macros are very useful for tons of reasons. I just put a warning on mis-used them. It will be definitely implemented in the compiler very soon.
GPI: your idea of pointing InSTR to findstring isn't bad at all. Do you have a list of 'standard' functions differently named in PB ?
Posted: Fri Nov 07, 2003 4:25 am
by PB
> every tip(snippet) will work if the Macro is included
True, but when people (or newbies) forget to include them, we'll start
having tonnes of replies here saying "Re-post with your macro defs!".
Posted: Fri Nov 07, 2003 9:34 am
by GPI
PB wrote:> every tip(snippet) will work if the Macro is included
True, but when people (or newbies) forget to include them, we'll start
having tonnes of replies here saying "Re-post with your macro defs!".
You have the same problem, when you use a userlibs in your example...
It is maybe true, that in the first time this post will come, but i think humans can learn! (OK, not all humans, but i think, that nearly all here can)
Posted: Fri Nov 07, 2003 4:47 pm
by Karbon
True that will be a problem but it's a price I'd gladly pay for macros. Seems like that's Fred's decision too so macros - here we come!
Posted: Fri Nov 07, 2003 6:12 pm
by GPI
Fred wrote:GPI: your idea of pointing InSTR to findstring isn't bad at all. Do you have a list of 'standard' functions differently named in PB ?
I found out, that InStr() has a diffrent position of the values, look here:
viewtopic.php?t=8228
other names: SPC() for Space(), RND() for Random().
But at the moment: my main-problem is THIS:
viewtopic.php?t=6947
GPI