January 16, 2013
On Wednesday, 16 January 2013 at 19:06:47 UTC, Mehrdad wrote:
> On Wednesday, 16 January 2013 at 18:57:06 UTC, mist wrote:
>>
>> This is a single template operator in D so it kind of solves the problem. First is tricky, but is exactly the reason sometimes types from external libs are used only via alias/typedef. I'd prefer something like :%s/boost::unord/std::unord/g though :) But well, if you are working with C++, then templates and mixins will hardly solve most problems of course, because C++ templates sucks and mixins do not even exist there.
>
>
>
> Yeah I'm working in C++, not D.
>
>
> But even if I was using D, there's no way in heck that I would use a _MIXIN_ for that:
>
> mixin("I'm not sure how this is supposed too be readable").unordered_map!(int) a;
>
> makes no sense to me at all, when I could just as well have said 'boost'.
>
>
>
> Also, the search/replace thing won't work so well for any real-world example (the second one is a lot closer to what I had in mind... you can't just replace "T" with "T, U" and expect it to work).
>
>
> So my point is: no, it's not a simple matter of abstracting things away. Lined-up text really DOES make certain tasks easier than they would be otherwise.

++1.

Also, regular expressions ;)
January 16, 2013
On Wednesday, 16 January 2013 at 19:06:47 UTC, Mehrdad wrote:
> On Wednesday, 16 January 2013 at 18:57:06 UTC, mist wrote:
>>
>> This is a single template operator in D so it kind of solves the problem. First is tricky, but is exactly the reason sometimes types from external libs are used only via alias/typedef. I'd prefer something like :%s/boost::unord/std::unord/g though :) But well, if you are working with C++, then templates and mixins will hardly solve most problems of course, because C++ templates sucks and mixins do not even exist there.
>
>
>
> Yeah I'm working in C++, not D.
>
>
> But even if I was using D, there's no way in heck that I would use a _MIXIN_ for that:
>
> mixin("I'm not sure how this is supposed too be readable").unordered_map!(int) a;
>
> makes no sense to me at all, when I could just as well have said 'boost'.
>
>
>
> Also, the search/replace thing won't work so well for any real-world example (the second one is a lot closer to what I had in mind... you can't just replace "T" with "T, U" and expect it to work).
>
>
> So my point is: no, it's not a simple matter of abstracting things away. Lined-up text really DOES make certain tasks easier than they would be otherwise.

Mixins and templates are tools to avoid copy-paste, there is no point to using them just for the sake of that. I have already mentioned that first example is not related to copy-paste and thus not fixable with that, it is more related to alias. Second is fixed perfectly in D using string mixins and single template unary operator with much more readable code.

My point is - when you have a lot repetitive text pieces in your code, it is much better in longer scope to use advanced language tools instead of advanced editing tools. And this is one place where D is so superior do C++. I must admit I'd prefer to have template mixins allowed for statements to minimize string mixin usage but it is still much much better than copy-paste in my opinion.
January 16, 2013
On Wednesday, 16 January 2013 at 19:29:59 UTC, mist wrote:
> Mixins and templates are tools to avoid copy-paste, there is no point to using them just for the sake of that. I have already mentioned that first example is not related to copy-paste and thus not fixable with that, it is more related to alias. Second is fixed perfectly in D using string mixins and single template unary operator with much more readable code.



String mixin are uglier than C-macros, IMO.
(No, I'm not saying they're worse. They're just uglier, visually speaking.)
I avoid string mixins as much as possible.


Not to mention they're quite intensive work for the compiler to do compared to a regular declaration, which creates obvious problems.




> My point is - when you have a lot repetitive text pieces in your code, it is much better in longer scope to use advanced language tools instead of advanced editing tools.

Only if the increase in ugliness is worth the ease of editing.


> And this is one place where D is so superior do C++.

Sure, but that's an unrelated discussion.


> I must admit I'd prefer to have template mixins allowed for statements to minimize string mixin usage but it is still much much better than copy-paste in my opinion.


The problem with the idea of a mixin is that it's just ___too much abstraction___.

It's almost like making a FactoryFactorFactory in Java, except now you have a MyClassOperatorMixinTemplate or something like that.


I don't know about you, but I just don't believe in abstracting away every single character I type.
January 16, 2013
On Wednesday, 16 January 2013 at 21:45:49 UTC, Mehrdad wrote:
> The problem with the idea of a mixin is that it's just ___too much abstraction___.


Clarification: I meant the problem with the idea of using a mixin to solve THIS kind of editing problem.

Obviously there's appropriate situations for those too, but "avoiding text alignment" isn't high on that list imo.
January 16, 2013
On 16.01.2013 20:07, Mehrdad wrote:

>
> When you have a ton of similar lines of code which need to be edited in
> parallel, lining them up lets you edit all of them in one keystroke.
> Saves me quite a lot of annoying editing in the long run, actually.

With Sublime Text you don't even have to align columns to do multiple simultaneous edits, just ctrl + click to create multiple cursors and then type/edit away. It has a lot of nice features :)

-- 

Marco Nembrini
January 17, 2013
On 1/15/2013 5:39 PM, H. S. Teoh wrote:
> Maybe I should invent a programming language in which color has semantic
> value.

That works until your first color blind user.

January 17, 2013
On Wed, Jan 16, 2013 at 04:40:07PM -0800, Walter Bright wrote:
> On 1/15/2013 5:39 PM, H. S. Teoh wrote:
> >Maybe I should invent a programming language in which color has semantic value.
> 
> That works until your first color blind user.

I wasn't being serious. :)


T

-- 
Food and laptops don't mix.
January 17, 2013
On Thursday, 17 January 2013 at 00:40:06 UTC, Walter Bright wrote:
> On 1/15/2013 5:39 PM, H. S. Teoh wrote:
>> Maybe I should invent a programming language in which color has semantic value.
>
> That works until your first color blind user.

 I have a perfect solution! Have a special monitor that can transmit the images directly into your brain! No more sense dependence issues!

 Okay maybe impractical until technology increases...
January 17, 2013
On Wednesday, 16 January 2013 at 22:29:10 UTC, Marco Nembrini wrote:
> On 16.01.2013 20:07, Mehrdad wrote:
>
>>
>> When you have a ton of similar lines of code which need to be edited in
>> parallel, lining them up lets you edit all of them in one keystroke.
>> Saves me quite a lot of annoying editing in the long run, actually.
>
> With Sublime Text you don't even have to align columns to do multiple simultaneous edits, just ctrl + click to create multiple cursors and then type/edit away. It has a lot of nice features :)



Uh, you sort of missed the point...
The point was that you align similar-looking lines when /writing/ the code, so that it's in the right form when you need to modify it later, and all you need to do is Alt-Click-Drag to create 20 cursors, and type away.

Or to put it another way: the whole point is to turn an O(n) operation into an O(1) operation. If you have to make O(n) cursor-additions then you've defeated the whole purpose.


That said, what you mentioned is not just a Sublime feature...
I use SciTE which does exactly the same thing. =P
January 17, 2013
On Thursday, January 17, 2013 03:09:35 Era Scarecrow wrote:
>   I have a perfect solution! Have a special monitor that can
> transmit the images directly into your brain! No more sense
> dependence issues!

And then you get to worry about people hacking your brain with bad soure code! :)

- Jonathan M Davis
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Top | Discussion index | About this forum | D home