Re: Pseudo namespaces

2015-12-04 Thread Ola Fosheim Grøstad via Digitalmars-d
On Friday, 4 December 2015 at 02:59:12 UTC, Steven Schveighoffer wrote: FWIW, I don't believe this complexity of API is worth it. It may be you have all this wonderful mechanisms to specify exactly the runtime requirements for your algorithms -- and Big-Oh isn't particularly useful, but

Re: Pseudo namespaces

2015-12-04 Thread Ola Fosheim Grøstad via Digitalmars-d
On Friday, 4 December 2015 at 08:40:13 UTC, Ola Fosheim Grøstad wrote: Big-Oh isn't particularly useful, but having an upper bound on actual running time is useful in real time programming. And to avoid confusion: in real time applications _everything_ is O(1). Anything worse than that is

Re: Pseudo namespaces

2015-12-04 Thread ZombineDev via Digitalmars-d
On Friday, 4 December 2015 at 07:12:50 UTC, Jacob Carlborg wrote: On 2015-12-03 22:02, Dicebot wrote: And for that specific "stable" example - just make it a separate module, problem solved. To make use of module system for symbol resolution one needs to have many small modules, _that_ should

Re: Pseudo namespaces

2015-12-04 Thread Dicebot via Digitalmars-d
On Friday, 4 December 2015 at 06:57:17 UTC, Walter Bright wrote: On 12/3/2015 12:59 PM, Dicebot wrote: This isn't any different from namespace struct idiom, is it? I don't like it because it forces the namespace usage even if it isn't needed. If you use mixin templates, you can use or not

Re: Pseudo namespaces

2015-12-04 Thread Dicebot via Digitalmars-d
On Friday, 4 December 2015 at 09:30:08 UTC, Walter Bright wrote: I don't understand your comment that modules are broken. With imports, you can use the module name as a prefix or not. I am referring to Andrei proposal for template "namespaces" + your explanation of how it can be flattened via

Re: Pseudo namespaces

2015-12-04 Thread Walter Bright via Digitalmars-d
On 12/4/2015 12:48 AM, Dicebot wrote: True, that didn't come to my mind. But that pushes resulting coding style from "weird but tolerable" to "good luck explaining newbies why D modules are not broken". All for the sake of a putting a dot in the name. Look at perspective for a moment think if

Re: Pseudo namespaces

2015-12-04 Thread Andrei Alexandrescu via Digitalmars-d
On 12/04/2015 02:12 AM, Jacob Carlborg wrote: On 2015-12-03 22:02, Dicebot wrote: And for that specific "stable" example - just make it a separate module, problem solved. To make use of module system for symbol resolution one needs to have many small modules, _that_ should become D idiom. I

Re: Pseudo namespaces

2015-12-04 Thread Andrei Alexandrescu via Digitalmars-d
On 12/04/2015 02:19 AM, Minas Mina wrote: On Thursday, 3 December 2015 at 22:54:53 UTC, Andrei Alexandrescu wrote: Nothing. But one thing I was keeping an eye for would be to allow lst.stable.linear.xxx and lst.linear.stable.xxx with one body. -- Andrei Please don't. Choose one to be the

Re: Pseudo namespaces

2015-12-04 Thread Andrei Alexandrescu via Digitalmars-d
Jacob Carlborg wrote: > On 2015-12-04 15:00, Andrei Alexandrescu wrote: > >> How would one create a module inside a class or struct? -- Andrei > > Hmm, I see that I really didn't understand what you were trying to do. > So you want to create a namespace inside a class or struct? I

Re: Pseudo namespaces

2015-12-04 Thread tcak via Digitalmars-d
On Friday, 4 December 2015 at 09:30:08 UTC, Walter Bright wrote: On 12/4/2015 12:48 AM, Dicebot wrote: True, that didn't come to my mind. But that pushes resulting coding style from "weird but tolerable" to "good luck explaining newbies why D modules are not broken". All for the sake of a

Re: Pseudo namespaces

