It is currently Wed Jun 19, 2019 12:00 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 157 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 11  Next
Author Message
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 8:54 pm 
Offline
Always Here
Always Here
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 5754
Location: Berlin - Germany
The Concept by Fred is good!

Only one wish: Source-Module and Binary-Module
To make Binary modules around the code before others inaccessible,
around this to selling or simply because one is ashamed of that :mrgreen:

_________________
PureBasic 5.70 | SpiderBasic 2.21 | Windows 10 Pro (x64) | Linux Mint 19.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 9:07 pm 
Offline
Addict
Addict

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1040
Location: Russia
freak, If we add modules in PB, it is necessary do it properly, rather than pseudo-modules, you have to offer. All constants, structures, procedures need to be isolated from the main program, and then the that suggest, can not be called isolation!
So it is better not to waste time on the modules than to implement them according to your plan. :( :(

freak wrote:
Modules in modules:
I don't see a common need for this. I have a hard time coming up with a useful example for it to be honest. And the semantics of such a feature would be hard to define and understand. Once again: we are trying to keep things understandable and not make them unnecessarily complex.
Imagine you have a game engine (for example), divided into several modules. Engine itself is a module, and modules engine - nested modules main module.
Why do it?
For isolation of code. Using modules of the required functions are exported engine, but the program will not be available functions and structures of the inner engine modules.

But on your plan, it does not make sense, because there is no complete isolation of code.

freak wrote:
What other feature should we have dropped to get the time for this?
For example, 3D function.

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Last edited by User_Russian on Mon Feb 04, 2013 9:18 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 9:10 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 24, 2007 3:15 pm
Posts: 728
Location: Germany
freak wrote:
Its not like we did nothing all these years. Look at the release history. What other feature should we have dropped to get the time for this?

Oh ... if you mean my quiping ... sorry if it was to much. :)


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 9:13 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
Fred wrote:
As you seem interested by the module topic, here is our draft, so you can get a better idea. Please keep in mind than it's no promise, we can drop it if we change our mind so don't expect it for the next version.

Code:
      ; Here is my suggestion: ...



Fred, the same stuff can be achieved with less complication, just look at the above post of mine.

We have already IncludeFile and IncludeBinary why not add IncludeModule and make each file a module?
There is no need for Module/EndModule and stuff that over-complicates things.

In Go if there are several procedures with the same name (because several modules are imported) the only thing that needs to be done is:
Code:
Crypto1.Cipher() ; call Cipher from module 1
Crypto2.Cipher() ; call Cipher from module 2


the PureBasic equivalent could look like this:

Code:
Crypto1\\Cipher() ; call Cipher from module 1
Crypto2\\Cipher() ; call Cipher from module 2


Please keep it simple.

Thanks for reading :wink:

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 9:22 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3694
Location: Italy
Thanks for the more detailed info. The "External" bit was the piece missing to make it work better for me.

freak wrote:
There is no confusion between an X_Foo() procedure that belongs to module X and another X_Foo() procedure that you write elsewhere because you can't. They refer to the same thing.


Scenario: you include the source of module MOD in your main program, the module contains a Foo() procedure inside it (scope defined below).

1) You don't use OpenModule

1A) Foo() in the module is private (default)
You try do define a Foo() proc in the main program. Should be possible.
You call that proc with Foo() and can't access the one inside the module. OK.

1B) Foo() in the module is External
You try do define a Foo() proc in the main program. Should be possible (?)
You call that proc with Foo() and the one inside the module with MOD_Foo(). OK.

2) You use OpenModule MOD

1A) Foo() in the module is private (default)
You try do define a Foo() proc in the main program. Should be possible.
You call that proc with Foo() and can't access the one inside the module. OK.

1B) Foo() in the module is External
You try do define a Foo() proc in the main program. What happens ? Error ? (you now can access Foo() in the module simply through its name right ?)

Is all the above right ?

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 9:34 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3574
Location: Berlin, Germany
fsw wrote:
We have already IncludeFile and IncludeBinary why not add IncludeModule and make each file a module?
Yes, that would be simple and useful.
Each file included by "IncludeModule" is a separate namespace. But procedures, structures or variables in the module which are declared "External" can be also accessed by code which is outside of the module. Keep it really simple. :-)

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 9:47 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Sep 21, 2007 5:52 am
Posts: 3377
Location: New Zealand
it makes perfect sense to use an underscore
So how would you escape a namespace and call a globally scoped function from within a namespace
seems like we need an escape symbol

Code:
;globally scoped function
Procedure Foo()
;...
EndProcedure

NameSpace Foo
   state.i
   procedure Foo()
   ;...
   EndProcedure
EndNameSpace

UseNameSpace Foo
   Foo()
   ;how to escape a namespace to the global namespace?         
   _foo() ; using underscore could break existing code
   \foo() ; is just confusing   
   ::foo() ;would work well   
   
   ;or like like this which would be a hassle   
    UseNameSpace Main
       foo()
    CloseNameSpace
 

