www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - 'partial' keyword in C# is very good for project ,what's the same

reply "FrankLike" <1150015857 qq.com> writes:
Hello,everyone,

very userful,which lets the auto codes in another single file,my 
codes are very easy to update.
But  what the same thing in D?

Thank you,every one.
Oct 29 2014
next sibling parent reply "Paulo Pinto" <pjmlp progtools.org> writes:
On Wednesday, 29 October 2014 at 07:41:41 UTC, FrankLike wrote:
 Hello,everyone,

 is very userful,which lets the auto codes in another single 
 file,my codes are very easy to update.
 But  what the same thing in D?

 Thank you,every one.
Maybe mixins might be a possibility.
Oct 29 2014
parent reply "Regan Heath" <regan netmail.co.nz> writes:
On Wed, 29 Oct 2014 07:54:39 -0000, Paulo  Pinto <pjmlp progtools.org>  
wrote:

 On Wednesday, 29 October 2014 at 07:41:41 UTC, FrankLike wrote:
 Hello,everyone,

 userful,which lets the auto codes in another single file,my codes are  
 very easy to update.
 But  what the same thing in D?

 Thank you,every one.
Maybe mixins might be a possibility.
Something like.. class Foo { mixin(import("auto-generated.d")); } where auto-generated.d has class members/methods but no "class Foo" itself. code and user code into a single class. So, the Windows GUI builder does it placing all the GUI component construction and property setting in one file, and allowing the user to only have to see/edit the application level code in another file. Likewise LINQ to SQL generates a custom DataContext child class, and the user can optionally create a 2nd file with the partial class to extend it. compiler generated empty body. They are not virtual as you cannot call a base.method() from method(), instead you optionally implement the method and if you don't it does nothing. LINQ to SQL uses these for insert/update/delete events for each table in your database. R -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Oct 29 2014
parent reply "FrankLike" <1150015857 qq.com> writes:
On Wednesday, 29 October 2014 at 10:25:54 UTC, Regan Heath wrote:
 On Wed, 29 Oct 2014 07:54:39 -0000, Paulo  Pinto 
 <pjmlp progtools.org> wrote:

 On Wednesday, 29 October 2014 at 07:41:41 UTC, FrankLike wrote:
 Hello,everyone,

 is very userful,which lets the auto codes in another single 
 file,my codes are very easy to update.
 But  what the same thing in D?

 Thank you,every one.

 auto-generated code and user code into a single class.  So, the 
 Windows GUI builder does it placing all the GUI component 
 construction and property setting in one file, and allowing the 
 user to only have to see/edit the application level code in 
 another file.  Likewise LINQ to SQL generates a custom 
 DataContext child class, and the user can optionally create a 
 2nd file with the partial class to extend it.
 R
The same thing in D should be done,now.Otherwise,no big projects FrankLike
Oct 29 2014
next sibling parent reply "FrankLike" <1150015857 qq.com> writes:

 auto-generated code and user code into a single class.  So, 
 the Windows GUI builder does it placing all the GUI component 
 construction and property setting in one file, and allowing 
 the user to only have to see/edit the application level code 
 in another file.  Likewise LINQ to SQL generates a custom 
 DataContext child class, and the user can optionally create a 
 2nd file with the partial class to extend it.
 R
The same thing in D should be done,now.Otherwise,no big keyword,and update the compiler. FrankLike
Oct 29 2014
parent ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Wed, 29 Oct 2014 12:58:28 +0000
FrankLike via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 The same thing in D should be done,now.Otherwise=EF=BC=8Cno big=20

Oct 29 2014
prev sibling next sibling parent reply "Gary Willoughby" <dev nomad.so> writes:
On Wednesday, 29 October 2014 at 12:55:01 UTC, FrankLike wrote:
 The same thing in D should be done,now.Otherwise,no big 

 the compiler.
Large projects are already being developed using D so your argument is wrong. Also no new keywords are being added to the language because D is trying to achieve stability right now. You can achieve what you desire using mixins.
Oct 29 2014
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 10/29/2014 7:01 AM, Gary Willoughby wrote:
 On Wednesday, 29 October 2014 at 12:55:01 UTC, FrankLike wrote:
 The same thing in D should be done,now.Otherwise,no big projects can be done

Large projects are already being developed using D so your argument is wrong. Also no new keywords are being added to the language because D is trying to achieve stability right now. You can achieve what you desire using mixins.
Either string mixins, template mixins, alias this or opDispatch.
Oct 29 2014
parent "andre" <andre s-e-a-p.de> writes:
 From some little tests I can say only string mixins are working
for the GUI builder scenario.
The concrete class contains private ui controls (members). The 
gui builder
framework needs to access these private members to call their 
constructors, and set their values to the last persisted state.

