[Implemented] A few VB touches....

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Yogi Yang
Enthusiast
Enthusiast
Posts: 107
Joined: Sun Dec 11, 2005 2:19 pm

[Implemented] A few VB touches....

Post by Yogi Yang »

Like in Vb there should be provision for forcing a developer to first declare variables and then use them if the developer wishes. I would go for a parameter like - Option Explicit (as implemented in VB) so if developer needs to force himself to declare each and every variables he will put Option Explicit at the top of the code module.

There should be provision for passing parameters to a function/routine either - ByVal or ByRef this would really help esp. ByRef as in VB.

A large set for Functions for manuplating Strings like those in VB and more, Arrays & such collections features as implemented in VB.NET would be great to have in PB.

I know there are many workarounds in form of UserLibs but it would be nice to have these features built right in PB ranther than in third party UserLib. Generally developers of UserLibs are hobbies and may loose their interest in a particular UserLib and many discontinue developing it or ditch it all togather. And over a period of time these UserLibs may become incompatible with newer versions of PB.

What do other developers think about this
maw

Re: A few VB touches....

Post by maw »

Yogi Yang wrote:Like in Vb there should be provision for forcing a developer to first declare variables and then use them if the developer wishes. I would go for a parameter like - Option Explicit (as implemented in VB) so if developer needs to force himself to declare each and every variables he will put Option Explicit at the top of the code module.
In PB4 you now have EnableExplicit which does just that.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: A few VB touches....

Post by PB »

> there should be provision for forcing a developer to first declare variables

Use the EnableExplicit command.

> A large set for Functions for manuplating Strings

Like what? There are many string commands at the moment.
Or maybe I could write a macro for... ah, forget it. ;)
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: A few VB touches....

Post by traumatic »

PB wrote:Or maybe I could write a macro for... ah, forget it. ;)
:lol:
Good programmers don't comment their code. It was hard to write, should be hard to read.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

:D
@}--`--,-- A rose by any other name ..
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Re: A few VB touches....

Post by Kale »

Yogi Yang wrote:Like in Vb there should be provision for forcing a developer to first declare variables and then use them if the developer wishes. I would go for a parameter like - Option Explicit (as implemented in VB) so if developer needs to force himself to declare each and every variables he will put Option Explicit at the top of the code module.

There should be provision for passing parameters to a function/routine either - ByVal or ByRef this would really help esp. ByRef as in VB.

A large set for Functions for manuplating Strings like those in VB and more, Arrays & such collections features as implemented in VB.NET would be great to have in PB.

I know there are many workarounds in form of UserLibs but it would be nice to have these features built right in PB ranther than in third party UserLib. Generally developers of UserLibs are hobbies and may loose their interest in a particular UserLib and many discontinue developing it or ditch it all togather. And over a period of time these UserLibs may become incompatible with newer versions of PB.

What do other developers think about this
Purebasic does not need to be like any language IMHO! and all these things are implemented in V4.0 anyway.
--Kale

Image
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: A few VB touches....

Post by traumatic »

Yogi Yang wrote:There should be provision for passing parameters to a function/routine either - ByVal or ByRef this would really help esp. ByRef as in VB.
I second that
Good programmers don't comment their code. It was hard to write, should be hard to read.
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post by Nik »

Pointers are the pure Way^^ andthis can be taken literal and philosophically
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

Nik wrote:Pointers are the pure Way^^ andthis can be taken literal and philosophically
Agreed! Never having used VB i dont get why you would need ByVal or ByRef when you can use pointers. Am i missing something here. :?:
--Kale

Image
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Kale wrote:Am i missing something here. :?:
Don't know. :)



This is not a matter of VB (other languages allow you to chose how
to pass parameters as well **), it's a matter of design/concept/needs.


Using ByVal, only a copy of the parameter will be used inside the
procedure. This prevents the procedure from changing the passed
data. Values are being preserved.

(Using a copy obviously allocates memory when calling the procedure
and comes with a certain performance hit of course.)



With ByRef (PB's way) on the other hand you're passing a memory
location, thus allowing the procedure to change the passed data,
which may not always be wanted.





** think of C for example:

Code: Select all

void ByVal(yourStruct var);
void ByRef(yourStruct& var);
[/size]
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

pb's way is byval, not byref
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

blueznl wrote:pb's way is byval, not byref
?

Code: Select all

Procedure AreYouSure(*var.POINT)
  *var\x = 10
EndProcedure
 
AreYouSure(myVar.POINT) 
Debug myVar\x
Good programmers don't comment their code. It was hard to write, should be hard to read.
Bonne_den_kule
Addict
Addict
Posts: 841
Joined: Mon Jun 07, 2004 7:10 pm

Post by Bonne_den_kule »

PB 4.00 has prototypes which can handle pointers like byref in VB.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

you PASS the VALUE of the POINTER

that's byval in my book :-) (a thin book, admitted, but still)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

We must have different books then.
Good programmers don't comment their code. It was hard to write, should be hard to read.
Post Reply