Re: Boy, std.bitmanip.bigEndianToNative is annoying to use

On Friday, 22 May 2015 at 19:44:59 UTC, H. S. Teoh wrote:
> On Fri, May 22, 2015 at 12:39:12PM -0700, H. S. Teoh via 
> Digitalmars-d wrote:
> [...]
>> 	face.palm();
>> 	head.hang!inShame();
>> 	self.crawlBackTo(hole);
> [...]
>
> Truth be told, though, the error message was very unhelpful 
> about it. It
> just says no templates were matched, no indication about the 
> fact that
> the problem was caused by mismatched type lengths.

Well, I'm not sure how we could fix that. That's a general 
problem with template constraints. You know that they aren't 
passing, but you don't know _why_ they aren't passing. Though 
maybe in this case, the docs could be improved to make it clearer 
that if you're getting compilation errors, there's a decent 
chance that you got the type sizes wrong.

- Jonathan M Davis

Re: Boy, std.bitmanip.bigEndianToNative is annoying to use

On Friday, 22 May 2015 at 19:10:41 UTC, H. S. Teoh wrote:
> In the spirit of forum bickering, ;-) I stumbled upon this D 
> wart today:
> I'm reading some data from a file into a ubyte[] buffer, and I 
> want to
> use bigEndianToNative to convert ushort values in the file data 
> into
> native byte order (whatever the native order might be).
>
> Sounds simple, right? Unfortunately, bigEndianToNative asks for 
> ubyte[n]
> as input. Meaning, this doesn't work:
>
> 	ubyte[] buf = ... /* allocate buffer here */;
> 	file.rawRead(buf);	// Read the data
>
> 	ushort myValue = bigEndianToNative!ushort(buf[4 .. 8]); // NG
>
> The last line doesn't compile, 'cos you can't convert a slice 
> of ubyte[]
> into ubyte[4].
>
> I can think of no easy way to declare a temporary ubyte[4] to 
> make
> bigEndianToNative happy, other than this silly verbosity:
>
> 	ubyte[4] tmp;
> 	tmp[] = buf[4 .. 8];
> 	ushort myValue = bigEndianToNative!ushort(tmp);
>
(Continue reading)

Boy, std.bitmanip.bigEndianToNative is annoying to use

In the spirit of forum bickering, ;-) I stumbled upon this D wart today:
I'm reading some data from a file into a ubyte[] buffer, and I want to
use bigEndianToNative to convert ushort values in the file data into
native byte order (whatever the native order might be).

Sounds simple, right? Unfortunately, bigEndianToNative asks for ubyte[n]
as input. Meaning, this doesn't work:

	ubyte[] buf = ... /* allocate buffer here */;
	file.rawRead(buf);	// Read the data

	ushort myValue = bigEndianToNative!ushort(buf[4 .. 8]); // NG

The last line doesn't compile, 'cos you can't convert a slice of ubyte[]
into ubyte[4].

I can think of no easy way to declare a temporary ubyte[4] to make
bigEndianToNative happy, other than this silly verbosity:

	ubyte[4] tmp;
	tmp[] = buf[4 .. 8];
	ushort myValue = bigEndianToNative!ushort(tmp);