template mixins aren't able to access these private members.
I also think alias this and opDispatch do not help here.

string mixins working perfectly. partial would be a really nice
feature but I also doubt that it will come with D2.

Kind regards
André

On Wednesday, 29 October 2014 at 23:23:40 UTC, Walter Bright 
wrote:
 On 10/29/2014 7:01 AM, Gary Willoughby wrote:
 On Wednesday, 29 October 2014 at 12:55:01 UTC, FrankLike wrote:
 The same thing in D should be done,now.Otherwise,no big 
 projects can be done

Large projects are already being developed using D so your argument is wrong. Also no new keywords are being added to the language because D is trying to achieve stability right now. You can achieve what you desire using mixins.
Either string mixins, template mixins, alias this or opDispatch.
Oct 30 2014
prev sibling next sibling parent reply "Dejan Lekic" <dejan.lekic gmail.com> writes:
On Wednesday, 29 October 2014 at 12:55:01 UTC, FrankLike wrote:
 The same thing in D should be done,now.Otherwise,no big 

 the compiler.
This certainly made me laugh... I work on a very big project does not have it. :) Even if it does we would not use it as we prefer our classes to be in a single file. In D apps I work on I prefer all my classes in a single module, as is common "D way", or shall I call it "modular way"?
Oct 31 2014
next sibling parent ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Fri, 31 Oct 2014 09:30:25 +0000
Dejan Lekic via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 On Wednesday, 29 October 2014 at 12:55:01 UTC, FrankLike wrote:
 The same thing in D should be done,now.Otherwise=EF=BC=8Cno big=20

 the compiler.
=20 This certainly made me laugh... I work on a very big project=20 does not have it. :) Even if it does we would not use it as we=20 prefer our classes to be in a single file. =20 In D apps I work on I prefer all my classes in a single module,=20 as is common "D way", or shall I call it "modular way"?
each new generation of programmers tend to believe that there will be no success to languages other than that one they learned unless other languages becomes feature-to-feature clones of The One Language. it's ok, they will learn other languages sooner or later and will start to hate them all. ;-)
Oct 31 2014
prev sibling next sibling parent reply "Paulo Pinto" <pjmlp progtools.org> writes:
On Friday, 31 October 2014 at 09:30:26 UTC, Dejan Lekic wrote:
 On Wednesday, 29 October 2014 at 12:55:01 UTC, FrankLike wrote:
 The same thing in D should be done,now.Otherwise,no big 

 the compiler.
This certainly made me laugh... I work on a very big project does not have it. :) Even if it does we would not use it as we prefer our classes to be in a single file. In D apps I work on I prefer all my classes in a single module, as is common "D way", or shall I call it "modular way"?
No human uses partial classes in .NET land other than the tools themselves. It is a language feature introduced to simplify how Visual Studio supports round-trip editing of UI code in its designers, instead of relying in metadata files. -- Paulo
Oct 31 2014
parent reply "FrankLike" <1150015857 qq.com> writes:
 No human uses partial classes in .NET land other than the tools 
 themselves.

 It is a language feature introduced to simplify how Visual 
 Studio supports round-trip editing of UI code in its designers, 
 instead of relying in metadata files.

 --
 Paulo
Very good,It makes your code look very simple , nice and cool. Frank
Oct 31 2014
parent reply "Wyatt" <wyatt.epp gmail.com> writes:
On Friday, 31 October 2014 at 12:54:30 UTC, FrankLike wrote:
 No human uses partial classes in .NET land other than the 
 tools themselves.
Very good,It makes your code look very simple , nice and cool.
Does the inverse of the Turing test have a name? How am I supposed to react when a human passes it? ;) -Wyatt
Oct 31 2014
parent ketmar via Digitalmars-d <digitalmars-d puremagic.com> writes:
On Fri, 31 Oct 2014 13:45:37 +0000
Wyatt via Digitalmars-d <digitalmars-d puremagic.com> wrote:

 On Friday, 31 October 2014 at 12:54:30 UTC, FrankLike wrote:
 No human uses partial classes in .NET land other than the=20
 tools themselves.
Very good,It makes your code look very simple =EF=BC=8C nice and cool.
Does the inverse of the Turing test have a name? How am I=20 supposed to react when a human passes it? ;)
just show him IOCCC. he will never return. ;-)
Oct 31 2014
prev sibling parent reply "Regan Heath" <regan netmail.co.nz> writes:
On Fri, 31 Oct 2014 09:30:25 -0000, Dejan Lekic <dejan.lekic gmail.com>  
wrote:
 In D apps I work on I prefer all my classes in a single module, as is  
 common "D way", or shall I call it "modular way"?