2015-12-04 Thread tcak via Digitalmars-d
On Friday, 4 December 2015 at 20:58:02 UTC, tcak wrote: On Friday, 4 December 2015 at 09:30:08 UTC, Walter Bright wrote: On 12/4/2015 12:48 AM, Dicebot wrote: [...] I don't understand your comment that modules are broken. With imports, you can use the module name as a prefix or not. The

Re: Pseudo namespaces

2015-12-04 Thread Jacob Carlborg via Digitalmars-d
On 2015-12-04 15:00, Andrei Alexandrescu wrote: How would one create a module inside a class or struct? -- Andrei Hmm, I see that I really didn't understand what you were trying to do. So you want to create a namespace inside a class or struct? I would probably create a separate struct and

Re: Pseudo namespaces

2015-12-04 Thread Walter Bright via Digitalmars-d
On 12/4/2015 1:35 AM, Dicebot wrote: On Friday, 4 December 2015 at 09:30:08 UTC, Walter Bright wrote: I don't understand your comment that modules are broken. With imports, you can use the module name as a prefix or not. I am referring to Andrei proposal for template "namespaces" + your

Re: Pseudo namespaces

2015-12-03 Thread Jacob Carlborg via Digitalmars-d
On 2015-12-03 23:54, Andrei Alexandrescu wrote: Nothing. But one thing I was keeping an eye for would be to allow lst.stable.linear.xxx and lst.linear.stable.xxx with one body. -- Andrei How do you plan to differentiate the functionality? -- /Jacob Carlborg

Re: Pseudo namespaces

2015-12-03 Thread Minas Mina via Digitalmars-d
On Thursday, 3 December 2015 at 22:54:53 UTC, Andrei Alexandrescu wrote: Nothing. But one thing I was keeping an eye for would be to allow lst.stable.linear.xxx and lst.linear.stable.xxx with one body. -- Andrei Please don't. Choose one to be the outer and one to be the inner. Otherwise

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 09:59 PM, Steven Schveighoffer wrote: FWIW, I don't believe this complexity of API is worth it. It's essential. -- Andrei

Re: Pseudo namespaces

2015-12-03 Thread Walter Bright via Digitalmars-d
On 12/3/2015 1:05 PM, FreeSlave wrote: When talking about namespaces in the C++ sense, the feature of namespace is that it can be scattered among many files and can be 'using'. I call that a bug, not a feature, since one loses all control over overloading of names and encapsulation. If

Re: Pseudo namespaces

2015-12-03 Thread Walter Bright via Digitalmars-d
On 12/3/2015 1:29 PM, Andrei Alexandrescu wrote: FWIW I wanted to use it to allow lst.linear.stable.insert() and lst.stable.linear.insert() to refer to the same function, but this is not working. Qualifies as a bug? I don't want this to become a D idiom. It's too clever, too confusing, too

Re: Pseudo namespaces

2015-12-03 Thread Jacob Carlborg via Digitalmars-d
On 2015-12-03 22:02, Dicebot wrote: And for that specific "stable" example - just make it a separate module, problem solved. To make use of module system for symbol resolution one needs to have many small modules, _that_ should become D idiom. I agree. I will just be difficult to convince the

Re: Pseudo namespaces

2015-12-03 Thread Walter Bright via Digitalmars-d
On 12/3/2015 12:59 PM, Dicebot wrote: This isn't any different from namespace struct idiom, is it? I don't like it because it forces the namespace usage even if it isn't needed. If you use mixin templates, you can use or not use the namespace. prefix.

Re: Pseudo namespaces

2015-12-03 Thread Walter Bright via Digitalmars-d
On 12/3/2015 2:54 PM, Andrei Alexandrescu wrote: But one thing I was keeping an eye for would be to allow lst.stable.linear.xxx and lst.linear.stable.xxx with one body. -- Andrei lst.xxx!(stable, linear)

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 04:05 PM, FreeSlave wrote: I don't understand how it is namespace (it's just named scope for me) and why do we need template for that? Probably struct with static members would work the same without need for instantiating the template. How would one use a struct for the List

Re: Pseudo namespaces

