View mode: basic / threaded / horizontal-split · Log in · Help
April 11, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
> Am 11.04.2011 10:01, schrieb Jonathan M Davis:
> >> Jonathan M Davis Wrote:
> >>> Personally, I think that it's _horrible_ to use tabs
> >> 
> >> Why would one fear tabs?
> > 
> > They change depending on your editor settings. Indenting gets screwed up
> > if tabs and spaces are mixed. It's just plain annoying to have an
> > indentation of multiple spaces which isn't actually multiple spaces.
> > 
> > The biggest problem though is that it just totally screws with
> > indentation if tabs and spaces are mixed and that invariably happens.
> > 
> > Tabs serve no useful purpose IMHO.
> > 
> > - Jonathan M Davis
> 
> So tabs are horrible because some people use spaces instead of tabs.

I hate the very concept of tabs to begin with. The fact that they're variable 
in size is _not_ something that I find to be desirable. Regardless of that 
however, if you try and use tabs for indentation they invariably get mixed 
with spaces, totally ruining whatever usefulness the tabs might have had. Code 
will _always_ contain spaces. You can't reasonably write code with only tabs. 
However, you _can_ easily and reasonably write code without tabs. Most code 
editors can be set up such that all tabs are converted to spaces. So, if you 
use only spaces, you can easily avoid the problem of tabs and spaces being 
mixed. On the other hand, you _can't_ do the same by using only tabs. So, if 
you do use tabs, you will end up with mixed tabs and spaces unless everyone 
involved is very careful, which isn't going to happen.

So, I suppose that you could say that tabs are horrible because some people 
use spaces, but I don't see any value in them to begin with anyway. However, 
the fact that you invariably end up with mixed tabs and spaces when you try 
and use tabs makes tabs completely useless. Every place that I've ever worked 
at has gone for spaces only, and I've only ever heard of one place where it 
was required that tabs be used for indentation. I'm sure that there are 
others, but it's rare that I've heard of anyone thinking that using tabs in 
code was a good idea.

- Jonathan M Davis
April 11, 2011
Re: simple display (from: GUI library for D)
On 04/11/2011 03:54 AM, Adam D. Ruppe wrote:
>> 1. *Please use spaces instead of tabs.*
> Spaces are the spawn of Satan! I hate them, but when it comes time
> to submit to phobos, I'll run a find/replace of them so it's
> consistent with the prevailing style there. Until then though,
> I'll write it in my native style... so these early drafts will
> remain tabs, but spaces will be used in the final copy.

Using spaces is confusing model & view, and forcing your preferred indent width 
over all readers. Tab means "align columns". Using tabs is respectful attitude ;-)

I still use spaces only because most email clients do not allow setting tab 
width :-(

Denis
-- 
_________________
vita es estrany
spir.wikidot.com
April 11, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
On 04/11/2011 07:51 AM, Jonathan M Davis wrote:
> the only way that tabs work is if you use them consistently, which in my
> experience almost never happens. And

How so? If you probably set your editor, inconsistency simply cannot happen... 
The same is true for using spaces, anyway.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com
April 11, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
On 04/11/2011 08:13 AM, Jonathan M Davis wrote:
> They mix tabs and spaces. On some lines, they use spaces and on others they
> use tabs.

Never seen this, not even once. Messing can only happen when one copy-pastes 
from modules using spaces.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com
April 11, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
On 04/11/2011 10:01 AM, Jonathan M Davis wrote:
>> Jonathan M Davis Wrote:
>>> >  >  Personally, I think that it's _horrible_ to use tabs
>> >
>> >  Why would one fear tabs?
> They change depending on your editor settings.

That's precisely what they are meant for... unlike space-indentation, 
tab-indentation respects you :-)
Using spaces for indent is using *content* to describe *display*. It's messing 
up model with view, just like using <b> instead of <strong>.

Denis
-- 
_________________
vita es estrany
spir.wikidot.com
April 11, 2011
Re: simple display (from: GUI library for D)
On 2011-04-10 17:39:03 -0400, KennyTM~ <kennytm@gmail.com> said:

> On Apr 9, 11 04:26, Adam D. Ruppe wrote:
>> We discussed this first in the GUI library thread, but since it
>> meandered so much, I decided to split off into a new subject. Much
>> of what I say here will be old to anyone who saw the previous thread.
>> There's some new stuff nearer to the bottom though.
>> 
>> I, with input from others, have started writing a little module
>> for simple uses of a display. You can write to a bitmap, display it
>> to a window, and handle events all in an easy way. The basics are
>> cross platform, but you can use native function calls too.
>> 
>> http://arsdnet.net/dcode/simpledisplay.d
>> 
>> It's still very much in progress, but I think it's now at the point
>> where the direction I'm taking it is clear.
>> 
> [snip]
> 
> Thanks for the great work!
> 
> Taking the version on that link, I have ported it to use the native 
> Cocoa/Core Graphics in OS X, instead of X11. You can check out the diff 
> in https://github.com/kennytm/simpledisplay.d/commit/a790.

Nice, you're the second one to do that. :-) (I made a Cocoa port of the 
earlier version when all there was to do was image.display(), but I 
didn't release the code.)

The major difference between our approaches is that I made it by 
putting Objective-C code in a separate Objective-C file instead of 
doing that objc_msgSend boilerplate directly in D.


> Only Snow Leopard (10.6) is supported.
> 
> I have only tested that it works on the pendulum example and the HSL 
> picker, so things like drawText and drawPixel may not work properly 
> yet. The implementation part is quite messy right now due to 
> Objective-C.

Ideally we'd be using the extern(Objective-C) syntax I'm working on, 
but I still have polishing to do on that thing before it's ready to be 
integrated in mainline DMD (and then it'll probably take some time 
before Walter reviews and applies the pull request) so it's not an 
option right now.


-- 
Michel Fortin
michel.fortin@michelf.com
http://michelf.com/
April 11, 2011
Re: simple display (from: GUI library for D)
On 2011-04-11 11:41, KennyTM~ wrote:
> On Apr 11, 11 15:43, Jacob Carlborg wrote:
>> When using objc_msgSend and friends you need to cast the function to the
>> right signature, to the same signature as the method you're calling via
>> objc_msgSend, before calling it. See
>> http://www.dsource.org/projects/dstep/browser/dstep/objc/message.d#L74
>>
>> If you start passing floats to objc_msgSend you'll soon notice that you
>> get some weird behaviors if you don't cast it to the right signature.
>>
>> You also need to use different versions of objc_msgSend depending on
>> what the return type is and on that platform you're on. If you're
>> returning a struct or an floating point number of some kind you need to
>> use a different version of objc_msgSend. You can have a look at:
>> http://www.dsource.org/projects/dstep/browser/dstep/objc/bridge/Bridge.d#L779
>>
>> . Also look the function being called:
>> http://www.dsource.org/projects/dstep/browser/dstep/objc/message.d
>
> Yes I know. Since all objc_msgSend used only operate on integers and
> pointers and structs and doubles, and they only return pointers or void,
> I didn't bother to cast them.

Fair point. But since we are talking about GUI libraries, images and 
drawing 2D graphics it's most likely floating point numbers will be used 
eventually, at least somewhere.

> Anyway, those calls are now updated to handled it properly, please check
> https://github.com/kennytm/simpledisplay.d/commit/18b6.

Ok.

-- 
/Jacob Carlborg
April 11, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
Jonathan M Davis Wrote:

> So, if 
> you do use tabs, you will end up with mixed tabs and spaces unless everyone 
> involved is very careful, which isn't going to happen.

If no one is careful, you end up with mixed tabs and spaces, no matter what policies you're trying to enforce.
April 11, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
Jonathan M Davis Wrote:

> Every place that I've ever worked 
> at has gone for spaces only, and I've only ever heard of one place where it 
> was required that tabs be used for indentation. I'm sure that there are 
> others, but it's rare that I've heard of anyone thinking that using tabs in 
> code was a good idea.

People often follow wrong traditions blindly.
April 11, 2011
Re: [OT] Spaces/tabs (Was: simple display (from: GUI library for D))
bearophile:
> It's a module theoretically meant for Phobos, and the Phobos coding
> standard are spaces.

Yeah, that's all that matters in the end. "When in Rome..."

But it's trivial to do a find and replace all before submitting so
really, it's just not a big deal.
2 3 4 5 6 7 8 9 10
Top | Discussion index | About this forum | D home