Re: DIP56 - inlining

2015-02-04 Thread zeljkog via Digitalmars-d
On 04.02.15 07:46, Zach the Mystic wrote: It's a bikeshed argument, but why not: pragma(inline, always); // warn if unable to inline pragma(inline, never); pragma(inline);// revert to default behavior ...? I know `true` and `false` are keywords, but why confuse people? What is a

Re: H1 2015 Priorities and Bare-Metal Programming

2015-02-03 Thread zeljkog via Digitalmars-d
On 03.02.15 10:35, Walter Bright wrote: On 2/3/2015 1:11 AM, Mike wrote: Another way of putting it: Does pragma(inline, true) simply allow the user to compiler parts of their source file with -inline? Yes. Eh, yes :) I see now, errors/warnings are invasive compared to this simple,

Re: H1 2015 Priorities and Bare-Metal Programming

2015-02-02 Thread zeljkog via Digitalmars-d
On 03.02.15 00:29, Walter Bright wrote: Now, when it can't inline, do you expect the compiler to produce an error message? Or warning? Microcontroller programmers like to look at produced code, no need to force them :)

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread zeljkog via Digitalmars-d-learn
On 31.01.15 15:45, RuZzz wrote: Maybe I need good examples on C++, for this class, because a lot of examples on C++. Maybe this can help you: https://github.com/andersonpd/decimal

Re: How to make a Currency class from std.BigInt?

2015-01-31 Thread zeljkog via Digitalmars-d-learn
On 31.01.15 15:56, zeljkog wrote: On 31.01.15 15:45, RuZzz wrote: Maybe I need good examples on C++, for this class, because a lot of examples on C++. Maybe this can help you: https://github.com/andersonpd/decimal Also http://code.dlang.org/packages/eris

Re: Labels in struct

2015-01-31 Thread zeljkog via Digitalmars-d-learn
On 31.01.15 17:04, tcak wrote: I do not have a big example in the end to show, but is there any way to put labels into struct definitions? struct CommunicationMessage{ char[2] signature; mainData: int info1; int info2; extraData: ushort checksum; content: } Members of

Re: Time for 2.067

2015-01-31 Thread zeljkog via Digitalmars-d
On 30.01.15 23:24, AndyC wrote: On Friday, 30 January 2015 at 22:06:34 UTC, Walter Bright wrote: Time to button this up and release it. Remaining regressions:

Re: accept @pure @nothrow @return attributes

2015-01-28 Thread zeljkog via Digitalmars-d
On 28.01.15 14:14, bearophile wrote: Dicebot: Yes, but it didn't also fix anything, only introduced more ways to do the same thing - without any plans for some consistent model. One of the rules of the Python Zen: There should be one-- and preferably only one --obvious way to do it. Yes

Re: This Week in D, Issue 3

2015-01-26 Thread zeljkog via Digitalmars-d-announce
On 26.01.15 14:37, Nick Treleaven wrote: On 26/01/2015 05:15, Adam D. Ruppe wrote: Also available via RSS: http://arsdnet.net/this-week-in-d/twid.rss Much appreciated - now works with my Thunderbird, thanks :) Double :)

Re: [WORK] groupBy is in! Next: aggregate

2015-01-26 Thread zeljkog via Digitalmars-d
On 26.01.15 19:05, Andrei Alexandrescu wrote: On 1/26/15 9:50 AM, Ary Borenszweig wrote: On 1/26/15 2:34 PM, Andrei Alexandrescu wrote: On 1/26/15 8:11 AM, H. S. Teoh via Digitalmars-d wrote: On Mon, Jan 26, 2015 at 11:26:04AM +, bearophile via Digitalmars-d wrote: Russel Winder: but

Re: accept @pure @nothrow @return attributes

2015-01-26 Thread zeljkog via Digitalmars-d
On 26.01.15 23:08, Walter Bright wrote: I strongly dislike context sensitive tokens, whether or not they are done by the lexer or the parser or the semantic analysis. It's like using a nail for a cotter pin. I remember the first time I read about D was something like make language easier

Re: std.experimental.logger formal review round 3

2015-01-25 Thread zeljkog via Digitalmars-d
On 25.01.15 15:06, Robert burner Schadek wrote: On Sunday, 25 January 2015 at 09:43:36 UTC, Jacob Carlborg wrote: Is the generated documentation for package module available somewhere? This [1] is empty. [1]