Sure, but that's not the point of partial. It's almost never used by the programmer directly, and when it is used you almost never need to look at the generated partial class code as "it just works". So, you effectively get what you "prefer" but you also get clean separation between generated and user code, which is very important if the generated code needs to be re-generated and it also means the user code stays simpler, cleaner and easier to work with. Basically it's just a good idea(TM). Unfortunately as many have said, it's not something D2.0 is likely to see. String mixins aren't the nicest thing to use, but at least they can achieve the same/similar thing. R -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Nov 10 2014
next sibling parent "FrankLike" <1150015857 qq.com> writes:
On Monday, 10 November 2014 at 10:21:34 UTC, Regan Heath wrote:

 Sure, but that's not the point of partial.  It's almost never 
 used by the programmer directly, and when it is used you almost 
 never need to look at the generated partial class code as "it 
 just works".  So, you effectively get what you "prefer" but you 
 also get clean separation between generated and user code, 
 which is very important if the generated code needs to be 
 re-generated and it also means the user code stays simpler, 
 cleaner and easier to work with.

 Basically it's just a good idea(TM).  Unfortunately as many 
 have said, it's not something D2.0 is likely to see.  String 
 mixins aren't the nicest thing to use, but at least they can 
 achieve the same/similar thing.

 R
It's right, it's just a good idea for D. I love D ,and hope it 'the user code stays simpler, cleaner and easier to work with.'. Thank you. Frank
Nov 10 2014
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2014-11-10 11:21, Regan Heath wrote:

 Basically it's just a good idea(TM).  Unfortunately as many have said,
 it's not something D2.0 is likely to see.  String mixins aren't the
 nicest thing to use, but at least they can achieve the same/similar thing.
Template mixins can be used instead. Looks a lot better. -- /Jacob Carlborg
Nov 10 2014
parent reply "Andre" <andre s-e-a-p.de> writes:
One requirement for a partial alternative is, that the generated 
coding can access private member of the actual class as they are 
in most GUI framework private members of the class.

class Example
{
private Button b;
private ComboBox cb;
}

The GUI framework takes care about calling their constructors and 
also about persisting their design time values (values you read 
and write in the GUI builder).

Is there any possibility to access private members by using 
Template Mixins?
As far as I can see only String Mixins are able to access private 
members of the scope they are inserted to.

Kind regards
André


On Monday, 10 November 2014 at 14:38:58 UTC, Jacob Carlborg wrote:
 On 2014-11-10 11:21, Regan Heath wrote:

 Basically it's just a good idea(TM).  Unfortunately as many 
 have said,
 it's not something D2.0 is likely to see.  String mixins 
 aren't the
 nicest thing to use, but at least they can achieve the 
 same/similar thing.
Template mixins can be used instead. Looks a lot better.
Nov 10 2014
parent "Gary Willoughby" <dev nomad.so> writes:
On Monday, 10 November 2014 at 16:44:53 UTC, Andre wrote:
 Is there any possibility to access private members by using 
 Template Mixins?
Yes, like this: https://github.com/nomad-software/tkd/blob/master/source/tkd/widget/common/value.d
Nov 10 2014
prev sibling parent reply "deadalnix" <deadalnix gmail.com> writes:
On Monday, 10 November 2014 at 10:21:34 UTC, Regan Heath wrote:
 On Fri, 31 Oct 2014 09:30:25 -0000, Dejan Lekic 
 <dejan.lekic gmail.com> wrote:
 In D apps I work on I prefer all my classes in a single 
 module, as is common "D way", or shall I call it "modular way"?
Sure, but that's not the point of partial. It's almost never used by the programmer directly, and when it is used you almost never need to look at the generated partial class code as "it just works". So, you effectively get what you "prefer" but you also get clean separation between generated and user code, which is very important if the generated code needs to be re-generated and it also means the user code stays simpler, cleaner and easier to work with. Basically it's just a good idea(TM). Unfortunately as many have said, it's not something D2.0 is likely to see. String mixins aren't the nicest thing to use, but at least they can achieve the same/similar thing. R
I don't get how the same can't be achieved with mixin template for instance.
Nov 10 2014
parent "Regan Heath" <regan netmail.co.nz> writes:
On Mon, 10 Nov 2014 18:09:12 -0000, deadalnix <deadalnix gmail.com> wrote:

 On Monday, 10 November 2014 at 10:21:34 UTC, Regan Heath wrote:
 On Fri, 31 Oct 2014 09:30:25 -0000, Dejan Lekic <dejan.lekic gmail.com>  
 wrote:
 In D apps I work on I prefer all my classes in a single module, as is  
 common "D way", or shall I call it "modular way"?
