Re: Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
Looking at the std.concurrency code, it appears that Tid is just a handle to a class, so multiple assignments should all refer to the same underlying class, and it looks like that underlying class (MessageBox) uses mutexes to ensure safe handling of multiple access. So this shared access to

Re: Passing Structs to function like in C

2016-08-14 Thread Cauterite via Digitalmars-d-learn
On Sunday, 14 August 2016 at 16:21:58 UTC, D.Rex wrote: so '();' works the same as 'foo.bar();'? with pointers, D automatically rewrites expressions like this: f.fooMethod() to this: (*f).fooMethod() which is why you're able to index an object-pointer-pointer (Foo*) the same

Re: DUB saying my Linux exe file is "not an executable file" even though DUB built it

2016-08-14 Thread WhatMeWorry via Digitalmars-d-learn
This is the actual problem that cause trouble. Your flash drive is probably Fat32 or NTFS formatted rather than ext4. Since those file systems do not support "executable attribute", Linux will silently fail to give files the attribute which results in these sort of surprises. You may wonder

Re: Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
On 08/14/2016 07:44 AM, Charles Hixson via Digitalmars-d-learn wrote: This is an approach to n x n thread message passing. The idea is that each thread should be able to pass messages to any other thread. The only alternative I've come up with involves the main thread handling each message.

Re: Caesar Cipher Cracking

2016-08-14 Thread Stefan via Digitalmars-d-learn
same code, just a little shorter. usage of ".array" more UFCS replaced cast with ".to" ---8><--- import std.stdio, std.conv; import std.algorithm, std.algorithm.searching, std.range; import std.ascii, std.string : countchars; int let2int(char c)

Re: Privacy violation depending on who passes a compile-time argument?

2016-08-14 Thread rcorre via Digitalmars-d-learn
On Sunday, 14 August 2016 at 17:23:06 UTC, Basile B. wrote: It is private: https://dpaste.dzfl.pl/83fcca84dde3, so the code you've posted in the first message could be a bug. Ah, you're correct. I'm not able to use either of them in runtime code. The deprecation message also since this

Re: Privacy violation depending on who passes a compile-time argument?

2016-08-14 Thread Basile B. via Digitalmars-d-learn
On Sunday, 14 August 2016 at 17:23:06 UTC, Basile B. wrote: On Sunday, 14 August 2016 at 16:34:48 UTC, rcorre wrote: On Sunday, 14 August 2016 at 15:47:16 UTC, Basile B. wrote: getMember_i is just an alias to that, so shouldn't it also be private? It is private:

Re: Privacy violation depending on who passes a compile-time argument?

2016-08-14 Thread Basile B. via Digitalmars-d-learn
On Sunday, 14 August 2016 at 16:34:48 UTC, rcorre wrote: On Sunday, 14 August 2016 at 15:47:16 UTC, Basile B. wrote: getMember_i is just an alias to that, so shouldn't it also be private? It is private: https://dpaste.dzfl.pl/83fcca84dde3, so the code you've posted in the first message could

Re: Privacy violation depending on who passes a compile-time argument?

2016-08-14 Thread rcorre via Digitalmars-d-learn
On Sunday, 14 August 2016 at 15:47:16 UTC, Basile B. wrote: No it's the opposite, only mixins gets the scope of the instantiation's location. Right, if it were a mixin, it would get the scope of the instantiation (the main module) and `i` would be inacessible. Since it isn't a mixin, I

Re: static immutable and lambdas inside struct or class. Is that bug or not?

2016-08-14 Thread Uranuz via Digitalmars-d-learn
On Sunday, 14 August 2016 at 15:53:21 UTC, ag0aep6g wrote: On 08/14/2016 04:27 PM, Uranuz wrote: [...] Looks like a compiler bug, since it works without the struct: import std.algorithm: map; import std.array: array; import std.typecons: tuple; immutable aaa = [ tuple("1",

Re: Passing Structs to function like in C

2016-08-14 Thread D.Rex via Digitalmars-d-learn
On Sunday, 14 August 2016 at 14:59:17 UTC, Adam D. Ruppe wrote: On Sunday, 14 August 2016 at 14:54:27 UTC, D.Rex wrote: Speaking of classes, and this may have been answered elsewhere, but I am yet to find said answer, or am just missing something right in front of my face...but how does one

Re: static immutable and lambdas inside struct or class. Is that bug or not?

2016-08-14 Thread ag0aep6g via Digitalmars-d-learn
On 08/14/2016 04:27 PM, Uranuz wrote: Greatings! I need help with these lines bellow. I don't understand why it doesn't compile. Is it bug somewhere in Phobos or compiler? Or just I wrote smth wrong? //- struct A { import std.algorithm: map; import std.array: array; import

Re: Privacy violation depending on who passes a compile-time argument?

2016-08-14 Thread Basile B. via Digitalmars-d-learn
On Sunday, 14 August 2016 at 12:03:28 UTC, rcorre wrote: Can someone help me understand why the first line is fine, but the second triggers a deprecation warning for access to a private variable? --- import std.traits; import s; pragma(msg, hasUDA!(S.getMember_i, attr)); // fine

Re: Passing Structs to function like in C

2016-08-14 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 14 August 2016 at 14:54:27 UTC, D.Rex wrote: Speaking of classes, and this may have been answered elsewhere, but I am yet to find said answer, or am just missing something right in front of my face...but how does one go about accessing a method from a class if said class is passed

Re: Passing Structs to function like in C

2016-08-14 Thread D.Rex via Digitalmars-d-learn
On Saturday, 13 August 2016 at 18:37:54 UTC, Cauterite wrote: On Saturday, 13 August 2016 at 15:47:51 UTC, D.Rex wrote: /* memory.d file */ module memory; import include.linux.sched;/* contains task_struct definition */ void free_page_tables(task_struct* tsk) { /* do something

Re: Passing Structs to function like in C

2016-08-14 Thread D.Rex via Digitalmars-d-learn
On Saturday, 13 August 2016 at 18:37:54 UTC, Cauterite wrote: On Saturday, 13 August 2016 at 15:47:51 UTC, D.Rex wrote: /* memory.d file */ module memory; import include.linux.sched;/* contains task_struct definition */ void free_page_tables(task_struct* tsk) { /* do something

Multi-Thread message passing approach

2016-08-14 Thread Charles Hixson via Digitalmars-d-learn
This is an approach to n x n thread message passing. The idea is that each thread should be able to pass messages to any other thread. The only alternative I've come up with involves the main thread handling each message. Is that a better approach? Is there a better way to pass lists of

static immutable and lambdas inside struct or class. Is that bug or not?

2016-08-14 Thread Uranuz via Digitalmars-d-learn
Greatings! I need help with these lines bellow. I don't understand why it doesn't compile. Is it bug somewhere in Phobos or compiler? Or just I wrote smth wrong? //- struct A { import std.algorithm: map; import std.array: array; import std.typecons: tuple;

Privacy violation depending on who passes a compile-time argument?

2016-08-14 Thread rcorre via Digitalmars-d-learn
Can someone help me understand why the first line is fine, but the second triggers a deprecation warning for access to a private variable? --- import std.traits; import s; pragma(msg, hasUDA!(S.getMember_i, attr)); // fine pragma(msg, hasUDA!(S.getMember!"i", attr)); // deprecated /++ in

Caesar Cipher Cracking

2016-08-14 Thread Antonio Corbi via Digitalmars-d-learn
Hi folks, I was just following Graham Hutton's excellent book "Programming in Haskell" (http://www.cs.nott.ac.uk/~pszgmh/book.html) and in chapter 5 He implements a Caesar-Cipher cracking algorithm in a few lines of Haskell code (http://www.cs.nott.ac.uk/~pszgmh/cipher.lhs). So, as I'm

Re: DUB saying my Linux exe file is "not an executable file" even though DUB built it

2016-08-14 Thread NX via Digitalmars-d-learn
On Sunday, 14 August 2016 at 03:10:28 UTC, WhatMeWorry wrote: On Sunday, 14 August 2016 at 01:05:33 UTC, Basile B. wrote: On Saturday, 13 August 2016 at 21:56:49 UTC, WhatMeWorry wrote: $ sudo chmod -v 777 * mode of 'HelloWindow' changed from 0644 (rw-r--r--) to 0777 (rwxrwxrwx) $ ls -al