Re: sortUniq

2015-01-24 Thread zeljkog via Digitalmars-d
On 24.01.15 19:47, Andrei Alexandrescu wrote: But here there is potential problem with shared state after save? It's not a problem - save saves the state of the iteration, not the data being iterated. -- Andrei If you pass stateful object with opCall or closure it becomes part of state

Re: sortUniq

2015-01-24 Thread zeljkog via Digitalmars-d
On 24.01.15 18:26, zeljkog wrote: Until now I concluded: 1. Resulting range must be output range. Right? Should be input range.

Re: sortUniq

2015-01-24 Thread zeljkog via Digitalmars-d
On 24.01.15 18:02, Andrei Alexandrescu wrote: On 1/24/15 7:17 AM, zeljkog wrote: private struct FilterResult(alias predicate, Range) { static if (is(predicate == struct)) predicate pred; else alias pred = predicate; ... The problem is here - the creation of

Re: sortUniq

2015-01-24 Thread zeljkog via Digitalmars-d
On 24.01.15 19:35, Andrei Alexandrescu wrote: On 1/24/15 9:34 AM, zeljkog wrote: On 24.01.15 18:26, zeljkog wrote: Until now I concluded: 1. Resulting range must be output range. Right? Should be input range. For filter it's a forward range if input is forward or better. -- Andrei But

Re: sortUniq

2015-01-24 Thread zeljkog via Digitalmars-d
On 24.01.15 15:53, Andrei Alexandrescu wrote: On 1/24/15 4:13 AM, zeljkog wrote: On 24.01.15 12:50, Peter Alexander wrote: auto f = unique(); [1, 5, 5, 2, 1, 5, 6, 6].filter!(f).writeln; // [1, 5, 2, 6] Filter needs an alias, and you cannot alias an R-value (it has no symbol). Yes, I see

Re: sortUniq

2015-01-24 Thread zeljkog via Digitalmars-d
On 24.01.15 16:17, zeljkog wrote: template filter(alias predicate) if (is(typeof(unaryFun!predicate))) Should be: template filter(alias predicate) if (is(typeof(unaryFun!predicate)) || is(predicate == struct))

Re: sortUniq

2015-01-24 Thread zeljkog via Digitalmars-d
On 23.01.15 19:05, zeljkog wrote: On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote: I think what he's trying to do is to call a function that returns a delegate, and use that delegate to instantiate the filter template. AFAIK I've never seen code like this before, and it looks like the

Re: sortUniq

2015-01-24 Thread zeljkog via Digitalmars-d
On 24.01.15 12:50, Peter Alexander wrote: auto f = unique(); [1, 5, 5, 2, 1, 5, 6, 6].filter!(f).writeln; // [1, 5, 2, 6] Filter needs an alias, and you cannot alias an R-value (it has no symbol). Yes, I see :) But I think this should be supported by std.algorithm: import std.stdio,

Re: sortUniq

2015-01-23 Thread zeljkog via Digitalmars-d
On 23.01.15 19:13, Andrei Alexandrescu wrote: On 1/23/15 10:05 AM, zeljkog wrote: On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote: I think what he's trying to do is to call a function that returns a delegate, and use that delegate to instantiate the filter template. AFAIK I've never

Re: sortUniq

2015-01-23 Thread zeljkog via Digitalmars-d
On 23.01.15 18:48, H. S. Teoh via Digitalmars-d wrote: I think what he's trying to do is to call a function that returns a delegate, and use that delegate to instantiate the filter template. AFAIK I've never seen code like this before, and it looks like the compiler isn't prepared to handle

Re: sortUniq

2015-01-23 Thread zeljkog via Digitalmars-d
On 22.01.15 22:40, Andrei Alexandrescu wrote: There's this classic patter on Unix: |sort|uniq, i.e. sort some data and only display the unique elements. Loosely-related, compiling ... auto ret = arr.filter!(myFilter()); ... I got: Error: closures are not yet supported in CTFE Using struct

Error: closures are not yet supported in CTFE

2015-01-23 Thread zeljkog via Digitalmars-d-learn
I tried: -- import std.stdio, std.algorithm; auto unique(){ bool[int] c; return (int a){ if (a in c) return false; else{ c[a] = true; return true; } }; } void main() { [1, 5, 5, 2, 1, 5, 6,

Re: Compile time iota

2015-01-22 Thread zeljkog via Digitalmars-d
On 22.01.15 14:06, Nick Treleaven wrote: On 21/01/2015 19:15, zeljkog wrote: And good name staticIota, unlike TypeTuple. I always wonder what is raw tuple, TypeTuple or Tuple :) Yes, there's a DIP to rename std.typetuple to std.meta.list. I made a pull to do that (which goes further than the

Re: Defining a static array with values in a range

2015-01-22 Thread zeljkog via Digitalmars-d-learn
On 22.01.15 20:05, Meta wrote: On Thursday, 22 January 2015 at 19:00:47 UTC, zeljkog wrote: On 22.01.15 19:26, Meta wrote: On Thursday, 22 January 2015 at 18:23:00 UTC, Meta wrote: Whoops, I forgot to make it a template to force CTFE. You can force CTFE assigning to manifest constant. enum

Re: Defining a static array with values in a range

2015-01-22 Thread zeljkog via Digitalmars-d-learn
On 22.01.15 19:26, Meta wrote: On Thursday, 22 January 2015 at 18:23:00 UTC, Meta wrote: Whoops, I forgot to make it a template to force CTFE. You can force CTFE assigning to manifest constant. enum t = charRange!...

Re: D on Slashdot

2015-01-22 Thread zeljkog via Digitalmars-d
On 22.01.15 17:27, Adam D. Ruppe wrote: Of course, eventually I'll write my own shell with my own completion function! terminal.d is slowly getting there. I'm used to editor. Execute current line - skip comment tags (keyboard shortcut) is all I need.

Compile time iota

2015-01-21 Thread zeljkog via Digitalmars-d
Maybe something like this can be added to Fobos: template Iota(int start, int stop, int step = 1){ template tuple(T...){ alias tuple = T; } static if(start stop) alias Iota = tuple!(start, Iota!(start + step, stop, step)); else alias Iota = tuple!(); }

Re: Compile time iota

2015-01-21 Thread zeljkog via Digitalmars-d
On 21.01.15 19:23, H. S. Teoh via Digitalmars-d wrote: This is actually already implemented as std.typecons.staticIota, but it's currently undocumented and restricted to only Phobos code. I'm not sure why it was decided not to make it public, but if you file an enhancement request, the devs can

Re: post qualifier and template constraint limitation, is there a reason ?

2015-01-17 Thread zeljkog via Digitalmars-d
On 17.01.15 09:33, deadalnix wrote: This is accepted : auto fun(T)(T T) inout if(...) { ... } This is not : auto fun(T)(T T) if(...) inout { ... } Is there a reason ? I think it improves readability. A little :) Often user don't care to read if-part.

Re: http://wiki.dlang.org/DIP25 has been preliminarily approved for 2.067

2015-01-16 Thread zeljkog via Digitalmars-d
On 16.01.15 22:41, Andrei Alexandrescu wrote: Please help us work the kinks out! Walter will be proceeding with the opt-in implementation for quicker pipelining. http://wiki.dlang.org/DIP25 Andrei Why is it restricted to @safe?

Re: no size yet for forward reference for nested structures

2015-01-15 Thread zeljkog via Digitalmars-d
This compiles: import std.container; class Node { DList!Node children; }

Re: no size yet for forward reference for nested structures

2015-01-15 Thread zeljkog via Digitalmars-d
On 15.01.15 23:30, Steven Schveighoffer wrote: On 1/15/15 9:56 AM, zeljkog wrote: This compiles: import std.container; class Node { DList!Node children; } Then use DList? DList is not SList, they were written by different people. -Steve SList.Range has moveFront, DList.Range does

Re: no size yet for forward reference for nested structures

2015-01-15 Thread zeljkog via Digitalmars-d
On 16.01.15 08:04, zeljkog wrote: On 15.01.15 23:30, Steven Schveighoffer wrote: On 1/15/15 9:56 AM, zeljkog wrote: This compiles: import std.container; class Node { DList!Node children; } Then use DList? DList is not SList, they were written by different people. -Steve

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-19 Thread zeljkog via Digitalmars-d-learn
On 19.12.14 16:25, Steven Schveighoffer wrote: This is surprising to me. I would expect especially ints to be faster. In reality, there is no difference between arr ~= args and arr.length += args.length, and then copying, it's just how you do the copying. Perhaps it's the call to memcpy in the

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-19 Thread zeljkog via Digitalmars-d-learn
On 19.12.14 23:56, Ali Çehreli wrote: Can we see the test code please. Ali import std.stdio, std.datetime, std.random; int N = 10_000; int len = 1000; int k = 4; struct S{ int n1, n2; //~ this(this){ //~ writeln(this(this)); //~ } } ref T[] append(T, Args...)(ref T[]

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-19 Thread zeljkog via Digitalmars-d-learn
If you wish run this just add: struct S{ int n1, n2, n3, n4, n5 ...; }

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-18 Thread zeljkog via Digitalmars-d-learn
On 18.12.14 14:50, Steven Schveighoffer wrote: I wonder how your code compares to this: void append(T)(ref T[] arr, T[] args...) { arr ~= args; } This is ~20% slower for ints, but it difference increases for bigger structs.

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-17 Thread zeljkog via Digitalmars-d-learn
On 15.12.14 01:00, Nordlöw wrote: Isn't this algorithm already encoded somewhere in Phobos? void append(T, Args...)(ref T[] arr, auto ref Args args){ { static if (args.length == 1) arr ~= args[0]; // inlined else{ arr.length += args.length; foreach(i, e; args)

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-17 Thread zeljkog via Digitalmars-d-learn
On 17.12.14 13:30, Tobias Pankrath wrote: void append(T, Args...)(ref T[] data, Args args) { static size_t estimateLength(Args args) { size_t result; foreach(e; args) static if(hasLength!(typeof(e))) result += e.length; else

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-14 Thread zeljkog via Digitalmars-d-learn
On 15.12.14 00:16, Nordlöw wrote: or some other trick? void append(T, Args...)(ref T[] arr, Args args){ arr.length += args.length; foreach(i, e; args) arr[$ - args.length + i] = args[i]; } void main() { int[] arr = [1, 2, 3, 4, 5]; arr.append(3, 10, 14); writeln(arr); } output:

Re: Fastest Way to Append Multiple Elements to an Array

2014-12-14 Thread zeljkog via Digitalmars-d-learn
On 15.12.14 01:00, Nordlöw wrote: Isn't this algorithm already encoded somewhere in Phobos? I don't know.

fibers and ranges: what's wrong here?

2014-12-13 Thread zeljkog via Digitalmars-d-learn
import std.stdio, core.thread; struct Tree{ int val; Tree[] tree; } struct TreeRange{ Tree curtree; bool empty; Fiber worker; this(Tree t){ worker = new Fiber(fiberFunc); curtree = t; popFront(); } void fiberFunc(){ Tree t = curtree; Fiber.yield();

Re: fibers and ranges: what's wrong here?

2014-12-13 Thread zeljkog via Digitalmars-d-learn
On 13.12.14 13:01, zeljkog wrote: void main() { auto tt = Tree(5, [Tree(7,[Tree(11), Tree(4)]), Tree(10)]); auto tr1 = TreeRange(tt); foreach(v; tr1){ writef(%2d, , v); } writeln(); for(auto r = TreeRange(tt); !r.empty; r.popFront()) writef(%2d, , r.front);

Re: DIP69 - Implement scope for escape proof references

2014-12-11 Thread zeljkog via Digitalmars-d
On 11.12.14 08:25, Shammah Chancellor wrote: This is exactly why this feature should be default behavior with compiler warnings generated when things escape scope. It can be compiler switch escape=I(gnore)|W(arning)|E(rror).

Re: DIP69 - Implement scope for escape proof references

2014-12-11 Thread zeljkog via Digitalmars-d
On Thursday, 4 December 2014 at 10:00:37 UTC, Walter Bright wrote: On 12/4/2014 1:51 AM, eles wrote: Making it implicit and requiring an explicit escape for un-scoped variables? Was afraid that would break too much code. Compiler switch: escape=I(gnore)|W(arning)|E(rror). For transition

Re: DIP69 - Implement scope for escape proof references

2014-12-08 Thread zeljkog via Digitalmars-d
On 05.12.14 21:55, Walter Bright wrote: It means that this code will be safe: void foo(scope int* p); p = malloc(n); foo(p); free(p); The rest is all the nuts and bolts of making that work. If it is main goal, opposite looks more natural. void foo(int* p); void