_________________
Got winter blues?
Enjoy a Caravan Trip into, "The Land of Grey and Pink", wine and punk weed optional!
https://www.youtube.com/watch?v=9hmFzGTxod4


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 9:48 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5777
Location: Germany
ts-soft wrote:
[...] To make Binary modules around the code before others inaccessible,
around this to selling or simply because one is ashamed of that :mrgreen:

Be honest: The second one is the critical one :D

User_Russian wrote:
All constants, structures, procedures need to be isolated from the main program, and then the that suggest, can not be called isolation!

The concept above would apply to all names. The procedures are just examples.

User_Russian wrote:
Imagine you have a game engine (for example), divided into several modules. Engine itself is a module, and modules engine - nested modules main module.

You can have the nested modules side by side. Just use descriptive names and there will be no problem. There is no need for them to be nested. I don't know a real world project that uses nested namespaces, even though other languages allow it. People avoid this because it makes things more complex, not less.

User_Russian wrote:
freak wrote:
What other feature should we have dropped to get the time for this?
For example, 3D function.

That is just your opinion. If i ask somebody else he would mention your most favorite feature. Would you be ok if we had postponed that?

PMV wrote:
freak wrote:
Its not like we did nothing all these years. Look at the release history. What other feature should we have dropped to get the time for this?

Oh ... if you mean my quiping ... sorry if it was to much. :)

It was aimed at the general "why did feature X take so many years?" questions. Its not feature X that took so long. The tons of other features combined did.

luis wrote:
1B) Foo() in the module is External
You try do define a Foo() proc in the main program. What happens ? Error ? (you now can access Foo() in the module simply through its name right ?)

You get an "already defined" error because you can see the one in the module and try to define something with the same name.

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 10:11 pm 
Offline
Always Here
Always Here
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 5754
Location: Berlin - Germany
I think adding a Alias was a good idea
Code:
Module GUI
  External Procedure Foo()
  EndProcedure
EndModule

Procedure Foo()
EndProcedure

OpenModule GUI As Blub
  BLub_Foo()
  Foo()
CloseModule


No conflict

_________________
PureBasic 5.70 | SpiderBasic 2.21 | Windows 10 Pro (x64) | Linux Mint 19.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 10:17 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
idle wrote:
it makes perfect sense to use an underscore


No an underscore makes no sense.
At least to me :P

This is better:
Code:
Module main
IncludeModule "myFoo" ; has a Foo() procedure

Procedure Foo()
;...
EndProcedure

   Foo() ; this is the local Foo
   myFoo\\Foo() ; this is the Foo from module myFoo
   


Besides "\" is used for structure items; it makes sense to use "\\" for module items.

If there is no local Foo() the code could look like this:
Code:
Module main
IncludeModule "myFoo" ; has a Foo() procedure

   Foo() ; this is the Foo from module myFoo
   

No module name needed as there is only one Foo().


Using NameSpace/EndNameSpace, UseNameSpace/CloseNameSpace and other things are not clever, it asks for trouble...

This is my opinion and I stick to it :mrgreen:

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Last edited by fsw on Mon Feb 04, 2013 10:21 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 10:21 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2941
Location: Boston, MA
freak wrote:
User_Russian wrote:
All constants, structures, procedures need to be isolated from the main program, and then the that suggest, can not be called isolation!

The concept above would apply to all names. The procedures are just examples.

By 'names' you mean constants and structures would be isolated too?

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 10:26 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 5:21 pm
Posts: 5777
Location: Germany
skywalk wrote:
freak wrote:
User_Russian wrote:
All constants, structures, procedures need to be isolated from the main program, and then the that suggest, can not be called isolation!

The concept above would apply to all names. The procedures are just examples.

By 'names' you mean constants and structures would be isolated too?


Yes.

Btw, another reason for the '_': #MyConstant inside Module Foo becomes "#Foo_MyConstant" which looks good. "Foo::#MyConstant" or "#Foo::MyConstant" are both a bit weird imho :)

_________________
quidquid Latine dictum sit altum videtur


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 10:49 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Dec 23, 2009 10:14 pm
Posts: 2941
Location: Boston, MA
Ok, that is very tempting and I will sacrifice my top wish for modules :mrgreen:

_________________
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 11:00 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 24, 2007 3:15 pm
Posts: 728
Location: Germany
freak wrote:
The concept above would apply to all names. The procedures are just examples.

With that the underscore makes much more sense as everything else. But i
will repeat myself ... It is a solid design and thats what i expected. Very nice!
Image



Only still curious about the release version. :P


Top
 Profile  
Reply with quote  
 Post subject: Re: Classes in PureBasic
PostPosted: Mon Feb 04, 2013 11:08 pm 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13590
Location: France
See why we don't talk about next features publicly ;)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 157 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 11  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: blueb and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye