Why not '\' instead of '::' for modules?

Everything else that doesn't fall into one of the other PB categories.
Justin
Addict
Addict
Posts: 948
Joined: Sat Apr 26, 2003 2:49 pm

Why not '\' instead of '::' for modules?

Post by Justin »

I've been trying modules and the current syntax looks pretty ugly in my opinion, the '\' operator is what PB uses for these things, why not use it?

In many cases the full name is requied
MyMod::DoSomething() ;ugly
MyMod\DoSomething() ;nice and PB like

And how about 'Using' instead of 'UseModule'? Like in C#, and make it valid only in the current file?
It's EndUsing really necessary?
User avatar
STARGÅTE
Addict
Addict
Posts: 2226
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Why not '\' instead of '::' for modules?

Post by STARGÅTE »

\ is for structures:

Code: Select all

Prototype Test()

Procedure Example()
	Debug "Hallo World!"
EndProcedure

Structure Example
	MyFunction.Test
EndStructure

Define Test.Example\MyFunction = @Example()

Test\MyFunction()
in this case you can create "modules" without module ^^
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
skywalk
Addict
Addict
Posts: 4210
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: Why not '\' instead of '::' for modules?

Post by skywalk »

Yes, I use prototypes in structures now.
Why does that prevent '\' as a module indicator? (Is there a name conflict with Structure & Module?)
Pros:
enables autocomplete with 1 keystroke instead of 2 '::'.
less clutter
Cons:
Module vs Structure does not jump out to reader.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: Why not '\' instead of '::' for modules?

Post by luis »

I've been trying modules and the current syntax looks pretty ugly in my opinion, the '\' operator is what PB uses for these things, why not use it?
Structures and see also the help for "interfaces".
And how about 'Using' instead of 'UseModule'?
Academically discussed here, maybe you can tag along -> http://www.purebasic.fr/english/viewtop ... =3&t=55196
It's EndUsing really necessary?
UnuseModule ? It can be if you want to use UseModule instead of full qualifiers "::".

Code: Select all

DeclareModule x
 Declare foo()
EndDeclareModule

Module x
 Procedure foo()
  Debug "x"
 EndProcedure
EndModule

DeclareModule y
 Declare foo()
EndDeclareModule

Module y
 Procedure foo()
  Debug "y"
 EndProcedure
EndModule

UseModule x
foo()

UnuseModule x ; remove this and it doesn't work anymore

UseModule y
foo()

"Have you tried turning it off and on again ?"
A little PureBasic review
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Why not '\' instead of '::' for modules?

Post by uwekel »

I totally agree with this request.
+1 for \ instead of ::
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User_Russian
Addict
Addict
Posts: 1516
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Why not '\' instead of '::' for modules?

Post by User_Russian »

Disagree!
Let it stay as it is now (using ::).
Using \ can cause a conflict with the structures and interfaces! Why do it?
And also, will be confusing. You will need to think a module, structure, or interface.
Separator :: uniquely specify that this module.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Why not '\' instead of '::' for modules?

Post by uwekel »

But at least a single character would be nice.
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: Why not '\' instead of '::' for modules?

Post by Danilo »

User_Russian wrote:Using \ can cause a conflict with the structures and interfaces! Why do it?
And also, will be confusing. You will need to think a module, structure, or interface.
There are languages that use the point '.' for everything. Structures, Namespaces, Interfaces, Classes, ...
So PB could also use the backslash for everything. If there is a name conflict, the compiler could say so.
Using the same name for structures, interfaces, modules could just be disabled and is not recommended
anyway. You can't use the same name for structures and interfaces anyway (and it is not a problem...):

Code: Select all

Interface theName
EndInterface

Structure theName
EndStructure

DeclareModule theName
EndDeclareModule
...so it could be the same for Modules to prevent name conflicts... and use the backslash for access to all members of structures/interfaces/modules!? More BASIC style, and more PB style. ;)

IMHO it wouldn't be a big problem to not use the same names for modules and structures/interfaces.
User_Russian
Addict
Addict
Posts: 1516
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Why not '\' instead of '::' for modules?

Post by User_Russian »

uwekel wrote:But at least a single character would be nice.
Really so hard to double-press the button?
Danilo wrote:There are languages that use the point '.' for everything. Structures, Namespaces, Interfaces, Classes
So what?
You forget that in many languages, for classes, and name space, it is used by two colons (::).
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: Why not '\' instead of '::' for modules?

Post by Shield »

I'd also be in favor of '\' but it's not going to change anyway.
I'm just happy they chose '::' and not '_' which was announced...
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Re: Why not '\' instead of '::' for modules?

Post by blueznl »

Brrrr.... I'm an oldie and have been using things like busbar_n and busbar_nr for ages... I would have to rewrite ALL my code if they would have used _ !!!!!

Even though I can see the charm of \ I can live with ::
( 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... )
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Why not '\' instead of '::' for modules?

Post by uwekel »

User_Russian wrote:Really so hard to double-press the button?
Let us imagine that 25000 programmers have 5000 occurrences only, we would save 125 million keystrokes all together ;-)
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User avatar
Demivec
Addict
Addict
Posts: 4258
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Why not '\' instead of '::' for modules?

Post by Demivec »

uwekel wrote:
User_Russian wrote:Really so hard to double-press the button?
Let us imagine that 25000 programmers have 5000 occurrences only, we would save 125 million keystrokes all together ;-)
If you imagine harder, doing search and replace would eliminate 124925000 of those keystrokes. :D
Last edited by Demivec on Mon Jul 15, 2013 8:21 pm, edited 1 time in total.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: Why not '\' instead of '::' for modules?

Post by freak »

If one character more (or one declare for that matter) is too much for you then you haven't understood the purpose of modules. Modules are about writing better (better readable, better testable, better maintainable, etc) code, not shorter code.
quidquid Latine dictum sit altum videtur
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

Re: Why not '\' instead of '::' for modules?

Post by uwekel »

The sense of modules is out of question and do not - of course - depend on these single or double characters. I just think that a single character is better than two. That's all. But i think there is no single character left which is easy to reach on the keyboard :-(
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
Post Reply