Re: Is DUB the best place to get examples of "Best of" D code?

2016-02-27 Thread Nicholas Wilson via Digitalmars-d-learn

On Sunday, 28 February 2016 at 05:59:39 UTC, WhatMeWorry wrote:


If so, is there a way to do a global search of all projects in 
DUB?


Aside downloading them all and loading them into an IDE, Ctrl+F 
for keywords in the description.


For what purpose?
Learning?
Ctrl+F finds me http://code.dlang.org/packages/dlang_koans.
But Ali's book is probably the best place to start.

Showing off?
Not sure...
Probably articles, blog posts and dconf videos/slides

Nic


Is DUB the best place to get examples of "Best of" D code?

2016-02-27 Thread WhatMeWorry via Digitalmars-d-learn


If so, is there a way to do a global search of all projects in 
DUB?





Re: Why we cannot use string in mixins?

2016-02-27 Thread sigod via Digitalmars-d-learn

On Saturday, 27 February 2016 at 23:43:07 UTC, cym13 wrote:
Could you please provide a link to said comment? Maybe some 
context would help bring some sanity over this statement.


Topic: 
https://www.reddit.com/r/programming/comments/30sqtd/why_didnt_the_d_language_become_mainstream_as/


Said comment: 
https://www.reddit.com/r/programming/comments/30sqtd/why_didnt_the_d_language_become_mainstream_as/cpvwdkb




Re: Installing DUB on OSX

2016-02-27 Thread Joel via Digitalmars-d-learn

On Friday, 26 February 2016 at 08:03:19 UTC, Jacob Carlborg wrote:

On 2016-02-25 22:38, Joel wrote:


.dub is grayed out on Finder, and isn't writable.


I'm suspecting that you don't own that directory. You can see 
the owner by running this:


ls -l -a ~/ | grep dub

The third column is the owner. You change the owner like this 
from the Terminal:


sudo chown -R joelcnz ~/.dub

Assuming "joelcnz" is your user account name.

If you do are the owner then it looks like the directory isn't 
writable. You can check that with the same "ls" command. The 
permissions are in the first column. It should look like this:


drwxr-xr-x

Meaning writable, readable and executable by the owner. 
Readable and executable by the group, readable and executable 
by everyone else. To make it have those exact permissions, run 
the following:


chmod 755 ~/.dub


Things just silently not work.

Joels-MacBook-Pro:packages joelcnz$ ls -l -a ~/ | grep dub
drwxr-xr-x4 joelcnz  staff 136 26 Sep 12:47 .dub
Joels-MacBook-Pro:packages joelcnz$


Re: Why we cannot use string in mixins?

2016-02-27 Thread mahdi via Digitalmars-d-learn

Thanks.

So the author was plain wrong about using enums instead of 
strings. The misconception is due to assuming we can use `string` 
variables at compile time but we cannot (as they are run-time 
data).


Re: Why we cannot use string in mixins?

2016-02-27 Thread Chris Wright via Digitalmars-d-learn
On Sat, 27 Feb 2016 23:29:49 +, mahdi wrote:

> I read this criticism about D on Reddit and it claims that you cannot
> use strings in mixins. Can you please elaborate about this and the
> reason behind it?
> 
> QUOTE:
> Look at strings: they are defined as immutable(char []).

That would be an immutable array pointing to immutable characters. That 
is, you have a (length, pointer) tuple; the tuple and its members can't 
be modified.

In other words, this isn't valid:

  immutable(char[]) s = "hello";
  s = "world";

Because you'd be overwriting the pointer and length properties of `s`.

If `string` were an alias to `immutable(char[])`, that would be pretty 
inconvenient.

Instead, strings are defined as immutable(char)[]. That's a (length, 
pointer) tuple; the length and the pointer are mutable. However, the data 
that the pointer points to cannot be modified.

> "immutable" as in "you could put it in ROM",

immutable means you could mprotect(2) that data as readonly and it 
wouldn't change how the program runs. You can come up with mutable data 
at runtime and then make an immutable copy of it. Arrays, for instance, 
have a special property, idup, that yields an immutable copy. You can 
create a class which can be constructed as an immutable instance.

enum, on the other hand, means that the data (and anything it points to) 
must be known at compile time. It's all in the binary's data segment.

> ... CTFE can't see strings correctly (can't be determined at compile
> time).

CTFE is performed at compile time. The person was complaining that all 
strings must be determined at compile time. This objection doesn't even 
make sense given their misconceptions about the meaning of 'immutable'.

