Page 1 of 2
Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 7:34 pm
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?
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 7:53 pm
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 ^^
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 8:07 pm
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.
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 8:14 pm
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()
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 8:19 pm
by uwekel
I totally agree with this request.
+1 for \ instead of ::
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 8:32 pm
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.
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 9:23 pm
by uwekel
But at least a single character would be nice.
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 9:28 pm
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.
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 9:56 pm
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 (::).
Re: Why not '\' instead of '::' for modules?
Posted: Sat Jul 13, 2013 10:03 pm
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...
Re: Why not '\' instead of '::' for modules?
Posted: Mon Jul 15, 2013 3:33 pm
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 ::
Re: Why not '\' instead of '::' for modules?
Posted: Mon Jul 15, 2013 7:48 pm
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

Re: Why not '\' instead of '::' for modules?
Posted: Mon Jul 15, 2013 8:19 pm
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.

Re: Why not '\' instead of '::' for modules?
Posted: Mon Jul 15, 2013 8:21 pm
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.
Re: Why not '\' instead of '::' for modules?
Posted: Mon Jul 15, 2013 8:34 pm
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