2015-12-03 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 3 December 2015 at 21:29:51 UTC, Andrei Alexandrescu wrote: On 12/03/2015 04:05 PM, FreeSlave wrote: I don't understand how it is namespace (it's just named scope for me) and why do we need template for that? Probably struct with static members would work the same without need for

Re: Pseudo namespaces

2015-12-03 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 3 December 2015 at 21:46:03 UTC, Chris Wright wrote: So maybe explicit namespaces within a module are justified sometimes. I definitely think that there are times when it's justified, but I also think that they should be used sparingly. I think that the only time that I've used

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 05:46 PM, Steven Schveighoffer wrote: On 12/3/15 3:51 PM, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have merit. Has anyone explored it? Is it a viable

Re: Pseudo namespaces

2015-12-03 Thread deadalnix via Digitalmars-d
On Thursday, 3 December 2015 at 20:59:59 UTC, Dicebot wrote: This isn't any different from namespace struct idiom, is it? I don't like it because it forces the namespace usage even if it isn't needed. There is something wrong with the module system if one needs to resort to idioms like this.

Re: Pseudo namespaces

2015-12-03 Thread Steven Schveighoffer via Digitalmars-d
On 12/3/15 3:51 PM, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have merit. Has anyone explored it? Is it a viable candidate for becoming a D idiom? I'm going to take a

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 05:14 PM, Jonathan M Davis wrote: You declare static functions on a struct or class and then make the struct or class unusable as an object (e.g. by having a final abstract class or explicitly disabling all ways to construct the struct or class). I must be dense. Consider:

Re: Pseudo namespaces

2015-12-03 Thread ZombineDev via Digitalmars-d
On Thursday, 3 December 2015 at 22:14:56 UTC, Jonathan M Davis wrote: On Thursday, 3 December 2015 at 21:29:51 UTC, Andrei Alexandrescu wrote: On 12/03/2015 04:05 PM, FreeSlave wrote: [...] How would one use a struct for the List example? There's no access to "this". Yes, it's a named

Re: Pseudo namespaces

2015-12-03 Thread ZombineDev via Digitalmars-d
On Thursday, 3 December 2015 at 20:51:02 UTC, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have merit. Has anyone explored it? Is it a viable candidate for becoming a D

Re: Pseudo namespaces

2015-12-03 Thread Steven Schveighoffer via Digitalmars-d
On 12/3/15 5:54 PM, Andrei Alexandrescu wrote: On 12/03/2015 05:46 PM, Steven Schveighoffer wrote: On 12/3/15 3:51 PM, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have

Re: Pseudo namespaces

2015-12-03 Thread Dicebot via Digitalmars-d
On Thursday, 3 December 2015 at 20:51:02 UTC, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have merit. Has anyone explored it? Is it a viable candidate for becoming a D

Re: Pseudo namespaces

2015-12-03 Thread Dicebot via Digitalmars-d
And for that specific "stable" example - just make it a separate module, problem solved. To make use of module system for symbol resolution one needs to have many small modules, _that_ should become D idiom.

Re: Pseudo namespaces

2015-12-03 Thread Chris Wright via Digitalmars-d
On Thu, 03 Dec 2015 21:02:07 +, Dicebot wrote: > And for that specific "stable" example - just make it a separate module, > problem solved. To make use of module system for symbol resolution one > needs to have many small modules, _that_ should become D idiom. Usually the right answer, but

Re: Pseudo namespaces

2015-12-03 Thread FreeSlave via Digitalmars-d
On Thursday, 3 December 2015 at 20:51:02 UTC, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have merit. Has anyone explored it? Is it a viable candidate for becoming a D

Re: Pseudo namespaces

