Re: AST like coding syntax. Easy upgrade!

2015-09-07 Thread Dmitry Olshansky via Digitalmars-d

On 07-Sep-2015 08:25, anonymous wrote:

On Monday 07 September 2015 02:24, Idan Arye wrote:


That's not considered as syntax check - that's an earlier stage
of the compilation process called "lexical
analysis"(https://en.wikipedia.org/wiki/Lexical_analysis)


 From the Wikipedia article: "a lexer is generally combined with a parser,
which together analyze the syntax".


No in this case obviously.

--
Dmitry Olshansky


Re: Unordered Element Pairs of a Range

2015-09-07 Thread cym13 via Digitalmars-d-learn

On Monday, 7 September 2015 at 09:06:05 UTC, Nordlöw wrote:
Is there a range in Phobos for accessing all unordered 
combinations of a range as:


foreach (const i, const a; r)
{
for (auto j = i + 1; j < r.length; ++j)
{
const b = r[j];
// Use a and b
}
}

excluding self-pairs, that is i != j


There is an open bug for that 
https://issues.dlang.org/show_bug.cgi?id=6788


[Issue 14140] Bad codegen for CTFE union initialisers for immutable structs

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14140

Kenji Hara  changed:

   What|Removed |Added

   Keywords||pull, wrong-code

--- Comment #4 from Kenji Hara  ---
https://github.com/D-Programming-Language/dmd/pull/5050

--


Using dub configurations with libraries

2015-09-07 Thread FreeSlave via Digitalmars-d-learn

Let's say I have two dub packages: A and B.
A is a library. B is library or application (does not matter) and 
depends on A.


A has several configurations in dub.json.

How to build the B package that way it will use non-default 
configuration of A?


Re: Benchmarking suite

2015-09-07 Thread Dmitry Olshansky via Digitalmars-d

On 07-Sep-2015 11:29, qznc wrote:

Maybe std.regex has just space for optimization?


Sure thing, see WIP here (~25% faster but not yet complete):
https://github.com/D-Programming-Language/phobos/pull/3314

--
Dmitry Olshansky


[Issue 15020] New: pragma(lib) not implemented with 2.068.1

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15020

  Issue ID: 15020
   Summary: pragma(lib) not implemented with 2.068.1
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: regression
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: chalu...@gmail.com

With 2.068.1 out, I tried today to recompile some vibe server and gets this
errors:

...\dub\packages\libasync-0.7.5\source\libasync\windows.d:22:1: error:
pragma(lib) not implemented [-Werror]
 pragma(lib, "ws2_32");
 ^
...\dub\packages\libasync-0.7.5\source\libasync\windows.d:23:1: error:
pragma(lib) not implemented [-Werror]
 pragma(lib, "ole32");
 ^
cc1d.exe: all warnings being treated as errors
gdc failed with exit code 1.

In the libasync sources there are these lines:
pragma(lib, "ws2_32");
pragma(lib, "ole32");

This compiles just fine with 2.068.0

I'm on windows 8.1 x86_64

Bug?

--


[Issue 15014] Win64: Invalid C++ mangling for multiple long arguments

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15014

--- Comment #2 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/63f19847131f89a6b526b7d1008b7214b9002dac
Merge pull request #5038 from rainers/issue_15014

Fix issue 15014 - Win64: Invalid C++ mangling for multiple long arguments

--


Re: Benchmarking suite

2015-09-07 Thread qznc via Digitalmars-d

On Sunday, 30 August 2015 at 13:21:42 UTC, qznc wrote:
On Saturday, 29 August 2015 at 19:17:47 UTC, Dmitry Olshansky 
wrote:

On 29-Aug-2015 21:14, qznc wrote:
On Saturday, 29 August 2015 at 12:35:14 UTC, Dmitry Olshansky 
wrote:
Well, here is the regex-dna one with 3 versions including 
C-T regex:


https://github.com/DmitryOlshansky/FReD/blob/master/bench/regex-dna/d_dna.d



Thanks Dmitry!

Which version should be used?


I'd try all of them, I think C-T was the fastest (as it 
should).


Yes, C-T is fastest. Even dmd is faster than C/C++ now. :)


Unfortunately, I have to take that back. C is faster than D even 
with compile-time regexes. I used the short running benchmarks 
first, where compile-time regex wins, probably because it saves 
some startup time. For large data, C is faster. It uses the regex 
engine from TCL. Maybe std.regex has just space for optimization?


I updated the benchmark results: 
https://qznc.github.io/d-shootout/


Odd stacktrace: Access Violation in object.TypeInfo_Interface.getHash

2015-09-07 Thread Fra via Digitalmars-d-learn
I encountered a runtime error in my code and all I can get (even 
in debug mode) is the following stacktrace:


object.Error@(0): Access Violation

0x0051C308 in const(nothrow @trusted uint function(const(void*))) 
object.TypeInfo_Interface.getHash

0x0058D2C0 in D6engine5world5world5World6__vtblZ
Error executing command run: Program exited with code 1

No other information is provided.
Anyone ever experienced anything similar? That __vtblZ part of 
the symbol name scares me a bit, TBH.
The codebase is big, so will take me some time to reduce it to a 
simple example, even if I were to use dustmite, but I was hoping 
that someone faced this error message before and could give me a 
pointer on what to look for.


Re: How To: Passing curried functions around

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

On Monday, 7 September 2015 at 03:55:01 UTC, Meta wrote:
The name validator_t is not idiomatic in D. Something like 
ValidatorFun should be preferred. Same for intReader_t; 
ReadIntFun is probably preferred, or even IntReader (but that 
would imply that it's a struct/class in my mind).


Noted. Thanks.

As for the actual use of partial, it's perfectly fine and 
idiomatic to use.


Good. Now the questions is what should be the signature of the 
receiving functions if I'm going to pass the (double) curried 
function around?


For example, considering the original piece of code, if I do

alias partial!(partial!(readInt, "Enter an integer:"), 
) ReaderFun;


is the following a valid signature for `foo`, to which I'll pass 
a `ReaderFun`?


void foo((int delegate() readerFun)



[Issue 15001] Duplicate error message without line number on if statement

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15001

--- Comment #2 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/36e83282e5c52e1f4dde667fd07138667ff69fea
fix Issue 15001 - Duplicate error message without line number on if statement

https://github.com/D-Programming-Language/dmd/commit/d1cff024654921f4bd1cdfe4f1974cbc013d1a9a
Merge pull request #5020 from 9rnsr/fix15001

Issue 15001 - Duplicate error message without line number on if statement

--


Re: Is D suitable for my latest project?

2015-09-07 Thread Kagamin via Digitalmars-d-learn

On Sunday, 6 September 2015 at 15:15:03 UTC, chris stevens wrote:
I guess you're right it wouldn't be too difficult to do it all 
using strings. The code generation I'd done before in c# I'd 
used some 3rd person library where you build up an object model 
rather than using strings.


Maybe with dparse you can construct an AST and later convert it 
to string.


Re: dmd codegen improvements

2015-09-07 Thread Walter Bright via Digitalmars-d

On 9/6/2015 4:39 PM, Manu via Digitalmars-d wrote:

It didn't happen for me because I changed my gmail settings after
Walter requested some time back to only include plain text. My NG
experience is much less enjoyable as a result of the change; I prefer
the blue quote line, but now I just have a sea of '>' characters after
turning it off. I preferred it before I changed my settings, but
apparently I am invisible spamming.


It is doing the right thing now, yay! :-)

BTW, Thunderbird's n.g. reader will transform the > into the blue line.


[Issue 15020] pragma(lib) not implemented with 2.068.1

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15020

Tomáš Chaloupka  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |INVALID

--- Comment #1 from Tomáš Chaloupka  ---
Hm, it was just that after 2.068.1 installation ower 2.068.0 it ended up with
dmd uninstalled and dub used gdc instead

--


Re: Abstractioning away main/winMain

2015-09-07 Thread Kagamin via Digitalmars-d-learn

On Saturday, 5 September 2015 at 01:43:43 UTC, Prudence wrote:

Any ideas?


See how vibe does it.


Unordered Element Pairs of a Range

2015-09-07 Thread Nordlöw
Is there a range in Phobos for accessing all unordered 
combinations of a range as:


foreach (const i, const a; r)
{
for (auto j = i + 1; j < r.length; ++j)
{
const b = r[j];
// Use a and b
}
}

excluding self-pairs, that is i != j


Re: DCD 0.7.0

2015-09-07 Thread Daniel Kozák via Digitalmars-d-announce

On Sun, 06 Sep 2015 21:00:11 +
Dicebot via Digitalmars-d-announce
 wrote:

> On Wednesday, 2 September 2015 at 09:07:24 UTC, Chris wrote:
> > Thanks, great stuff! One thing you say it's been tested with 
> > 2.067.1, but for this version it gives the following error 
> > message:
> >
> > containers/experimental_allocator/src/std/experimental/allocator/common.d(337):
> > Error: module meta is in file 'std/meta.d' which cannot be read
> > import path[0] = containers/src import path[1] = msgpack-d/src
> > import path[2] = libdparse/src
> > import path[3] = dsymbol/src
> > import path[4] = containers/experimental_allocator/src
> >
> > I had to use 2.068.0 to compile it.
> 
> btw this is also the reason why Arch package is still not updated 
> - waiting until will build with latest LDC

Ohh, that makes sense :)


What are (dis)advantages of using pure and immutable by default?

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn
It seems to me a good practice to mark all functions that I write 
as `pure` and define all the variables as `immutable`, unless 
there is a reason not to.
I can see some serious advantages of this, most notable of which 
is minimum side-effect and predictability of the code.  However I 
suppose it's going to impact the performance and memory footprint 
as well, though I have no idea how deep the impact will be.


I'm pretty sure I'm not the first one to think about this; so 
what would you seasoned D'ers say?




Re: Release D 2.068.1

2015-09-07 Thread anonymous via Digitalmars-d-announce
On Monday 07 September 2015 00:32, Martin Nowak wrote:

> http://downloads.dlang.org/releases/2.x/2.068.1/

Trying to download the 7z Windows file gives me a 403.

http://downloads.dlang.org/releases/2015/dmd.2.068.1.windows.7z


Re: What are (dis)advantages of using pure and immutable by default?

2015-09-07 Thread anonymous via Digitalmars-d-learn
On Monday 07 September 2015 13:12, Bahman Movaqar wrote:

> I was under the impression that when a variable, that is declared 
> as `immutable`, is passed to a function, a copy of the value is 
> passed.
>
> However based on "marks" I can imagine that since the data is 
> marked as `immutable` only a reference is passed; and the 
> compiler guarantees that what is referenced to never changes.  Am 
> I right?

Generally immutable doesn't affect how things are passed around. An 
immutable type is passed the same as a mutable version of it.

Compilers may optimize based on immutability. This may mean that a reference 
is passed instead of a copy, or the other way around. I don't know if 
compilers do such things currently, or how much potential is in that. Also, 
I don't think the language has a stance on that; it's purely an 
optimization.

immutable does affect how you can pass things around, though. An example:


void f(int a) {}
void g(int* a) {}

void main()
{
int xm;
immutable int xi;
f(xm); /* ok, obviously */
f(xi); /* ok */

int* ym = 
immutable int* yi = 
g(ym); /* ok, obviously */
g(yi); /* doesn't compile */
}


f(xi) is ok because when passing an int or an immutable(int), it's copied 
completely. So the f cannot possibly mutate the original immutable variable 
xi.

g(yi) is not ok, because when passing an int* or an immutable(int*), only 
the pointer is copied. So g could dereference yi and mutate the referenced 
immutable variable xi.

The same applies to other forms of references: classes, ref parameters, 
arrays.


Re: Benchmarking suite

2015-09-07 Thread Suliman via Digitalmars-d
On Monday, 7 September 2015 at 08:33:33 UTC, Dmitry Olshansky 
wrote:

On 07-Sep-2015 11:29, qznc wrote:

Maybe std.regex has just space for optimization?


Sure thing, see WIP here (~25% faster but not yet complete):
https://github.com/D-Programming-Language/phobos/pull/3314


Could anybody add C# version of examples?


[Issue 6004] std.range.unzip()

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6004

Edwin van Leeuwen  changed:

   What|Removed |Added

 CC||ed...@tkwsping.nl

--- Comment #2 from Edwin van Leeuwen  ---
(In reply to weaselcat from comment #1)
> I was looking for this in std.range and didn't find anything, came across
> this issue.
> 
> Since this is about 4 years old, was anything like this ever implemented?

I was wondering the same thing.

--


Re: How to partially forward properties of struct array member to struct (disable length property) ?

2015-09-07 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/6/15 3:34 AM, ParticlePeter wrote:

I am working on a struct vector. The data is stored in a member static
array and I want to be able to forward all array properties except
length to vector.
Reason is I have free functions f that take vector(s) as arguments, such
that f(vector) and vector.f via UFCS is possible. Using alias array this
in the case of length function/array property is problematic, as
length(vector) obviously uses the free function but vector.length the
array property.

What would be the simplest way to disable the array.length property for
the vector struct?

I would prefer not to implement length as a vector member function and
call it inside the free function as this is inconsistent with the other
free funcs.



struct vector(T)
{
   T[] _buf;
   alias _buf this;
   auto length() { return .length(this);}
}

-Steve


Re: Behavior of opEquals

2015-09-07 Thread Timon Gehr via Digitalmars-d

On 09/05/2015 08:18 AM, Jonathan M Davis wrote:

On Friday, 4 September 2015 at 20:39:14 UTC, Timon Gehr wrote:

On 09/04/2015 09:21 PM, H. S. Teoh via Digitalmars-d wrote:


Wait, wait, did I miss something? Since when was operator overloading
allowed as free functions?


Since UFCS, but DMD does not implement it.


There is nothing in the spec about supporting operator overloading with
free functions, so I don't know where you get the idea that it's even
intended to be a feature. UFCS applies to functions which use the member
function call syntax, and operators aren't used that way.


Specifying semantics via lowering is somewhat pointless if rewrites are 
not transitive.



There is no plan whatsoever to support operator overloading via free functions.
...


Then specify operator overloading using __traits(getMember,...). (I 
consider this unwise though.)


Better unittest failure output

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

I am working on a simple project created with DUB[1].
When unit tests the output reads really cryptic to me; for 
example:


$ dub test
Generating test runner configuration '__test__library__' for 
'library' (library).

Target dunit 1.0.11 is up to date. Use --force to rebuild.
Building d-etudes ~master configuration "__test__library__", 
build type unittest.

Compiling using dmd...
Linking...
Running ./__test__library__
core.exception.AssertError@source/e002.d(111): unittest 
failure


./__test__library__(void 
detudes.e002.__unittest_fail(int)+0x28) [0x4bf508]
./__test__library__(void 
detudes.e002.__unittestL106_4()+0x17b) [0x4bf47b]
./__test__library__(void detudes.e002.__modtest()+0xe) 
[0x4bf48e]
./__test__library__(int 
core.runtime.runModuleUnitTests().__foreachbody2(object.ModuleInfo*)+0x34) [0x4d0d0c]
./__test__library__(int object.ModuleInfo.opApply(scope int 
delegate(object.ModuleInfo*)).__lambda2(immutable(object.ModuleInfo*))+0x1c) [0x4c1ab4]
./__test__library__(int rt.minfo.moduleinfos_apply(scope int 
delegate(immutable(object.ModuleInfo*))).__foreachbody2(ref 
rt.sections_elf_shared.DSO)+0x46) [0x4c7422]
./__test__library__(int 
rt.sections_elf_shared.DSO.opApply(scope int delegate(ref 
rt.sections_elf_shared.DSO))+0x41) [0x4c7499]
./__test__library__(int rt.minfo.moduleinfos_apply(scope int 
delegate(immutable(object.ModuleInfo*)))+0x20) [0x4c73bc]
./__test__library__(int object.ModuleInfo.opApply(scope int 
delegate(object.ModuleInfo*))+0x20) [0x4c1a90]

./__test__library__(runModuleUnitTests+0x98) [0x4d0bd8]
./__test__library__(void rt.dmain2._d_run_main(int, char**, 
extern (C) int function(char[][])*).runAll()+0x17) [0x4c4147]
./__test__library__(void rt.dmain2._d_run_main(int, char**, 
extern (C) int function(char[][])*).tryExec(scope void 
delegate())+0x2a) [0x4c40fa]

./__test__library__(_d_run_main+0x1d2) [0x4c407a]
./__test__library__(main+0x20) [0x48a968]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) 
[0x7f1f751d9ec5]

Error executing command test:
Program exited with code 1

It is almost impossible for me to comprehend anything useful out 
of this, except that, well, the tests have failed :-)


Is there any compiler switch, argument to `assert` or trick to 
make `unittest` output more helpful messages when failing?


[1] https://github.com/bahmanm/d-etudes


Re: Better unittest failure output

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

On Monday, 7 September 2015 at 12:16:14 UTC, anonymous wrote:

On Monday 07 September 2015 14:12, Bahman Movaqar wrote:

Thanks.  This is indeed helpful.  OT but where can I view the 
documentation for `unittest` and `assert`?


unittest: http://dlang.org/unittest.html
assert: http://dlang.org/expression.html#AssertExpression (I 
don't know why

it's considered an expression and not a statement.)


Thanks.


Re: Release D 2.068.1

2015-09-07 Thread Martin Nowak via Digitalmars-d-announce
On 09/07/2015 12:21 PM, anonymous wrote:
> Trying to download the 7z Windows file gives me a 403.
> 
> http://downloads.dlang.org/releases/2015/dmd.2.068.1.windows.7z

Thanks, I just fixed it. The aws client failed to upload that file and
it was hard to notice in the log output.


Re: Better unittest failure output

2015-09-07 Thread anonymous via Digitalmars-d-learn
On Monday 07 September 2015 13:57, Bahman Movaqar wrote:

> I am working on a simple project created with DUB[1].
> When unit tests the output reads really cryptic to me; for 
> example:
> 
>  $ dub test
[...]
>  core.exception.AssertError@source/e002.d(111): unittest 
> failure
[...]
> 
> It is almost impossible for me to comprehend anything useful out 
> of this, except that, well, the tests have failed :-)

>From that one line I left intact above, you should also be able to figure 
out that it's the test in source/e002.d, line 111 that failed.

> Is there any compiler switch, argument to `assert` or trick to 
> make `unittest` output more helpful messages when failing?

You can pass a custom message as a second argument to assert:
assert(condition, "message goes here");

I think there are testing libraries/frameworks around that mean to provide 
more than the basic built-in things. But I haven't tried any, so I can't 
recommend anything. Try searching for "test" here: http://code.dlang.org/


Re: What are (dis)advantages of using pure and immutable by default?

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

On Monday, 7 September 2015 at 11:49:32 UTC, anonymous wrote:

void f(int a) {}
void g(int* a) {}

void main()
{
int xm;
immutable int xi;
f(xm); /* ok, obviously */
f(xi); /* ok */

int* ym = 
immutable int* yi = 
g(ym); /* ok, obviously */
g(yi); /* doesn't compile */
}


f(xi) is ok because when passing an int or an immutable(int), 
it's copied completely. So the f cannot possibly mutate the 
original immutable variable xi.


g(yi) is not ok, because when passing an int* or an 
immutable(int*), only the pointer is copied. So g could 
dereference yi and mutate the referenced immutable variable xi.


The same applies to other forms of references: classes, ref 
parameters, arrays.


Thanks for the explanation.
So from what I can gather, `immutable`, apart from possible 
compiler-level optimisations, is mainly there to help the 
programmer catch otherwise runtime errors at compile time.


This is nice.  Indeed very helpful in a language when one deals 
with pointers and references.


Re: Better unittest failure output

2015-09-07 Thread Gary Willoughby via Digitalmars-d-learn

On Monday, 7 September 2015 at 11:57:25 UTC, Bahman Movaqar wrote:

I am working on a simple project created with DUB[1].
When unit tests the output reads really cryptic to me; for 
example:


Try using DUnit, it gives you much more readable fail messages:

https://github.com/nomad-software/dunit


Re: Unordered Element Pairs of a Range

2015-09-07 Thread Nordlöw

On Monday, 7 September 2015 at 09:12:53 UTC, cym13 wrote:
There is an open bug for that 
https://issues.dlang.org/show_bug.cgi?id=6788


Thanks.

So I construct a pairwise range with two implementation cases one 
for RandomAccessRange and one for InputRange


https://github.com/nordlow/justd/blob/master/combinations.d#L172

Should this go into Phobos?


Re: What are (dis)advantages of using pure and immutable by default?

2015-09-07 Thread anonymous via Digitalmars-d-learn
On Monday 07 September 2015 12:40, Bahman Movaqar wrote:

> It seems to me a good practice to mark all functions that I write 
> as `pure` and define all the variables as `immutable`, unless 
> there is a reason not to.

I agree.

> I can see some serious advantages of this, most notable of which 
> is minimum side-effect and predictability of the code.  However I 
> suppose it's going to impact the performance and memory footprint 
> as well, though I have no idea how deep the impact will be.

I don't see how merely marking things immutable/pure would affect 
performance negatively. They're just marks on the type. If anything, you 
could get a performance boost from the stricter guarantees. But 
realistically, there won't be a difference.

If you change your algorithms to avoid mutable/impure, then you may see 
worse performance than if you made use of them. But I suppose that would be 
"a reason not to" mark everything immutable/pure.


Re: Odd stacktrace: Access Violation in object.TypeInfo_Interface.getHash

2015-09-07 Thread Nicholas Wilson via Digitalmars-d-learn

On Monday, 7 September 2015 at 08:55:31 UTC, Fra wrote:
I encountered a runtime error in my code and all I can get 
(even in debug mode) is the following stacktrace:


object.Error@(0): Access Violation

0x0051C308 in const(nothrow @trusted uint 
function(const(void*))) object.TypeInfo_Interface.getHash

0x0058D2C0 in D6engine5world5world5World6__vtblZ
Error executing command run: Program exited with code 1

No other information is provided.
Anyone ever experienced anything similar? That __vtblZ part of 
the symbol name scares me a bit, TBH.
The codebase is big, so will take me some time to reduce it to 
a simple example, even if I were to use dustmite, but I was 
hoping that someone faced this error message before and could 
give me a pointer on what to look for.


__vtbl indicates an entry in a virtual function table
object.Error@(0): the '0' the is the address that failed.

you attempted to get the hash of a null object ( of type 
engine.world.world.World )


It does seem a bit odd that no other info is provided  stack 
traces are usually quite a bit longer than that  ...


Re: What are (dis)advantages of using pure and immutable by default?

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

On Monday, 7 September 2015 at 10:55:13 UTC, anonymous wrote:

On Monday 07 September 2015 12:40, Bahman Movaqar wrote:
I can see some serious advantages of this, most notable of 
which is minimum side-effect and predictability of the code.  
However I suppose it's going to impact the performance and 
memory footprint as well, though I have no idea how deep the 
impact will be.


I don't see how merely marking things immutable/pure would 
affect performance negatively. They're just marks on the type. 
If anything, you could get a performance boost from the 
stricter guarantees. But realistically, there won't be a 
difference.


Just "marks", eh?
I was under the impression that when a variable, that is declared 
as `immutable`, is passed to a function, a copy of the value is 
passed.
However based on "marks" I can imagine that since the data is 
marked as `immutable` only a reference is passed; and the 
compiler guarantees that what is referenced to never changes.  Am 
I right?


If you change your algorithms to avoid mutable/impure, then you 
may see worse performance than if you made use of them. But I 
suppose that would be "a reason not to" mark everything 
immutable/pure.


True.
Nowadays that more algorithms are designed with parallelism and 
distribution in mind, though, I believe mutating values and 
impure functions, at least in certain domains, will cease to 
exist.




Re: Better unittest failure output

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

On Monday, 7 September 2015 at 12:06:09 UTC, anonymous wrote:

On Monday 07 September 2015 13:57, Bahman Movaqar wrote:

 $ dub test

[...]

 core.exception.AssertError@source/e002.d(111): unittest
failure

[...]
From that one line I left intact above, you should also be able 
to figure out that it's the test in source/e002.d, line 111 
that failed.


True.  That I had already figured out.  I was actually hoping for 
something like Groovy's assert messages[1], if possible.


Is there any compiler switch, argument to `assert` or trick to 
make `unittest` output more helpful messages when failing?


You can pass a custom message as a second argument to assert:
assert(condition, "message goes here");


Thanks.  This is indeed helpful.  OT but where can I view the 
documentation for `unittest` and `assert`?


[1] 
http://docs.groovy-lang.org/next/html/documentation/core-testing-guide.html#_power_assertions






Re: AST like coding syntax. Easy upgrade!

2015-09-07 Thread Sergei Nosov via Digitalmars-d

On Monday, 7 September 2015 at 02:50:06 UTC, Adam D. Ruppe wrote:
On Sunday, 6 September 2015 at 23:33:17 UTC, Walter Bright 
wrote:
I'd always thought Javascript was an ideal extension language 
for a text editor.


Well, I don't think *ideal*, but indeed, it wouldn't be bad.


C'mon, kind sirs! Haven't you heard anything about Emacs Lisp? =)



Re: Better unittest failure output

2015-09-07 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 7 September 2015 at 12:58:58 UTC, Gary Willoughby 
wrote:
On Monday, 7 September 2015 at 11:57:25 UTC, Bahman Movaqar 
wrote:

I am working on a simple project created with DUB[1].
When unit tests the output reads really cryptic to me; for 
example:


Try using DUnit, it gives you much more readable fail messages:

https://github.com/nomad-software/dunit


It's in the dub repository too:

http://code.dlang.org/packages/dunit


Re: A collection of DIPs

2015-09-07 Thread rsw0x via Digitalmars-d
On Monday, 7 September 2015 at 14:52:21 UTC, Ola Fosheim Grøstad 
wrote:

On Monday, 7 September 2015 at 14:44:05 UTC, nx wrote:

https://github.com/NightmareX1337/DX

Don't kill me, I'm just trying to help...


Thanks for taking the time to write up your ideas. There has 
been much discussion on the GC in the past and I agree that a 
GC-tracking mechanism that can enable precise scanning is 
needed, but to get that level of speed you need some of the 
mechanisms in Rust.


precise GC scanning could be enabled easily if the allocation 
calls were templates instead of raw C function. RTInfo is just a 
hack(IMO,) and pretty much ignoring one of the areas D excels in.


Re: A collection of DIPs

2015-09-07 Thread via Digitalmars-d
On Monday, 7 September 2015 at 14:52:21 UTC, Ola Fosheim Grøstad 
wrote:
1. You need to make sure that pointers to the interior of a GC 
object are not live when the last pointer to the start of the 
GC objects disappears.


2. You need to annotate C functions that take pointers with a 
guarantee that they don't hold on to references through that 
pointer. Or simply ban C functions from taking GC memory.


3. You need give up on destructors for GC objects too, and not 
allow them to own heap allocated objects. A reasonable 
restriction IMHO.


[Issue 14996] only(EnumMembers!T) eats all my memory when T : string

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14996

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/2070e8e1386ad03d1d77d7beff910bfca31a8aad
fix Issue 14996 - only(EnumMembers!T) eats all my memory when T : string

https://github.com/D-Programming-Language/dmd/commit/21e644ee74d83c64869c60830b96547736765c73
Merge pull request #5046 from 9rnsr/fix14996

Issue 14996 - only(EnumMembers!T) eats all my memory when T : string

--


[Issue 14996] only(EnumMembers!T) eats all my memory when T : string

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14996

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 6744] Missing AA symbol with enum

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6744

Kenji Hara  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #10 from Kenji Hara  ---
(In reply to Kenji Hara from comment #2)
> This is not only the problem of AA, it is where template instantiation is
> belongs to.
> 
>  test.d
> import traits;
> void func()(){ X!() x; auto n = x.length; }
> void main(){ func(); assert(0); }
> 
>  traits.d
> struct X(){ int length(){ return 0; } }
> enum x = X!()();
> 
>  command line
> dmd test.d
> 
>  output
> OPTLINK (R) for Win32  Release 8.00.7
> Copyright (C) Digital Mars 1989-2010  All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> test2.obj(test2)
>  Error 42: Symbol Undefined _D6traits6__T1XZ1X6lengthMFZi
> 
> semantic() runs against the type of X!() at both line 2 in test and line 2
> of traits, but its instantiation belongs to only traits, because the
> semantic runs  first in traits.
> But the module traits never generate .obj, then the symbol ob X!().length
> will be lost.


Now, the question has been resolved.

Since 2.064, new template instantiation strategy has been introduced:

https://github.com/D-Programming-Language/dmd/pull/2550

By that, when a template X!() is instantiated in both root module (test.d) and
non-root module (traits.d), it's assumed that the instantiated code would exist
in the linked object file of the non-root module.
But the command line `dmd test.d` does not correctly compile & link the
traits.d module.
Then test.obj fail to link the instantiated X!().length() funciton.
In short, the link-failure is intentional behavior.

Close this issue as "resolved".

--


Re: A collection of DIPs

2015-09-07 Thread BBasile via Digitalmars-d

On Monday, 7 September 2015 at 14:44:05 UTC, nx wrote:

https://github.com/NightmareX1337/DX

Don't kill me, I'm just trying to help...

You can report issues and create pull requests :)


Destroy!


OK, here are a few comments on what i agree with or not. The 
other point simply don't interest me.



## Managed, unmanaged, something between? - pointers

You can already create, allocate new class, struct and union 
instances that are not known by the GC.
This is not well known because I've explained this several time 
on several boards to several people. So this proposal is simply 
consequence of a lack of knowledge.


But, even if... using the '^' symbol, would be bad since it's 
already used to xor.



## Why need alias this while we have opCast?

an "alias this" expression doesn't require to cast.
Maybe you don't really see "alias this" as it is widely used:
- custom type.
- composition.

So your proposal to use cast is pointless.


## InExpression is meaningless

No it doesn't. :)


## ?? operator

Yes, the 'Null coalescing operator' would be great.


## Templates should use exclamation!

No, you can clearly differentiate declaration from instantiation 
thanks to the current syntax.



## friend classes

You can put the classes in different modules and then 'private' 
and 'protected' are sufficient to get something like friend 
classes.


[Issue 14472] add separate ptr data section

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14472

--- Comment #2 from Martin Nowak  ---
Something along this line from Rainer.
https://github.com/D-Programming-Language/dmd/pull/5047#issuecomment-138125410
https://github.com/rainers/dmd/commit/e6a3d1778ad2969fc7bcb378a084b8d865b015c7

--


function argument restrictions for templated struct

2015-09-07 Thread Laeeth Isharc via Digitalmars-d-learn

Hi.

Is there a more elegant way to write the template arg 
restrictions for display?


Thanks.


Laeeth

import std.stdio;
import std.traits;

struct Bar(bool test)
{
double a;
static if(test)
double b;
}

void display(T)(T a)
if (__traits(isSame, TemplateOf!(T), Bar))
{
writefln("%s",a);
}

void main(string[] args)
{
auto a=Bar!false(1.0);
auto b=Bar!true(1.0,2.0);
a.display;
b.display;
}


Re: D-Day for DMD is today!

2015-09-07 Thread via Digitalmars-d-announce

On Friday, 4 September 2015 at 12:38:41 UTC, Daniel Murphy wrote:
It's not that phobos is bad, it's that we're following the same 
development pattern we had with C++.  We're using a 
conservative subset of D features and libraries, and slowly 
expanding what's acceptable. For example, DMD now uses foreach 
and delegates in a few places, and I expect we'll see a lot of 
use of D strings in the near future.


Is there any place where this is documented? For instance, what D 
constructs are currently allowed, whether/which phobos imports 
have started to be accepted, and so on?


Re: A collection of DIPs

2015-09-07 Thread Israel via Digitalmars-d

On Monday, 7 September 2015 at 14:44:05 UTC, nx wrote:

https://github.com/NightmareX1337/DX


Destroy!


Yea ill admit, i came from C# and i hate underscores. I prefer 
PascalCase above anything.


Re: Are there any Phobos functions to check file permissions on Windows and Posix?

2015-09-07 Thread BBasile via Digitalmars-d-learn
On Sunday, 6 September 2015 at 23:05:29 UTC, Jonathan M Davis 
wrote:
[...] which makes treating some of this stuff in a 
cross-platform fashion quite difficult.


And even more with ACLs that it could be:

On windows, to know properly if something is readable or writable 
the attributes are not enough. One should also check the ACL:


https://msdn.microsoft.com/en-us/library/windows/desktop/aa446659(v=vs.85).aspx

For example you can retieve the flags: 
archive/readonly/hidden/system/indexable(?) and even if it looks 
writable or readable, the file won't be open at all because the 
ACL for the file don't include the current user account.





Re: A collection of DIPs

2015-09-07 Thread via Digitalmars-d

On Monday, 7 September 2015 at 15:34:21 UTC, BBasile wrote:
You can already create, allocate new class, struct and union 
instances that are not known by the GC.
This is not well known because I've explained this several time 
on several boards to several people. So this proposal is simply 
consequence of a lack of knowledge.


You have to scan all memory that MAY contain a pointer to a 
reference chain that contains a pointer to GC heap. That's a lot 
of cache lines to scan over on today's computers that soon have 
terrabytes of memory.




Re: function argument restrictions for templated struct

2015-09-07 Thread anonymous via Digitalmars-d-learn
On Monday 07 September 2015 17:51, Laeeth Isharc wrote:

> Is there a more elegant way to write the template arg 
> restrictions for display?
[...]
> void display(T)(T a)
> if (__traits(isSame, TemplateOf!(T), Bar))
> {
>   writefln("%s",a);
> }

if (isInstanceOf!(Bar, T))


Re: Are there any Phobos functions to check file permissions on Windows and Posix?

2015-09-07 Thread FreeSlave via Digitalmars-d-learn
On Sunday, 6 September 2015 at 23:05:29 UTC, Jonathan M Davis 
wrote:


http://dlang.org/phobos/std_file.html#.getAttributes will get 
you all of the file attributes for a file, though you'll have 
to look at the Windows and POSIX documentation to know how to 
interpret that.


- Jonathan M Davis


It will give you attributes from owner's point of view (i.e. what 
owner can, what users in the same group can, and what all other 
users can)


Not sure if phobos has functions to check if file is readable or 
writable by current user. You can use access on Posix: 
http://linux.die.net/man/2/access


Re: Are there any Phobos functions to check file permissions on Windows and Posix?

2015-09-07 Thread Kagamin via Digitalmars-d-learn
On Sunday, 6 September 2015 at 20:40:04 UTC, Gary Willoughby 
wrote:
Are there any Phobos functions to check file permissions on 
Windows and Posix? For example, I want to check if a file is 
readable and/or writable in a cross-platform fashion. Does 
anyone have an example?


Call fopen and check errno?


[Issue 15002] [REG2.064] ICE with invalid static variable initializer while CTFE

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15002

--- Comment #7 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b5b8d55d74cef95b2e5a6cf24a93438c2ae20141
fix Issue 15002 - ICE with invalid static variable initializer while CTFE

https://github.com/D-Programming-Language/dmd/commit/a94bcb5ab7e714bd9673a4367d1bff01f4338fce
Merge pull request #5026 from 9rnsr/fix15002

--


[Issue 14696] destructor for temporary called before statement is complete with conditional operator

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14696

--- Comment #11 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/3bbe72b5fdc278fe1293c20b39af4f94b10070bb
fix Issue 14696 - destructor for temporary called before statement is complete
with conditional operator

https://github.com/D-Programming-Language/dmd/commit/38d31b0364e555ce42a8f47ca656e59b1cf90aad
Merge pull request #5003 from 9rnsr/fix14696_cdmd

--


Chaining struct method invocations

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn
I need some help understand the behaviour of my code[1].  
Specifically I have trouble with `add` method on line 79.


My impression is that since it returns `this`, multiple 
invocations can be chained like `obj.add(X).add(Y).add(Z)`.  
However the test on line 92 fails and if I do a `writeln`, only 
"p1" and "p2" records show up.


What am I missing here?  Thanks in advance.

[1] 
https://github.com/bahmanm/d-etudes/blob/master/source/e002/models.d




[Issue 3248] lossless floating point formatting

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3248

hst...@quickfur.ath.cx changed:

   What|Removed |Added

 CC|hst...@quickfur.ath.cx  |

--


Re: A collection of DIPs

2015-09-07 Thread via Digitalmars-d

On Monday, 7 September 2015 at 14:44:05 UTC, nx wrote:

https://github.com/NightmareX1337/DX

Don't kill me, I'm just trying to help...


Thanks for taking the time to write up your ideas. There has been 
much discussion on the GC in the past and I agree that a 
GC-tracking mechanism that can enable precise scanning is needed, 
but to get that level of speed you need some of the mechanisms in 
Rust.


1. You need to make sure that pointers to the interior of a GC 
object are not live when the last pointer to the start of the GC 
objects disappears.


2. You need to annotate C functions that take pointers with a 
guarantee that they don't hold on to references through that 
pointer. Or simply ban C functions from taking GC memory.


What do you think?


Re: Chaining struct method invocations

2015-09-07 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-09-07 16:44, Bahman Movaqar wrote:


Does this mean that in the following piece of code, what is passed to
`add` is actually a copy of `rec1`?

auto rec1 = SalesRecord("p10", 1.0, 10);
coll.add(rec1);


Yes. structs have value semantics. If you want reference semantics you 
might want to use a class instead.


--
/Jacob Carlborg


Re: Chaining struct method invocations

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

On Monday, 7 September 2015 at 14:54:04 UTC, Jacob Carlborg wrote:

On 2015-09-07 16:44, Bahman Movaqar wrote:

Does this mean that in the following piece of code, what is 
passed to

`add` is actually a copy of `rec1`?

auto rec1 = SalesRecord("p10", 1.0, 10);
coll.add(rec1);


Yes. structs have value semantics. If you want reference 
semantics you might want to use a class instead.


Actually I like the value semantics very much.  I think I'm going 
to stick to `structs` for as much as possible :-)


Re: dmd codegen improvements

2015-09-07 Thread Jacob Carlborg via Digitalmars-d
On 2015-09-06 15:24, Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= 
 wrote:



Oh, actually it appears to run on both OS-X and Linux. I didn't know
that. Looks very promising, thanks!


Yeah, it's built on the same framework as Atom. Or were you hoping for 
Visual Studio, sans Code, on OS X and Linux?


--
/Jacob Carlborg


Re: AST like coding syntax. Easy upgrade!

2015-09-07 Thread Jacob Carlborg via Digitalmars-d

On 2015-09-06 21:32, Prudence wrote:

template X(Y)
{
 string X = Y.stringof;
}

auto s = X({int 3;})

Of course, doesn't work!!


You might be interested in this [1].

[1] http://wiki.dlang.org/DIP50

--
/Jacob Carlborg


A collection of DIPs

2015-09-07 Thread nx via Digitalmars-d

https://github.com/NightmareX1337/DX

Don't kill me, I'm just trying to help...

You can report issues and create pull requests :)


Destroy!


[Issue 14708] destructor for temporary not called during stack unwinding

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14708

--- Comment #3 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/e20c63cb28decb66c792b1dfc10d79aa0aebd7cf
fix Issue 14708 - destructor for temporary not called during stack unwinding

https://github.com/D-Programming-Language/dmd/commit/38d31b0364e555ce42a8f47ca656e59b1cf90aad
Merge pull request #5003 from 9rnsr/fix14696_cdmd

--


[Issue 14948] [Reg 2.068.0] AA key requirement was broken w/o notice and w/ horrible error message

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14948

--- Comment #8 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/5c1d3c5b63394b7d3758f86a53eace6ffb3d3165
fix Issue 14948 - AA key requirement was broken w/o notice and w/ horrible
error message

https://github.com/D-Programming-Language/dmd/commit/880f45dafe5b45951f5b30d188130b32250d6e31
Merge pull request #5001 from 9rnsr/fix14948

--


[Issue 15017] [REG2.068.1-b2] assigning a Variant to be value in a hashmap

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15017

--- Comment #5 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/4a87ff64dfdc67419a69136ce542e88c67726701
fix Issue 15017 - assigning a Variant to be value in a hashmap

https://github.com/D-Programming-Language/dmd/commit/c9c12bf14b054a589841a2a62f083106c8647fb5
Merge pull request #5042 from 9rnsr/fix15017

--


Re: Chaining struct method invocations

2015-09-07 Thread Namespace via Digitalmars-d-learn

On Monday, 7 September 2015 at 14:12:25 UTC, Bahman Movaqar wrote:
I need some help understand the behaviour of my code[1].  
Specifically I have trouble with `add` method on line 79.


My impression is that since it returns `this`, multiple 
invocations can be chained like `obj.add(X).add(Y).add(Z)`.  
However the test on line 92 fails and if I do a `writeln`, only 
"p1" and "p2" records show up.


What am I missing here?  Thanks in advance.

[1] 
https://github.com/bahmanm/d-etudes/blob/master/source/e002/models.d


You should mark your return type with ref. Structs are value 
types and therefore you return only a copy currently.


Re: Chaining struct method invocations

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

On Monday, 7 September 2015 at 14:26:57 UTC, mzf wrote:
On Monday, 7 September 2015 at 14:12:25 UTC, Bahman Movaqar 
wrote:

struct is a value type,you can convert to ref type by "ref":

struct Test
{
int a;

Test add1()
{
a++;
return this;
}
ref Test add2()
{
a++;
return this;
}
}

Test t1;
t1.add1.add1;
writeln(t1.a);//1

Test t2;
t2.add2.add2;
writeln(t2.a);//2


Thanks.  I was afraid I had to resort to using pointers to 
achieve this!


Re: Chaining struct method invocations

2015-09-07 Thread mzfhhhh via Digitalmars-d-learn

On Monday, 7 September 2015 at 14:12:25 UTC, Bahman Movaqar wrote:
I need some help understand the behaviour of my code[1].  
Specifically I have trouble with `add` method on line 79.


My impression is that since it returns `this`, multiple 
invocations can be chained like `obj.add(X).add(Y).add(Z)`.  
However the test on line 92 fails and if I do a `writeln`, only 
"p1" and "p2" records show up.


What am I missing here?  Thanks in advance.

[1] 
https://github.com/bahmanm/d-etudes/blob/master/source/e002/models.d


struct is a value type,you can convert to ref type by "ref":

struct Test
{
int a;

Test add1()
{
a++;
return this;
}
ref Test add2()
{
a++;
return this;
}
}

Test t1;
t1.add1.add1;
writeln(t1.a);//1

Test t2;
t2.add2.add2;
writeln(t2.a);//2


Re: dmd codegen improvements

2015-09-07 Thread via Digitalmars-d

On Monday, 7 September 2015 at 13:41:31 UTC, Jacob Carlborg wrote:
On 2015-09-06 15:24, Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= 
 wrote:


Oh, actually it appears to run on both OS-X and Linux. I 
didn't know

that. Looks very promising, thanks!


Yeah, it's built on the same framework as Atom. Or were you 
hoping for Visual Studio, sans Code, on OS X and Linux?


I knew there was an Atom based type script editor (or several?), 
but didn't know that Microsoft was behind it and that "VS Code" 
was different from "VS"/"VS Express" ;).


Typescript seems to have a lot of momentum. I'm thinking about 
the possibility of a transpiler TypeScript->D (and other 
languages).


Re: Chaining struct method invocations

2015-09-07 Thread Bahman Movaqar via Digitalmars-d-learn

On Monday, 7 September 2015 at 14:28:06 UTC, Namespace wrote:
On Monday, 7 September 2015 at 14:12:25 UTC, Bahman Movaqar 
wrote:
Structs are value types and therefore you return only a copy 
currently.


Does this mean that in the following piece of code, what is 
passed to `add` is actually a copy of `rec1`?


   auto rec1 = SalesRecord("p10", 1.0, 10);
   coll.add(rec1);




Re: Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn
On that note, is there also any generic translation software for 
code that you can program a set of simple "rules"(matching and 
arranging) to translate source code?


e.g., match("const WM_", ";")->WM.add(%1 + ",")).

The above should be obvious but essentially it matches the first 
string until the second is found, adds it to the WM 
container(which, we can specify it it's type). %1 is just what 
was found inbetween the two bookends in the match. We add a comma 
for the next enum.


(such a line would put all the const WM's into the enum, it 
doesn't handle the outer static versioning, so would break 
headers... hence a more robust solution is needed)





Re: Windows Header consts

2015-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn

On Monday, 7 September 2015 at 17:44:54 UTC, Prudence wrote:

const WM_* -> add to enum WM;
else WM_* -> WM.*


I'm against that. The documentation all says WM_* and we 
shouldn't muck with it.


const -> enum is a good idea though. These headers were all 
written way back when when const and enum had different 
meanings.



I guessing one would need a D or C parser to deal with all this?


hackerpilot's dfix would be the starting point.



[Issue 15021] New: [Reg 2.068.1] linker error with speculative instantiation and -inline

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15021

  Issue ID: 15021
   Summary: [Reg 2.068.1] linker error with speculative
instantiation and -inline
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: regression
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: c...@dawg.eu

cat > bug.d << CODE
import std.conv;

class AliasDeclaration
{
}

void aliasDeclaration(AliasDeclaration ad)
{
// This is extracted from VariantN
AliasDeclaration* zis;
static if (is(typeof(to!string(*zis
to!string(*zis);
}

void main()
{
}
CODE

dmd -inline bug

bug.o:bug.d:function _D3bug16aliasDeclarationFC3bug16AliasDeclarationZv: error:
undefined reference to
'_D3std6format54__T22enforceValidFormatSpecTC3bug16AliasDeclarationTaZ22enforceValidFormatSpecFNaNfKS3std6format18__T10FormatSpecTaZ10FormatSpecZv'
bug.o:bug.d:function
_D3std4conv11__T2toTAyaZ31__T2toTC3bug16AliasDeclarationZ2toFC3bug16AliasDeclarationZAya:
error: undefined reference to
'_D3std6format54__T22enforceValidFormatSpecTC3bug16AliasDeclarationTaZ22enforceValidFormatSpecFNaNfKS3std6format18__T10FormatSpecTaZ10FormatSpecZv


This is most likely caused by
https://github.com/D-Programming-Language/dmd/pull/4944 and broke any code
using classes in Variant and specifically dfmt.

--


[Issue 12090] Make std.concurrency compatible with fibers as threads

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12090

Mathias LANG  changed:

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 CC||pro.mathias.l...@gmail.com
 Resolution|--- |FIXED

--- Comment #10 from Mathias LANG  ---
This was fixed in 2.067 but since the title of the P.R. didn't include "Fix",
bugzilla didn't pick it up.
Note: It's not showing up in the changelog as a result.

--


Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn
Windows headers contain a ton of global const's for the various 
messages. Seems like a very bad way to go about this.


Could one not simply put all these in an enum? e.g., enum WM { 
WM_CREATE = 1, etc... }?


If so, because there are so many and so many references to them, 
this can't be done easily by hand. Surely there is a way to 
automate this? But because the headers are not consistently 
written, a simple search and replace won't work well?


e.g.,

const WM_* -> add to enum WM;
else WM_* -> WM.*

because there is code like

static if (_WIN32_WINNT >= 0x500) {

enum {
WM_CHANGEUISTATE=   0x0127,
WM_UPDATEUISTATE=   0x0128,
WM_QUERYUISTATE =   0x0129
}

// LOWORD(wParam) values in WM_*UISTATE*
enum {
UIS_SET =   1,
UIS_CLEAR   =   2,
UIS_INITIALIZE  =   3
}

// HIWORD(wParam) values in WM_*UISTATE*
enum {
UISF_HIDEFOCUS  =   0x1,
UISF_HIDEACCEL  =   0x2
}

}

static if (_WIN32_WINNT >= 0x501) {

// HIWORD(wParam) values in WM_*UISTATE*
enum {
UISF_ACTIVE =   0x4
}

}

(unless one can define partial enums or use static if in the 
enums directly(probably the case but parsing is more difficult))



I guessing one would need a D or C parser to deal with all this?



[Issue 15023] New: debug info for extern(C++) classes don't work when debugging C++ code

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15023

  Issue ID: 15023
   Summary: debug info for extern(C++) classes don't work when
debugging C++ code
   Product: D
   Version: D2
  Hardware: All
OS: Linux
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: c...@dawg.eu

Haven't investigated this further but when debugging C++ code in ddmd, the
debugger doesn't know anything about extern(C++) classes.
Not to mention that the debug info for classes has lots of other issues (e.g.
no baseclass fields).

--


[Issue 14980] [REG2.068] getAddressInfo(null) broken

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14980

--- Comment #6 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/156bf68ef7008343755ab450facdd0e5604f6fac
fix Issue 14980 - getAddressInfo(null) broken

https://github.com/D-Programming-Language/phobos/commit/e885e163f0acc034f98f53ca59a809a82ade064f
std.socket: Add test for issue 14980

https://github.com/D-Programming-Language/phobos/commit/e06c7a9e607bc7ca37958459c079e81c35893250
Merge pull request #3612 from 9rnsr/fix14980

https://github.com/D-Programming-Language/phobos/commit/564389e89b6398c99c206381cdfc8599e08c63cf
Merge pull request #3613 from CyberShadow/pull-20150830-042721

--


[Issue 14904] [REG2.067.0] bad error message in reduce: 'Incompatible function/seed/element'

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14904

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/6579c574bbcc53944a2060f3d1eadc1fa5516f51
fix Issue 14904 - bad error message in reduce: 'Incompatible
function/seed/element'

https://github.com/D-Programming-Language/phobos/commit/76a5087312382ff0b16840d4c2501dc8ba6abda0
Merge pull request #3580 from 9rnsr/fix14904

--


[Issue 14920] [REG2.067.0] SList.insertAfter on uninitialized list triggers assertion in _first

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14920

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/0c28c7717437b10570677994112fc874e196d26a
fix issue 14920

https://github.com/D-Programming-Language/phobos/commit/aac09abf0a8f8624e81bbac4ded38b941cc768d9
Merge pull request #3557 from tosttost/issue_14920

--


Re: function argument restrictions for templated struct

2015-09-07 Thread Laeeth Isharc via Digitalmars-d-learn

On Monday, 7 September 2015 at 16:27:21 UTC, anonymous wrote:

On Monday 07 September 2015 17:51, Laeeth Isharc wrote:

Is there a more elegant way to write the template arg 
restrictions for display?

[...]

void display(T)(T a)
if (__traits(isSame, TemplateOf!(T), Bar))
{
writefln("%s",a);
}


if (isInstanceOf!(Bar, T))


Thanks !


Re: A collection of DIPs

2015-09-07 Thread Shammah Chancellor via Digitalmars-d

On Monday, 7 September 2015 at 14:44:05 UTC, nx wrote:

https://github.com/NightmareX1337/DX

Don't kill me, I'm just trying to help...

You can report issues and create pull requests :)


Destroy!


Hi NX,

Thanks for the document.  A lot of what you say about UDA and 
compile time reflection is absolutely true.  We should fix it so 
it isn't so darn convoluted.


w/ regards to __traits() those are call outs to the compiler and 
generally should not be used directly.  Thus std.traits, and why 
they're prefixed with __.  Unfortunately, the current state of 
compile time reflection requires that you must use __traits 
directly (at least, I've had to)


However, I can't agree with you about alias this, UFCS, or global 
functions in phobos.  The "idiomatic" way to code in D is use 
local named imports.  e.g.:


void main() {
   import std.stdio : writeln;
   writeln("Hello world!");
}

-Shammah


[Issue 15021] [Reg 2.068.1] linker error with speculative instantiation and -inline

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15021

--- Comment #1 from Martin Nowak  ---
Maybe we should do a 2.068.2 hotfix release for this?

--


[Issue 15022] New: use __TEXT,__cstring to deduplicate strings during linking

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15022

  Issue ID: 15022
   Summary: use __TEXT,__cstring to deduplicate strings during
linking
   Product: D
   Version: D2
  Hardware: All
OS: Mac OS X
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: c...@dawg.eu

The linker will deduplicate all strings in the __TEXT,__cstring section.
https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/MachORuntime/#//apple_ref/doc/uid/TP4895-CH248-CJBIIIJH

--


[Issue 15024] New: Wrong keyword color for Visual Studio Dark theme

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15024

  Issue ID: 15024
   Summary: Wrong keyword color for Visual Studio Dark theme
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: regression
  Priority: P1
 Component: visuald
  Assignee: nob...@puremagic.com
  Reporter: den...@gmail.com

Created attachment 1548
  --> https://issues.dlang.org/attachment.cgi?id=1548=edit
screenshot

Some types are too dark (VS2015, Visual D 0.3.42)
regression after https://issues.dlang.org/show_bug.cgi?id=11786 perhaps?

--


Re: template UDA

2015-09-07 Thread Adam D. Ruppe via Digitalmars-d

On Monday, 7 September 2015 at 22:00:07 UTC, bitwise wrote:
Is there any real(and plausible) use case where providing a 
template with no argument as a UDA would be useful?


Yes, you actually wrote it yourself!


@MyAttribute!SomeClass class SomeClass { }


That right there is a reason. When you are looking for UDAs, you 
look for declarations. The usage code looks like:


foreach(member; getMembers!module)
  if(member.hasUDA!(MyAttribute)) {
  // do something
  }


The beauty of it is that member is right there! So your 
reflection code could instantiate it right there:


  // do something becomes...
  MyAttribute!(member);

so it instantiates the template with the given member in the 
reflection code itself.




Re: Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn

On Monday, 7 September 2015 at 20:55:25 UTC, Adam D. Ruppe wrote:

On Monday, 7 September 2015 at 19:06:48 UTC, Prudence wrote:
It's called encapsulation. It prevents namespace pollution and 
identifier collision.


This is already provided by the D module system. Even if you 
were to define a WM_CREATE in your code, it would not cause a 
major problem with the Win32 name because you can disambiguate 
via the imports. (That's also a minor hassle, but it is more 
rare for these long names than a short name like WM anyway!)


My editor already autocompletes WM_* names anyway, but again, 
the D module system can help with that too if you didn't want 
the keyword based completion I use for that.


I just don't see any advantage here to counterbalance the pain 
of changing it.


Again, it's called progress. Why keep using the same defunct 
system for endless years simply because that's the way it was 
done?


It's like saying we should never upgrade the space shuttle(not 
that it matters any more) simply because the previous one was 
working?


Do you seriously think that your logic is the best? If you could 
prove that Bill Gates designed the best OS ever possible, that is 
one thing... But changes are they shit all over themselves while 
doing it because they didn't learn from there mistakes(how could 
they, they go in to the future to see what kinda crap came out).


Do you think computers in 100 years are still going to be using 
windows? Do you think the designers will still use the same 
programming techniques? Do you think they will worship Bill Gates 
because think they the messaging model of Windows was the 
ultimate gift to humanity?


It's one thing to say: "I'm just too lazy to want to waste all 
that time changing stuff to make it work". That's a valid 
argument! But it's quite different to say "We don't need to 
change because this model works best and any modification of it 
will only produce a poorer result". If you are going to use the 
second argument, you need to prove it. If you are going to use 
the first, don't expect to get anywhere.


I just wish when people say stuff like you have done, you would 
be honest and say what you really mean so we don't have to waste 
time beating around the bush. A simple "I'm don't care what 
others want, I think we should keep it the same because I'm happy 
with it". I'm OK with such a statement. At least it's honest and 
direct. I might not like the selfishness that it implies, but to 
each his own, I suppose.


Oh, and who says you couldn't keep both systems? But I'll never 
understand why people think keeping a junker around and NOT allow 
something better is a good idea. You can keep your rusted ol' 
ElCamino that's missing a tire and has no hood if you want. But 
why stop me from having a Ferrari? Is it jealousy? Selfishness? 
There's enough gas to go around you know? And if we both arrive 
at the gas station we can take turns, if your willing?








Re: Windows Header consts

2015-09-07 Thread Prudence via Digitalmars-d-learn

On Monday, 7 September 2015 at 22:21:28 UTC, Adam D. Ruppe wrote:

On Monday, 7 September 2015 at 22:02:47 UTC, Prudence wrote:

Oh, and who says you couldn't keep both systems?


Nobody. There's absolutely nothing stopping you from defining 
your one constants and bindings. I think you should actually do 
it and see for yourself the pros and cons in practice.


Which is why I asked is there is an easy way to do it, and you 
replied that essentially that it shouldn't be changed because it 
would change things.


[Issue 15026] New: cannot array assign to a slice return value

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15026

  Issue ID: 15026
   Summary: cannot array assign to a slice return value
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: c...@dawg.eu

cat > bug.d << CODE
int[] bar()
{
return null;
}

void test()
{
bar() = 2;
}
CODE

Error: bar() is not an lvalue


Even more annoying with opSlice.

cat > bug.d << CODE
struct Foo
{
int[] opSlice()
{
return null;
}
}

void test()
{
Foo foo;
foo[] = 2;
}
CODE

Error: foo[] is not an lvalue


Seems like the lvalue check should be done after array assignments are lowered.

--


[Issue 15026] cannot array assign to a slice return value

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15026

--- Comment #1 from Martin Nowak  ---
Workaround is to slice the return value, i.e. `bar()[]` and `foo[][]`.

--


Re: Windows Header consts

2015-09-07 Thread Adam D. Ruppe via Digitalmars-d-learn

On Monday, 7 September 2015 at 23:11:36 UTC, Prudence wrote:
I asked is there is an easy way to do it, and you replied that 
essentially that it shouldn't be changed because it would 
change things.


I also said:

I guessing one would need a D or C parser to deal with all 
this?

hackerpilot's dfix would be the starting point.


https://github.com/Hackerpilot/dfix


Re: D-Day for DMD is today!

2015-09-07 Thread Daniel Murphy via Digitalmars-d-announce

On 8/09/2015 1:54 AM, "Luís Marques   wrote:

On Friday, 4 September 2015 at 12:38:41 UTC, Daniel Murphy wrote:

It's not that phobos is bad, it's that we're following the same
development pattern we had with C++.  We're using a conservative
subset of D features and libraries, and slowly expanding what's
acceptable. For example, DMD now uses foreach and delegates in a few
places, and I expect we'll see a lot of use of D strings in the near
future.


Is there any place where this is documented? For instance, what D
constructs are currently allowed, whether/which phobos imports have
started to be accepted, and so on?


No.


[Issue 15021] [REG2.068.1] linker error with speculative instantiation and -inline

2015-09-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15021

Kenji Hara  changed:

   What|Removed |Added

   Keywords||link-failure, pull
Summary|[Reg 2.068.1] linker error  |[REG2.068.1] linker error
   |with speculative|with speculative
   |instantiation and -inline   |instantiation and -inline

--- Comment #2 from Kenji Hara  ---
https://github.com/D-Programming-Language/dmd/pull/5055

--


How To Compile D2SQLite3 on OSX?

2015-09-07 Thread Mike McKee via Digitalmars-d
LOL, I feel like I need to do one of these "Explain like I'm 5" 
kind of posts you see on Reddit. I'm stuck. I'm on OSX 
(Yosemite). I seem to have properly installed homebrew, and then 
dub, and then sqlite3, and I have the dmd D compiler installed 
and working. Now I'm trying to get D2SQLite3 installed on OSX so 
that I can interact with a SQLite database. I downloaded and 
expanded the zip from Github:


https://github.com/biozic/d2sqlite3

...and then cd'd to this directory. I then edited the dub.json 
file like so:


{
"name": "d2sqlite3",
"description": "A thin wrapper around SQLite3",
"homepage": "https://github.com/biozic/d2sqlite3;,
"authors": ["Nicolas Sicard", "Other contributors: see Github 
repo"],

"copyright": "Copyright 2011-15 Nicolas Sicard",
"license": "BSL-1.0",
"targetType": "library",
"libs": ["sqlite3"],
"systemDependencies": "SQLite version >= 3.8.7",
"lflags": 
["-L/usr/local/Cellar/sqlite/3.8.11.1/lib/libsqlite3.dylib"]

}


...although I'm not quite clear if I did the lflags line 
properly. I then ran "dub build" and it seems to have created the 
file: libd2sqlite3.a


Now I don't know what to do with that file. I also created a 
test.d script to test the SQLite out, but it's complaining of 
missing symbols, even though I'm importing the right .d files:


import d2sqlite3;
import std.array;
import std.conv;
import std.exception;
import std.file;
import std.path;
import std.stdio;
import std.string;
import std.c.stdlib : exit;
import core.stdc.time : time_t;
import etc.c.zlib;

void main(){

auto db = Database("test.sqlite");
auto results = db.execute("SELECT * FROM test");
while (!results.empty) {
auto row = results.front;
writeln(row.peek!string(0));
results.popFront();
}

}

When I compile this, it complains of missing the d2SQLite symbols:

$ dmd test.d
Undefined symbols for architecture x86_64:
  "_D9d2sqlite311ResultRange11__fieldDtorMFZv", referenced from:
  __Dmain in test.o
  "_D9d2sqlite311ResultRange5emptyMFNdZb", referenced from:
  __Dmain in test.o
  "_D9d2sqlite311ResultRange5frontMFNdZS9d2sqlite33Row", 
referenced from:

  __Dmain in test.o
  "_D9d2sqlite311ResultRange8_Payload11__fieldDtorMFZv", 
referenced from:
  _D42TypeInfo_S9d2sqlite311ResultRange8_Payload6__initZ in 
test.o
  
"_D9d2sqlite311ResultRange8_Payload11__xopEqualsFKxS9d2sqlite311ResultRange8_PayloadKxS9d2sqlite311ResultRange8_PayloadZb", referenced from:
  _D42TypeInfo_S9d2sqlite311ResultRange8_Payload6__initZ in 
test.o

  "_D9d2sqlite311ResultRange8popFrontMFZv", referenced from:
  __Dmain in test.o
  "_D9d2sqlite312__ModuleInfoZ", referenced from:
  _D4test12__ModuleInfoZ in test.o
  "_D9d2sqlite33Row13internalIndexMFiZi", referenced from:
  _D9d2sqlite33Row13__T4peekTAyaZ4peekMFiZAya in test.o
  "_D9d2sqlite38Database11__fieldDtorMFZv", referenced from:
  __Dmain in test.o
  "_D9d2sqlite38Database6__ctorMFNcAyaiZS9d2sqlite38Database", 
referenced from:

  __Dmain in test.o
  "_D9d2sqlite38Database7executeMFAyaZS9d2sqlite311ResultRange", 
referenced from:

  __Dmain in test.o
  "_D9d2sqlite38Database8_Payload6__dtorMFZv", referenced from:
  _D38TypeInfo_S9d2sqlite38Database8_Payload6__initZ in test.o
  "_D9d2sqlite39Statement8_Payload10__aggrDtorMFZv", referenced 
from:
  _D39TypeInfo_S9d2sqlite39Statement8_Payload6__initZ in 
test.o
  
"_D9d2sqlite39Statement8_Payload11__xopEqualsFKxS9d2sqlite39Statement8_PayloadKxS9d2sqlite39Statement8_PayloadZb", referenced from:
  _D39TypeInfo_S9d2sqlite39Statement8_Payload6__initZ in 
test.o

  "_sqlite3_column_text", referenced from:
  _D9d2sqlite33Row13__T4peekTAyaZ4peekMFiZAya in test.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to 
see invocation)

--- errorlevel 1

How do I get this going?



template UDA

2015-09-07 Thread bitwise via Digitalmars-d

Currently this will compile
Note:
-no type is supplied to @MyAttribute
-"instantiated" will not be printed

struct MyAttribute(T) {
pragma(msg, "instantiated");
}

@MyAttribute class SomeClass { }

void main(string[] args) {
A a = new A();
}

Is there any real(and plausible) use case where providing a 
template with no argument as a UDA would be useful?


If not, could the above usage be made to instantiate MyAttribute 
using the type of whatever it's applied to?


So in the above example, MyAttribute would be(or attempted to be) 
instantiated with type 'SomeClass'.


Currently, you can achieve this(annoyingly and redundantly) like 
this:


@MyAttribute!SomeClass class SomeClass { }

So if there is no valid usage for untyped template UDA's, can D 
be made to act as I am proposing?






Re: Windows Header consts

2015-09-07 Thread Mike Parker via Digitalmars-d-learn

On Monday, 7 September 2015 at 22:02:47 UTC, Prudence wrote:


Again, it's called progress. Why keep using the same defunct 
system for endless years simply because that's the way it was 
done?


Any C library binding should maintain the same interface as the C 
library as much as possible. That way any existing C code can be 
directly ported to D with minimal modification. If you then want 
to build a wrapper on top of that to make it more D-like, that's 
perfectly fine, but the binding itself shouldn't be D-ified.


Re: Regression?

2015-09-07 Thread Sebastiaan Koppe via Digitalmars-d-learn

Fixed it by changing into:

```
import std.conv : text;
	string json = 
File("../languages.json","r").byLineCopy().joiner.text;

auto ls = json.parseJSON();
```


Re: template UDA

2015-09-07 Thread bitwise via Digitalmars-d

On Monday, 7 September 2015 at 22:03:13 UTC, Adam D. Ruppe wrote:

On Monday, 7 September 2015 at 22:00:07 UTC, bitwise wrote:
Is there any real(and plausible) use case where providing a 
template with no argument as a UDA would be useful?


Yes, you actually wrote it yourself!


@MyAttribute!SomeClass class SomeClass { }


That right there is a reason. When you are looking for UDAs, 
you look for declarations. The usage code looks like:





I kinda understand what you're saying, but I still don't think 
there is any benefit to tagging something with a template which 
has no type. The attribute in the above example doesn't need to 
be a template.


I imagine that if I were to search for a template UDA, the next 
step would probably be to enumerate the template parameters and 
take special action. Otherwise, the type is not needed. I suppose 
a template UDA could either have some args, or no args, but I 
can't imaging a use case where this would actually happen.



foreach(member; getMembers!module)
  if(member.hasUDA!(MyAttribute)) {
  // do something
  }

The beauty of it is that member is right there! So your 
reflection code could instantiate it right there:


  // do something becomes...
  MyAttribute!(member);

so it instantiates the template with the given member in the 
reflection code itself.


My goal is not to have this reflection code at all(the loop which 
looks through the module instantiating things). I want the 
attribute itself to do that.


Example:

struct Reflection {
string typeName;
string[] members;

static Reflection[string] reflections;
}

struct Reflected(T)
{
static this() {
string[] members;

foreach(memberName; __traits(allMembers, T))
{
members ~= memberName;
}

enum typeName = fullyQualifiedName!T.stringof[1..$-1];

writeln("registering type: " ~ typeName);
Reflection.reflections[typeName] = Reflection(typeName, 
members);

}
}

Reflection* reflect(Object obj) {
writeln("retrieving type for: " ~ typeid(obj).toString);
return typeid(obj).toString in Reflection.reflections;
}

@Reflected!A class A {
int x;
float y;
string z;
}

void main(string[] args)
{
A a = new A();

foreach(n; a.reflect.members)
writeln(n);
}



But I would like to have the attribute pick up the type that's 
attached.


I saw an example, in another post that went something like this:

struct MyAttribute(T = _UDA_OBJECT_) { }

This would be acceptable too, but for some reason, the response 
received almost no attention.


   Bit



Re: template UDA

2015-09-07 Thread bitwise via Digitalmars-d

On Monday, 7 September 2015 at 22:03:13 UTC, Adam D. Ruppe wrote:

[...]


A more useful example:

http://dpaste.dzfl.pl/82a3d65be4be



Re: template UDA

2015-09-07 Thread bitwise via Digitalmars-d

On Monday, 7 September 2015 at 22:03:13 UTC, Adam D. Ruppe wrote:

[...]


digging deeper, this very contrived example compiles:

struct S(T) { int x; }

auto fun(alias T, S)(S x) {
return T!S(x);
}

void main(string[] args) {
auto s = fun!S(123);
writeln(s.x);
}

So I suppose the existing behaviour shouldn't really be 
considered a bug.


This syntax would sure be nice though:

struct MyAttribute(T = _UDA_TARGET_) { }


Re: "Programming in D" paper book is available for purchase

2015-09-07 Thread Paolo Invernizzi via Digitalmars-d-announce

On Wednesday, 19 August 2015 at 00:57:32 UTC, Ali Çehreli wrote:



Enjoy, and go buy some books! ;)



My printed copy is just arrived... very good job Ali!

Paolo


  1   2   >