Sure, but that's not the point of partial. It's almost never used by the programmer directly, and when it is used you almost never need to look at the generated partial class code as "it just works". So, you effectively get what you "prefer" but you also get clean separation between generated and user code, which is very important if the generated code needs to be re-generated and it also means the user code stays simpler, cleaner and easier to work with. Basically it's just a good idea(TM). Unfortunately as many have said, it's not something D2.0 is likely to see. String mixins aren't the nicest thing to use, but at least they can achieve the same/similar thing. R
I don't get how the same can't be achieved with mixin template for instance.
Someone raised concerns.. I haven't looked into it myself. If it can, great :) R -- Using Opera's revolutionary email client: http://www.opera.com/mail/
Nov 12 2014
prev sibling parent reply "Andrea Fontana" <nospam example.com> writes:
On Wednesday, 29 October 2014 at 12:55:01 UTC, FrankLike wrote:
 The same thing in D should be done,now.Otherwise,no big 

 the compiler.

 FrankLike
I wonder how linux was written in c. I think it's a rather big project to do without partial keyword.
Oct 31 2014
parent reply "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Friday, 31 October 2014 at 13:50:30 UTC, Andrea Fontana wrote:
 I wonder how linux was written in c.
 I think it's a rather big project to do without partial keyword.
Finns are hardcore. They drink a lot. They swear a lot. And they bathe in snow after taking a whipping. Naked… And they like it… Only Linus can create Linux without partial.
Oct 31 2014
next sibling parent reply "eles" <eles eles.com> writes:
On Friday, 31 October 2014 at 13:57:40 UTC, Ola Fosheim Grøstad 
wrote:
 On Friday, 31 October 2014 at 13:50:30 UTC, Andrea Fontana 
 wrote:
 I wonder how linux was written in c.
 I think it's a rather big project to do without partial 
 keyword.
Finns are hardcore. They drink a lot. They swear a lot. And they bathe in snow after taking a whipping. Naked…
Caught in the act... http://www.freogan.org/wp-content/uploads/2009/12/linus-torvald-speedo-300x255.jpg
Oct 31 2014
parent "Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= writes:
On Friday, 31 October 2014 at 14:03:04 UTC, eles wrote:
 Caught in the act...

 http://www.freogan.org/wp-content/uploads/2009/12/linus-torvald-speedo-300x255.jpg
Nice! He's got a sauna at home too. And he does "management by cursing": http://en.wikipedia.org/wiki/Management_by_perkele
Oct 31 2014
prev sibling parent "deadalnix" <deadalnix gmail.com> writes:
On Friday, 31 October 2014 at 13:57:40 UTC, Ola Fosheim Grøstad
wrote:
 On Friday, 31 October 2014 at 13:50:30 UTC, Andrea Fontana 
 wrote:
 I wonder how linux was written in c.
 I think it's a rather big project to do without partial 
 keyword.
Finns are hardcore. They drink a lot. They swear a lot. And they bathe in snow after taking a whipping. Naked… And they like it… Only Linus can create Linux without partial.
They are out of control https://www.youtube.com/watch?v=VWHfiEKK3zw
Oct 31 2014
prev sibling next sibling parent reply "deadalnix" <deadalnix gmail.com> writes:
On Wednesday, 29 October 2014 at 07:41:41 UTC, FrankLike wrote:
 Hello,everyone,

 is very userful,which lets the auto codes in another single 
 file,my codes are very easy to update.
 But  what the same thing in D?

 Thank you,every one.
What does it do ?
Oct 29 2014
parent reply Jacob Carlborg <doob me.com> writes:
On 2014-10-30 00:00, deadalnix wrote:

 What does it do ?
It lets you split the implementation of a class between multiple source codes, i.e. a GUI builder. You have the generated part of the class in one file and the code that is manually edited in another file. -- /Jacob Carlborg
Oct 30 2014
parent "FrankLike" <1150015857 qq.com> writes:
On Thursday, 30 October 2014 at 07:20:24 UTC, Jacob Carlborg 
wrote:
 On 2014-10-30 00:00, deadalnix wrote:

 What does it do ?
It lets you split the implementation of a class between that generate some codes, i.e. a GUI builder. You have the generated part of the class in one file and the code that is manually edited in another file.
It's a good thing for editing codes. Frank
Nov 08 2014
prev sibling next sibling parent "Kagamin" <spam here.lot> writes:

both ways: some are split into partial classes, some mix 
generated code with user code. Can't remember any issue with it, 
and difference is visible only when you realize, that the code is 
indeed in the same file, which may or may not happen.
Oct 31 2014
prev sibling parent "tcak" <tcak gmail.com> writes:
On Wednesday, 29 October 2014 at 07:41:41 UTC, FrankLike wrote:
 Hello,everyone,

 is very userful,which lets the auto codes in another single 
 file,my codes are very easy to update.
 But  what the same thing in D?

 Thank you,every one.
We never used partial before. So you don't/shouldn't need it as well. /s
Nov 01 2014