> So rather than fix the compiler
> so that strings can be used in mixins in the way that people expect it
> to work even if that means making them something other than
> immutable(char []), they decided to start using enums where strings
> actually go. Seriously: take the same code and replace 'string "foo"'
> with 'enum "foo"' and it starts to work!

Neither of those examples are valid D syntax.

The person might have observed something like: you can declare a variable 
as a string initialized with a compile-time constant. Then you try to use 
it as a template parameter or a CTFE function parameter. It fails, 
complaining that you tried to use a variable that's not a compile-time 
constant. You replace `string` with `enum` and it works.

In other words, you replace a mutable pointer and length with a compile-
time constant and suddenly you can use it as a compile-time constant. I'm 
sure this is shocking.


Re: Why we cannot use string in mixins?

2016-02-27 Thread Rikki Cattermole via Digitalmars-d-learn

On 28/02/16 12:43 PM, cym13 wrote:

On Saturday, 27 February 2016 at 23:29:49 UTC, mahdi wrote:

I read this criticism about D on Reddit and it claims that you cannot
use strings in mixins. Can you please elaborate about this and the
reason behind it?

QUOTE:
Look at strings: they are defined as immutable(char []). "immutable"
as in "you could put it in ROM", ... CTFE can't see strings correctly
(can't be determined at compile time). So rather than fix the compiler
so that strings can be used in mixins in the way that people expect it
to work even if that means making them something other than
immutable(char []), they decided to start using enums where strings
actually go. Seriously: take the same code and replace 'string "foo"'
with 'enum "foo"' and it starts to work!
END QUOTE


This sounds like (please, pardon my language) a shitty load of bullshit
from an incompetent that didn't know what he's talking about (that's
excusable) and didn't try to understand it better before going on a
pointless rant (that's not).

Could you please provide a link to said comment? Maybe some context
would help bring some sanity over this statement.


I looked it up via Google. You basically said it right.

The user has since been deleted. Every point they made had not only been 
debunked but shown to be as useful as this one, the first one.


Re: Why we cannot use string in mixins?

2016-02-27 Thread ag0aep6g via Digitalmars-d-learn

On 28.02.2016 00:29, mahdi wrote:

I read this criticism about D on Reddit and it claims that you cannot
use strings in mixins. Can you please elaborate about this and the
reason behind it?

QUOTE:
Look at strings: they are defined as immutable(char []).


immutable(char)[] actually


"immutable" as
in "you could put it in ROM", ... CTFE can't see strings correctly
(can't be determined at compile time). So rather than fix the compiler
so that strings can be used in mixins in the way that people expect it
to work even if that means making them something other than
immutable(char []), they decided to start using enums where strings
actually go. Seriously: take the same code and replace 'string "foo"'
with 'enum "foo"' and it starts to work!
END QUOTE


I can only guess that something like this is the perceived problem:


string hello(string who) {return "hello " ~ who;}
void main()
{
string w = "world";
static string hw = hello(w); /* Error: variable w cannot be read at 
compile time */

}


The poster seems to be puzzled as to why the compiler refuses to see 
that `w` is a constant. It's even marked "immutable"!


As noted above, `w` is not immutable, though. Only the elements are. 
Also, `immutable` does not mean that the value is a compile time 
constant. Immutable values can be constructed at run time, and then they 
can't be used at compile time, obviously. `enum` values, on the other 
hand, are compile time constants.


Re: Why we cannot use string in mixins?

2016-02-27 Thread cym13 via Digitalmars-d-learn

On Saturday, 27 February 2016 at 23:29:49 UTC, mahdi wrote:
I read this criticism about D on Reddit and it claims that you 
cannot use strings in mixins. Can you please elaborate about 
this and the reason behind it?


QUOTE:
Look at strings: they are defined as immutable(char []). 
"immutable" as in "you could put it in ROM", ... CTFE can't see 
strings correctly (can't be determined at compile time). So 
rather than fix the compiler so that strings can be used in 
mixins in the way that people expect it to work even if that 
means making them something other than immutable(char []), they 
decided to start using enums where strings actually go. 
Seriously: take the same code and replace 'string "foo"' with 
'enum "foo"' and it starts to work!

END QUOTE


This sounds like (please, pardon my language) a shitty load of 
bullshit from an incompetent that didn't know what he's talking 
about (that's excusable) and didn't try to understand it better 
before going on a pointless rant (that's not).


Could you please provide a link to said comment? Maybe some 
context would help bring some sanity over this statement.


Why we cannot use string in mixins?

2016-02-27 Thread mahdi via Digitalmars-d-learn
I read this criticism about D on Reddit and it claims that you 
cannot use strings in mixins. Can you please elaborate about this 
and the reason behind it?


QUOTE:
Look at strings: they are defined as immutable(char []). 
"immutable" as in "you could put it in ROM", ... CTFE can't see 
strings correctly (can't be determined at compile time). So 
rather than fix the compiler so that strings can be used in 
mixins in the way that people expect it to work even if that 
means making them something other than immutable(char []), they 
decided to start using enums where strings actually go. 
Seriously: take the same code and replace 'string "foo"' with 
'enum "foo"' and it starts to work!

END QUOTE


Re: How to better organize dub project to get 3 exe from same codebase?

2016-02-27 Thread Zardoz via Digitalmars-d-learn

On Saturday, 27 February 2016 at 13:56:21 UTC, Suliman wrote:
What I am doing wrong? 
http://img.ctrlv.in/img/16/02/27/56d1aae37b77a.png


Try :

dub build code1:App1
dub build code1:App2


Re: Calling python code from D

2016-02-27 Thread Ellery Newcomer via Digitalmars-d-learn

On Thursday, 25 February 2016 at 21:40:45 UTC, Wyatt wrote:
I have a project I started in Python before I realised I really 
don't enjoy Python.  It's been on the back-burner for a few 
years and I'd like to start again in D, but there's a 
particular python module (Mutagen) that I outright refuse to 
reimplement.  What's the state of the art in calling Python 
code from D?


I have a hunch PyD fits somewhere in this equation, but the 
documentation is pretty sparse, and what little I can find 
about this area makes it seem like a fairly tedious manual 
process.  Is there a less-painful and intensive way to truss 
things up?  Something to generate a simple D wrapper from a 
python module?


-Wyatt


If you want to call python from D, you should be able to install 
pyd with dub. Depending on your python setup, it should Just 
Work. If python is set up weird (ubuntu), you will need to 
generate some custom dub config and insert it in your dub.json. 
look for generate_dub_config.py on github for the generation 
part. or install pyd with pip and run python -m 
pyd.generate_dub_config


after that, you should be good to go. some example usage off the 
top of my head that probably doesn't compile:


py_init();
InterpContext context = new InterpContext();
context.pystmts(`
  from mutagen.flac import FLAC
  audio = FLAC("example.flac")
  audio["title"] = "An example"
`);
auto audio = context.audio;
audio.pprint();
audio.save();


Re: How to better organize dub project to get 3 exe from same codebase?

2016-02-27 Thread Suliman via Digitalmars-d-learn
What I am doing wrong? 
http://img.ctrlv.in/img/16/02/27/56d1aae37b77a.png


Re: Trouble installing DCD on Windows

2016-02-27 Thread BBasile via Digitalmars-d-learn

On Saturday, 27 February 2016 at 10:16:53 UTC, Minas Mina wrote:

Hello.
I'm trying to install DCD on windows 8.1 using DUB but I get an 
error.


When executing "dub build --build=release --config=client" I 
get the following error:
=> Root package dcd contains reference to invalid package 
libdparse >=0.5.0 <0.6.0 <=


run the build.bat file located in the repository, you'll be more 
lucky, but take care to run "git submodule update --init 
--recursive" before (if not already done of course).


Trouble installing DCD on Windows

2016-02-27 Thread Minas Mina via Digitalmars-d-learn

Hello.
I'm trying to install DCD on windows 8.1 using DUB but I get an 
error.


When executing "dub build --build=release --config=client" I get 
the following error:
=> Root package dcd contains reference to invalid package 
libdparse >=0.5.0 <0.6.0 <=





Re: How to make a progressbar with DWT?

2016-02-27 Thread aa via Digitalmars-d-learn

On Saturday, 27 February 2016 at 09:09:59 UTC, xky wrote:

Hello :-)
Well.. In java with SWT case, used asyncExec and Runnable class.
how can i do processing?


sorry i misunderstood your question, so please ignore about link.


Re: How to make a progressbar with DWT?

2016-02-27 Thread aa via Digitalmars-d-learn

On Saturday, 27 February 2016 at 09:09:59 UTC, xky wrote:

Hello :-)
Well.. In java with SWT case, used asyncExec and Runnable class.
how can i do processing?


https://github.com/d-widget-toolkit/org.eclipse.swt.snippets/blob/4d3e76073e1901622dec80b6a3e24eebbaf6b68d/src/org/eclipse/swt/snippets/Snippet7.d


How to make a progressbar with DWT?

2016-02-27 Thread xky via Digitalmars-d-learn

Hello :-)
Well.. In java with SWT case, used asyncExec and Runnable class.
how can i do processing?