and I have to do this for every single numerical field in the data
buffer that I need to convert. :-(  Why should I copy data around that's
already sitting in a ubyte[] buffer intended precisely for the purpose
of doing such conversions in the first place??

The docs for bigEndianToNative claims that this is to help "prevent
accidentally using a swapped value as a regular one". But I say, "Why,
(Continue reading)

PTHREAD_MUTEX_INITIALIZER seems defined wrongly on OSX

Any OSX experts could weigh on this? 
https://issues.dlang.org/show_bug.cgi?id=14617. Thanks! -- Andrei

Chris via Digitalmars-d | 22 May 19:49 2015

D installer installs outdated D

So I found myself in this page: 
http://wiki.dlang.org/Installing_DMD

Which says: Easiest and fastest way to get your DMD running on MS 
Windows is to use DInstaller

So if I download and run DInstaller, I get D v2.062

This caused me a large amount of frustration until I realized I 
was working with an outdated version :(

Re: Uphill

On Friday, 22 May 2015 at 17:05:10 UTC, H. S. Teoh wrote:
> Agreed, D does have its warts and dark corners, but overall it's
> extremely awesome. I just can't bring myself to starting new 
> projects in
> any other language these days (unless I get paid to do it, of 
> course).
> D has totally wrecked my life, and it's all yall's fault!! j/k

LOL. The problem I have is that I'm not learning any new 
languages anymore. Not only do I never have enough time to do all 
that I want to get done with D itself, but if I'm working on a 
project that I care about at all, I want to do it in D. But in my 
experience, to really learn a new language, you need to either be 
using it all the time at work, or you need to be using it as you 
go-to language for all of your side projects. If you don't, you 
don't really end up using it enough to really learn it. And since 
I really want to be doing my side projects in D (and I work in 
C++), I'm really not experimenting with other languages much, and 
I'm definitely not learning them well. I haven't even learned 
C++11/14 properly, because I can't use it at work yet, and almost 
all the programming I do in my free time is in D.

But everything other than D is just so frustrating anyway. ;)

- Jonathan M Davis

Chris via Digitalmars-d | 22 May 19:16 2015

Re: Uphill

On Friday, 22 May 2015 at 17:05:10 UTC, H. S. Teoh wrote:
> On Fri, May 22, 2015 at 04:00:28PM +0000, Jonathan M Davis via 
> Digitalmars-d wrote:
>> On Friday, 22 May 2015 at 14:11:49 UTC, H. S. Teoh wrote:
>> >+1, finally, something other than the usual bickering on the 
>> >forum.
>> >;-)
>> 
>> LOL. Don't worry. I'm sure that someone will come along and 
>> start
>> griping about something soon.
>> 
>> :(
>> 
>> Joking aside, we do seem to frequently have the problem that 
>> what we
>> have is good enough that folks expect it to be perfect and 
>> thus start
>> complaining about how we don't do something well enough when we
>> actually do it better than most anyone else. D certainly isn't 
>> perfect
>> - and we _do_ have areas to improve upon - but we what we do 
>> have is
>> pretty darn awesome.
> [...]
>
> Agreed, D does have its warts and dark corners, but overall it's
> extremely awesome. I just can't bring myself to starting new 
> projects in
> any other language these days
(Continue reading)

indie game contests

I know there's a strong gamedev presence here, so I'm wondering 
if anyone's submitted any games written in D to any of these 
contests? What was your experience like?

I'd like to enter one, and wonder if anyone would be interested 
in a collaboration.

Outside of programming, I used to do low-poly 3d art (just as a 
hobby in my secondary school days), so I can potentially 
contribute visuals, and I'm pretty comfortable with openGL.

Re: Uphill

On Friday, 22 May 2015 at 14:11:49 UTC, H. S. Teoh wrote:
> +1, finally, something other than the usual bickering on the 
> forum. ;-)

LOL. Don't worry. I'm sure that someone will come along and start 
griping about something soon.

:(

Joking aside, we do seem to frequently have the problem that what 
we have is good enough that folks expect it to be perfect and 
thus start complaining about how we don't do something well 
enough when we actually do it better than most anyone else. D 
certainly isn't perfect - and we _do_ have areas to improve upon 
- but we what we do have is pretty darn awesome.

- Jonathan M Davis

Chris via Digitalmars-d | 22 May 12:21 2015

Uphill

I was recently thinking that D is a bit like climbing up a hill 
or a mountain. For the most part you are focused on reaching the 
top, yet every once in a while it's good to stop and turn around 
to enjoy the scenery and see how far you've come. So here is what 
I see:

- LDC/GDC: easy to download and use. Nicely packaged.
- DUB: great tool for project management
- DVM: great tool for upgrading from D to D.
- Phobos: has become quite a useful library. Ranges are an 
important part of data processing, I don't wanna miss 'em anymore
- vibe.d: a web server in D.
- Projects in D: LuaD, PyD etc etc.
- the expertise that's involved
[add anything you like]

Mind you, this has been achieved without millions of dollars and 
corporate backing and yet D is a real language with real 
applications (only nobody talks about it). I know, there is still 
a steep climb ahead of D, but let's enjoy the view for a while. 
What has been achieved is by no means trivial.

tcak via Digitalmars-d | 21 May 23:08 2015

Skipping function parameters with default value

Does D has an aim to be convertible back to C code easily?

I want to define a function as follows:

mysqlConnect( string host="localhost", string username, string 
password=null );

I was expecting that I could call the function as follows:

mysqlConnect( , "root" );

But, it neither allows me to define the function in that way, or 
allows me to call the function in that way even if I give a 
default value to username parameter. Would it be possible to 
allow a syntax as above?

This could open the doors to set parameters by giving parameter 
name as well.


Gmane