2015-12-03 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 3 December 2015 at 22:27:45 UTC, Andrei Alexandrescu wrote: On 12/03/2015 05:14 PM, Jonathan M Davis wrote: You declare static functions on a struct or class and then make the struct or class unusable as an object (e.g. by having a final abstract class or explicitly disabling all

Re: Pseudo namespaces

2015-12-03 Thread Mike via Digitalmars-d
On Thursday, 3 December 2015 at 22:44:35 UTC, deadalnix wrote: At work we started using abstract final classes a lot for this. #notashamed I used abstract final classes as well: https://github.com/JinShil/stm32f42_discovery_demo/blob/master/source/stm32f42/gpio.d. My use case is quite

Re: Pseudo namespaces

2015-12-03 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 3 December 2015 at 22:54:53 UTC, Andrei Alexandrescu wrote: On 12/03/2015 05:46 PM, Steven Schveighoffer wrote: On 12/3/15 3:51 PM, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more

Re: Pseudo namespaces

2015-12-03 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 3 December 2015 at 22:44:35 UTC, deadalnix wrote: At work we started using abstract final classes a lot for this. which works just fine normally, but apparently, Andrei wants to namespace member functions within a class or struct, which means having access to a specific object

Re: Pseudo namespaces

2015-12-03 Thread Meta via Digitalmars-d
On Thursday, 3 December 2015 at 20:51:02 UTC, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have merit. Has anyone explored it? Is it a viable candidate for becoming a D

Re: Pseudo namespaces

2015-12-03 Thread Tofu Ninja via Digitalmars-d
On Friday, 4 December 2015 at 01:09:07 UTC, Andrei Alexandrescu wrote: On 12/03/2015 08:04 PM, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b Win :o). -- Andrei Not win, we should feel ashamed that this is the kind of stuff you have to do.

Re: Pseudo namespaces

2015-12-03 Thread Steven Schveighoffer via Digitalmars-d
On 12/3/15 8:01 PM, Andrei Alexandrescu wrote: On 12/03/2015 05:59 PM, Steven Schveighoffer wrote: alias stableLinearXxx = linearStableXxx; Doesn't scale. -- Andrei To what? How many nested namespaces are you planning? -Steve

Re: Pseudo namespaces

2015-12-03 Thread Idan Arye via Digitalmars-d
On Thursday, 3 December 2015 at 20:51:02 UTC, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have merit. Has anyone explored it? Is it a viable candidate for becoming a D

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 05:59 PM, Steven Schveighoffer wrote: alias stableLinearXxx = linearStableXxx; Doesn't scale. -- Andrei

Re: Pseudo namespaces

2015-12-03 Thread Mike via Digitalmars-d
On Thursday, 3 December 2015 at 20:59:59 UTC, Dicebot wrote: There is something wrong with the module system if one needs to resort to idioms like this. I agree. These techniques blur the line between "idiom" and "feature abuse". They're creative and sometimes the best or only option, but

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 08:04 PM, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b Win :o). -- Andrei

Re: Pseudo namespaces

2015-12-03 Thread Mike via Digitalmars-d
On Friday, 4 December 2015 at 01:04:33 UTC, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b Doesn't seem to scale to member access: http://dpaste.dzfl.pl/37193377524c /d649/f987.d-mixin-3(7): Error: 'this' is only defined in non-static member

Re: Pseudo namespaces

2015-12-03 Thread Timon Gehr via Digitalmars-d
On 12/04/2015 02:37 AM, Mike wrote: On Friday, 4 December 2015 at 01:04:33 UTC, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b Doesn't seem to scale to member access: http://dpaste.dzfl.pl/37193377524c /d649/f987.d-mixin-3(7): Error: 'this' is only

Re: Pseudo namespaces

2015-12-03 Thread Idan Arye via Digitalmars-d
On Friday, 4 December 2015 at 01:37:35 UTC, Mike wrote: On Friday, 4 December 2015 at 01:04:33 UTC, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b Doesn't seem to scale to member access: http://dpaste.dzfl.pl/37193377524c /d649/f987.d-mixin-3(7):

Re: Pseudo namespaces

2015-12-03 Thread Tofu Ninja via Digitalmars-d
On Thursday, 3 December 2015 at 20:51:02 UTC, Andrei Alexandrescu wrote: I vaguely remembered I saw something like this a while ago: http://dpaste.dzfl.pl/f11894a098c6 The trick could be more fluent, but it might have merit. Has anyone explored it? Is it a viable candidate for becoming a D

Re: Pseudo namespaces

2015-12-03 Thread Timon Gehr via Digitalmars-d
On 12/03/2015 10:29 PM, Andrei Alexandrescu wrote: FWIW I wanted to use it to allow lst.linear.stable.insert() and lst.stable.linear.insert() to refer to the same function, but this is not working. Qualifies as a bug? Yes. (It works with my own implementation of name lookup.)

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 08:52 PM, Tofu Ninja wrote: On Friday, 4 December 2015 at 01:09:07 UTC, Andrei Alexandrescu wrote: On 12/03/2015 08:04 PM, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b Win :o). -- Andrei Not win, we should feel ashamed that this is the

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 08:59 PM, Steven Schveighoffer wrote: On 12/3/15 8:01 PM, Andrei Alexandrescu wrote: On 12/03/2015 05:59 PM, Steven Schveighoffer wrote: alias stableLinearXxx = linearStableXxx; Doesn't scale. -- Andrei To what? How many nested namespaces are you planning? Many functions,

Re: Pseudo namespaces

2015-12-03 Thread Tofu Ninja via Digitalmars-d
On Friday, 4 December 2015 at 02:02:48 UTC, Timon Gehr wrote: On 12/04/2015 02:37 AM, Mike wrote: On Friday, 4 December 2015 at 01:04:33 UTC, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b Doesn't seem to scale to member access:

Re: Pseudo namespaces

2015-12-03 Thread Steven Schveighoffer via Digitalmars-d
On 12/3/15 9:20 PM, Andrei Alexandrescu wrote: On 12/03/2015 08:59 PM, Steven Schveighoffer wrote: On 12/3/15 8:01 PM, Andrei Alexandrescu wrote: On 12/03/2015 05:59 PM, Steven Schveighoffer wrote: alias stableLinearXxx = linearStableXxx; Doesn't scale. -- Andrei To what? How many nested

Re: Pseudo namespaces

2015-12-03 Thread Tofu Ninja via Digitalmars-d
On Friday, 4 December 2015 at 02:24:32 UTC, Tofu Ninja wrote: On Friday, 4 December 2015 at 02:02:48 UTC, Timon Gehr wrote: On 12/04/2015 02:37 AM, Mike wrote: On Friday, 4 December 2015 at 01:04:33 UTC, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b

Re: Pseudo namespaces

2015-12-03 Thread Timon Gehr via Digitalmars-d
On 12/04/2015 03:24 AM, Tofu Ninja wrote: On Friday, 4 December 2015 at 02:02:48 UTC, Timon Gehr wrote: On 12/04/2015 02:37 AM, Mike wrote: On Friday, 4 December 2015 at 01:04:33 UTC, Idan Arye wrote: People are going to hate me, but http://dpaste.dzfl.pl/851d1d1f5e4b Doesn't seem to scale

Re: Pseudo namespaces

2015-12-03 Thread Andrei Alexandrescu via Digitalmars-d
On 12/03/2015 09:37 PM, Steven Schveighoffer wrote: On 12/3/15 9:20 PM, Andrei Alexandrescu wrote: On 12/03/2015 08:59 PM, Steven Schveighoffer wrote: On 12/3/15 8:01 PM, Andrei Alexandrescu wrote: On 12/03/2015 05:59 PM, Steven Schveighoffer wrote: alias stableLinearXxx = linearStableXxx;

Re: Pseudo namespaces

2015-12-03 Thread Steven Schveighoffer via Digitalmars-d
On 12/3/15 9:40 PM, Andrei Alexandrescu wrote: On 12/03/2015 09:37 PM, Steven Schveighoffer wrote: On 12/3/15 9:20 PM, Andrei Alexandrescu wrote: On 12/03/2015 08:59 PM, Steven Schveighoffer wrote: On 12/3/15 8:01 PM, Andrei Alexandrescu wrote: On 12/03/2015 05:59 PM, Steven Schveighoffer