Re: the best language I have ever met(?)

2016-11-25 Thread Artur Skawina via Digitalmars-d-learn
On 11/25/16 18:33, Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, November 25, 2016 18:20:11 Artur Skawina via Digitalmars-d-learn > wrote: >> On 11/25/16 17:30, Jonathan M Davis via Digitalmars-d-learn wrote: >>> On Friday, November 25, 2016 17:03:32 Artur Ska

Re: the best language I have ever met(?)

2016-11-25 Thread Artur Skawina via Digitalmars-d-learn
On 11/25/16 17:30, Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, November 25, 2016 17:03:32 Artur Skawina via Digitalmars-d-learn > wrote: >> On 11/25/16 15:51, Jonathan M Davis via Digitalmars-d-learn wrote: >>> On Friday, November 25, 2016 14:27:

Re: the best language I have ever met(?)

2016-11-25 Thread Artur Skawina via Digitalmars-d-learn
On 11/25/16 15:51, Jonathan M Davis via Digitalmars-d-learn wrote: > On Friday, November 25, 2016 14:27:39 Igor Shirkalin via Digitalmars-d-learn > wrote: >> I think you may write it (I mean actual D) with using some >> template like this: >> >> auto array = static_array!uint(1, 2, 3, 4) >> >>

Re: Passing private functions to template algorithms

2016-06-12 Thread Artur Skawina via Digitalmars-d
The language does not prevent taking the address of a private symbol and escaping it. The alias case isn't (ie shouldn't be) different. artur

Re: a lambda with arguments has type void?

2016-06-09 Thread Artur Skawina via Digitalmars-d-learn
On 06/09/16 07:20, cy via Digitalmars-d-learn wrote: > Like this is why it doesn't really make sense: > > import std.stdio; > > auto foo(Callable)(Callable c) { > return c(42); > } > > auto foo2(alias c)() { > return c(42); > } > > void main() { > // this works, when you know it's an int

Re: Version block "conditions" with logical operators

2016-05-11 Thread Artur Skawina via Digitalmars-d
On 05/10/16 13:48, Tomer Filiba via Digitalmars-d wrote: > On Tuesday, 10 May 2016 at 11:12:58 UTC, Tomer Filiba wrote: >> Alternatively, an isVersion(x) predicate that I could use in a static if >> could do the trick > > Well, I've come up with > > template isVersion(string ver) { >

Re: With statement extension

2016-04-28 Thread Artur Skawina via Digitalmars-d
On 04/28/16 10:28, Adrian Matoga via Digitalmars-d wrote: > On Wednesday, 27 April 2016 at 18:34:18 UTC, Artur Skawina wrote: >> [...] >> >>ref Ex1() { return e1.someProperties.someModulusX; } > > Unless any of the properties is an enum or, well, a @prope

Re: With statement extension

2016-04-27 Thread Artur Skawina via Digitalmars-d
On 04/27/16 15:55, deed via Digitalmars-d wrote: > > A stronger example would be a scope with two similar types, i.e.: > > void foo (Matrix matrix, SameType e1, SameType e2) > { > with ( > M: matrix.rawArr; > Ex1 : e1.someProperties.someModulusX, > Ey1 :

Re: Issue Turning Template into Variadic Template

2016-03-31 Thread Artur Skawina via Digitalmars-d-learn
On 03/30/16 20:12, jmh530 via Digitalmars-d-learn wrote: > I wrote a version of cartesianProduct that will return the cartesian product > when the some of the types are not ranges. The original code is below. > > My issue is that I can't figure out how to turn it into a variadic template. >

Re: Attribute inference for non-templated functions

2016-03-30 Thread Artur Skawina via Digitalmars-d
On 03/30/16 16:20, Meta via Digitalmars-d wrote: > On Wednesday, 30 March 2016 at 12:57:56 UTC, Mathias Lang wrote: >> It's a design decision. You want to be able to fix the exact type of your >> function, in order to provide headers for them for example (so you can work >> with libraries for

Re: static if else behavior and is type comparison

2016-03-11 Thread Artur Skawina via Digitalmars-d-learn
On 03/11/16 09:21, Ali Çehreli via Digitalmars-d-learn wrote: > You've been bitten by a common usability issue. :) > > On 03/11/2016 12:02 AM, Fynn Schröder wrote: >> static if (is(U == ubyte)) { >> } else if (is(U == ushort)) { > > You mean 'else static if'. (Not your fault: I (and

Re: Decoding Pattern to a Tuple

2016-02-22 Thread Artur Skawina via Digitalmars-d-learn
On 02/19/16 19:10, Nordlöw via Digitalmars-d-learn wrote: > Have anybody put together a generalised form of findSplit that can split and > decode using a compile time parameters somewhat like > > "(1)-(2.0)".decode!("(", int, ")", char, "(", double, ")") > > evaluates to > > to a > >

Re: print function

2016-02-05 Thread Artur Skawina via Digitalmars-d-learn
On 02/05/16 08:04, cy via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 15:32:48 UTC, Artur Skawina wrote: >>void print(A...)(A a) { >> foreach (N, ref e; a) >> write(e, N==A.length-1?"\n":" "); >>} > &

Re: print function

2016-02-05 Thread Artur Skawina via Digitalmars-d-learn
On 02/05/16 14:38, Ola Fosheim Grøstad via Digitalmars-d-learn wrote: > On Friday, 5 February 2016 at 12:35:14 UTC, Artur Skawina wrote: >> call used to print diagnostics. What I saw made me never use or look at D's >> std lib again. Except for meta programing and toy/example

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 15:02, ixid via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 13:46:46 UTC, Dejan Lekic wrote: >> On Thursday, 4 February 2016 at 00:23:07 UTC, ixid wrote: >>> It would be nice to have a simple writeln that adds spaces automatically >>> like Python's 'print' in

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 16:32, Artur Skawina wrote: > >void print(A...)(A a) { > foreach (N, ref e; a) > write(e, N==A.length-1?"\n":" "); >} BTW, that was *deliberately* written that way as a compromise between efficiency and template bloat. It

Re: print function

2016-02-04 Thread Artur Skawina via Digitalmars-d-learn
On 02/04/16 18:53, ixid via Digitalmars-d-learn wrote: > On Thursday, 4 February 2016 at 17:34:33 UTC, Artur Skawina wrote: >> On 02/04/16 16:32, Artur Skawina wrote: >> but that seems too expensive, when the use is just in toy programs and >> debugging. > >

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote: > On Monday, 1 February 2016 at 18:28:05 UTC, Artur Skawina wrote: >> On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote: >>> Thanks! I was surprised this is not straightforward. >> >>enum

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 02/01/16 21:42, Artur Skawina wrote: > On 02/01/16 20:47, Meta via Digitalmars-d-learn wrote: >> That looks much nicer. It still needs work to properly handle functions with >> non-empty argument lists. > > Then it gets a bit long for a one-liner ;) > >enum

Re: how do I tell if something is lvalue?

2016-02-01 Thread Artur Skawina via Digitalmars-d-learn
On 01/31/16 23:11, Steven Schveighoffer via Digitalmars-d-learn wrote: > Thanks! I was surprised this is not straightforward. enum isLvalue(alias A) = is(typeof((ref _){}(A))); artur

Re: [dlang.org] Let's talk about the logo

2016-01-23 Thread Artur Skawina via Digitalmars-d
On 01/23/16 02:11, ronaldmc via Digitalmars-d wrote: > > What happens if a technical feature is vetoed by someone is charge even if it > has merit? Every wrong decision affects the project negatively. > Linux Foundation has a board members to approve or not new features or > changes, and

Re: improving scope(finally/success)

2015-12-04 Thread Artur Skawina via Digitalmars-d
On 12/03/15 16:33, Steven Schveighoffer via Digitalmars-d wrote: > auto ref logCall(alias f, Args...)(auto ref Args args) { >auto ref printResult(T)(auto ref T t) >{ > writeln(t); > return t; >} >return printResult(f(args)) > } > > logCall!foo(true); Which will

Re: Forward declaration issue

2015-12-04 Thread Artur Skawina via Digitalmars-d-learn
On 12/04/15 09:12, Andre via Digitalmars-d-learn wrote: > Hi, > > I have a strange issue with following coding. > > void baz(); // forward declaration > > void foo() > { > void bar() > { > baz(); // (1) without f.d. syntax error > } > > void baz() > { >

Re: Binding to GSL library

2015-11-26 Thread Artur Skawina via Digitalmars-d-learn
On 11/25/15 17:11, Radek via Digitalmars-d-learn wrote: > Hi, I'm making a trying to bind a gsl library > http://www.gnu.org/software/gsl/ so far it was working but when i started > binding complex numbers some functions won't work, like trigonometric > functions - called they return null. > >

Re: DMD is faster than LDC and GDC

2015-11-12 Thread Artur Skawina via Digitalmars-d
On 11/12/15 13:22, Daniel Kozak via Digitalmars-d wrote: >>> timings: >>> > > >>> > > DMD (-O -release -inline -boundscheck=off): >>> > > real0m0.003s >>> > > user0m0.000s >>> > > sys 0m0.000s >>> > > >>> > > LDMD2-ldc2 (-O -release -inline -boundscheck=off): >>> > > real0m1.071s

Re: Help from the compiler when debugging failing template constraints - a pull request

2015-10-14 Thread Artur Skawina via Digitalmars-d
On 10/14/15 15:32, Atila Neves via Digitalmars-d wrote: > On Wednesday, 14 October 2015 at 12:42:23 UTC, Artur Skawina wrote: >> On 10/14/15 10:26, Atila Neves via Digitalmars-d wrote: >>> On Monday, 28 September 2015 at 20:25:21 UTC, Atila Neves wrote: >>>> I've me

Re: Synchronized classes have no public members

2015-10-14 Thread Artur Skawina via Digitalmars-d
On 10/14/15 03:10, Kapps via Digitalmars-d wrote: > On Tuesday, 13 October 2015 at 18:28:23 UTC, Marco Leise wrote: >> >> Guys, sorry to break into your wishful thinking, but >> >>synchronized(mutex) {} >> >> already works as you want it to since as long as I can think. Yes, it takes >> a

Re: Help from the compiler when debugging failing template constraints - a pull request

2015-10-14 Thread Artur Skawina via Digitalmars-d
On 10/14/15 10:26, Atila Neves via Digitalmars-d wrote: > On Monday, 28 September 2015 at 20:25:21 UTC, Atila Neves wrote: >> I've mentioned this many times before: template constraints are like >> unittest blocks with asserts in D: great that they're built-in easy to use. >> But when they fail,

Re: Check template parameter whether it has "length"

2015-10-08 Thread Artur Skawina via Digitalmars-d-learn
On 10/08/15 11:29, tcak via Digitalmars-d-learn wrote: > I am "trying" to write a function that takes an array of items, and returns > the length of longest item. > > [code] > size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, > "length" ) ) > { > return 0; // not

Re: Idioms you use

2015-10-05 Thread Artur Skawina via Digitalmars-d
On 10/05/15 17:53, Marco Leise via Digitalmars-d wrote: > Am Sun, 04 Oct 2015 00:08:39 +0200 > schrieb Artur Skawina via Digitalmars-d > <digitalmars-d@puremagic.com>: > >>static ctfe = ctfeArr!( iota(256).map!isDigit() ); >> >>immutable typeof(R.fron

Re: Idioms you use

2015-10-03 Thread Artur Skawina via Digitalmars-d
On 10/03/15 15:53, Marco Leise via Digitalmars-d wrote: > Am Mon, 28 Sep 2015 21:40:43 + > schrieb Freddy : > >> Are any D idioms you use that you like to share? >> Heres one of mine >> --- >> enum ctfe = >> { >> return 0xdead & 0xbad; >> }(); >> --- > > Yep,

Re: Get template parameter value

2015-09-29 Thread Artur Skawina via Digitalmars-d-learn
On 09/29/15 12:13, rumbu via Digitalmars-d-learn wrote: > On Tuesday, 29 September 2015 at 09:53:39 UTC, Kagamin wrote: >> On Tuesday, 29 September 2015 at 09:11:15 UTC, John Colvin wrote: >>> Welcome to the weird and wonderful work of >>> http://dlang.org/expression.html#IsExpression >> >> No,

Re: pragma(inline, true) not very useful in its current state?

2015-09-27 Thread Artur Skawina via Digitalmars-d
On 09/27/15 13:48, Marco Leise via Digitalmars-d wrote: > Am Sat, 26 Sep 2015 19:58:14 +0200 > schrieb Artur Skawina via Digitalmars-d > <digitalmars-d@puremagic.com>: > >> `allow` is the default state and always safe; for the cases >> where it's /undesirable/, the

Re: Pathing in the D ecosystem is generally broken (at least on windows)

2015-09-26 Thread Artur Skawina via Digitalmars-d
On 09/26/15 13:10, Walter Bright via Digitalmars-d wrote: > On 9/26/2015 1:21 AM, Manu via Digitalmars-d wrote: >>> I'll leave that to the GDC and LDC teams. >> >> And right there is the problem as I see it, summarised in one sentence ;) >> >> If you take the D ecosystem as aggregate, these issues

Re: Pathing in the D ecosystem is generally broken (at least on windows)

2015-09-26 Thread Artur Skawina via Digitalmars-d
On 09/26/15 23:58, Laeeth Isharc via Digitalmars-d wrote: >> Given the DMD licensing situation, __nobody__ will (or should) even look >> inside the DMD repo for info. Especially that Note that the above is not what I actually wrote, but has been altered with no mention of this fact. It's hard

Re: pragma(inline, true) not very useful in its current state?

2015-09-26 Thread Artur Skawina via Digitalmars-d
On 09/26/15 18:42, Marco Leise via Digitalmars-d wrote: > Am Sat, 26 Sep 2015 12:21:15 +0200 > schrieb Jacob Carlborg : > >> On 2015-09-26 06:27, Manu via Digitalmars-d wrote: >> >>> We _really_ need attribute aliasing in >>> some form, especially since LDC/GDC have compiler-specific

Re: What is the corect behavour for lazy in foreach variadic template

2015-09-25 Thread Artur Skawina via Digitalmars-d-learn
On 09/25/15 17:47, Ali Çehreli via Digitalmars-d-learn wrote: > Perhaps we need an enhancement that either works in your original code [...] His original code does work (`foreach` evaluates `args[N]` and assigns the result to `arg`). If he wanted to delay the evaluation, he would have written

Re: Why is the constructor of B called?

2015-09-24 Thread Artur Skawina via Digitalmars-d-learn
On 09/24/15 13:26, Marc Schütz via Digitalmars-d-learn wrote: > On Thursday, 24 September 2015 at 01:01:09 UTC, Nicholas Wilson wrote: >> On Wednesday, 23 September 2015 at 21:25:15 UTC, tcak wrote: >>> On Wednesday, 23 September 2015 at 21:14:17 UTC, Adam D. Ruppe wrote: On Wednesday, 23

Re: A collection of DIPs

2015-09-07 Thread Artur Skawina via Digitalmars-d
> void main() > { > std.stdio.writeln("Hello world!"); // Error: undefined identifier 'std' > } struct Mod(string B="") { template opDispatch(string M) { static if (__traits(compiles, { mixin(`import `~B~"."~M~`;`); })) mixin(`import opDispatch =

Re: __traits(allMembers) and aliases

2015-08-26 Thread Artur Skawina via Digitalmars-d-learn
On 08/26/15 14:42, Mike Parker via Digitalmars-d-learn wrote: This doesn't help me distinguish aliased function names. [...] I don't want to put any restrictions on what the user can have in the module/class/struct that contains the function pointer. It's just that aliased function names

Re: extern opaque struct

2015-08-23 Thread Artur Skawina via Digitalmars-d
On 08/24/15 00:20, John Colvin via Digitalmars-d wrote: Let's say I have some C headers that have code like this in: extern struct UndeclaredStruct blah; Undeclared *p = blah; which would naïvely translate to D as: struct UndeclaredStruct; extern UndeclaredStruct blah; auto p = blah;

Re: Problem with casting instance reference to void* and back.

2015-07-27 Thread Artur Skawina via Digitalmars-d-learn
On 07/27/15 14:03, Vlad Leberstein via Digitalmars-d-learn wrote: Hi! My use case requires interaction with C API which in turn implies storing object instance reference as void *. I'm using gdc 4.9.2 and everything worked fine with object - void * - object conversion, but object - void * -

Re: with(auto x = ...)

2015-07-26 Thread Artur Skawina via Digitalmars-d
On 07/26/15 17:56, Idan Arye via Digitalmars-d wrote: On Sunday, 26 July 2015 at 14:49:40 UTC, Timon Gehr wrote: Well, no. That does not follow. We can have both a with statement and a with expression. Mmm... but how will we differ them? There's no need for that. (hint: mixin). But,

Re: Rant after trying Rust a bit

2015-07-24 Thread Artur Skawina via Digitalmars-d
On 07/24/15 20:29, Walter Bright via Digitalmars-d wrote: On 7/24/2015 4:55 AM, Artur Skawina via Digitalmars-d wrote: Basically, it can work like this: - traits, like your 'hasPrefix', check that 'T' implements an interface (defined in hasPrefix). (this does the job that template

Re: Rant after trying Rust a bit

2015-07-24 Thread Artur Skawina via Digitalmars-d
On 07/24/15 23:32, Jonathan M Davis via Digitalmars-d wrote: On Friday, 24 July 2015 at 20:57:34 UTC, Artur Skawina wrote: The difference is that right now the developer has to write a unit-test per function that uses `hasPrefix`, otherwise the code might not even be verified to compile. 100

Re: Rant after trying Rust a bit

2015-07-24 Thread Artur Skawina via Digitalmars-d
On 07/24/15 06:43, Walter Bright via Digitalmars-d wrote: On 7/23/2015 3:12 PM, Dicebot wrote: On Thursday, 23 July 2015 at 22:10:11 UTC, H. S. Teoh wrote: OK, I jumped into the middle of this discussion so probably I'm speaking totally out of context... This is exactly one major advantage

Re: version: multiple conditions

2015-07-04 Thread Artur Skawina via Digitalmars-d
On 06/28/15 16:21, Joakim via Digitalmars-d wrote: On Sunday, 28 June 2015 at 13:43:39 UTC, Artur Skawina wrote: On 06/28/15 05:06, Joakim via Digitalmars-d wrote: So you're trying to avoid writing this? version(linux) version(D_LP32) version = valistIsCharPointer; else version(Windows

Re: turning an array of structs into a struct of arrays

2015-07-04 Thread Artur Skawina via Digitalmars-d-learn
On 07/03/15 12:52, Laeeth Isharc via Digitalmars-d-learn wrote: I have an array of structs eg struct PriceBar { DateTime date; double open; double high; double low; double close; } (which fields are present in this particular struct will depend on template arguments).

Re: ReturnType and overloaded functions

2015-06-13 Thread Artur Skawina via Digitalmars-d
On 06/13/15 01:25, Yuxuan Shui via Digitalmars-d wrote: When there are multiple overloaded functions, whose return type will I get when I use ReturnType? Is there a way I could choose a specific function by its parameter types? alias ReturnType(alias F, A...) = typeof(F(A.init)); artur

Re: Daily downloads in decline

2015-06-12 Thread Artur Skawina via Digitalmars-d
On 06/11/15 23:44, Walter Bright via Digitalmars-d wrote: On 6/11/2015 1:18 PM, Meta wrote: It's not *quite* the same. I believe Rust traits are closer to C++ concepts. I suspect C++ concepts have the same limitation. It's not a limitation, but a feature. Your example could look more or

Re: Eponymous/anonymous mixin templates

2015-06-09 Thread Artur Skawina via Digitalmars-d
On 06/08/15 22:03, Jeffrey Tsang via Digitalmars-d wrote: Recursive mixin templates, which is mostly the reason I'm using this, won't work: string foo(string x)() { return x; } string foo(string x, T...)() { mixin foo!T _foo; return x ~ y ~ _foo.foo(); } // mixin

Re: static foreach considered

2015-06-08 Thread Artur Skawina via Digitalmars-d
On 06/08/15 22:02, Andrei Alexandrescu via Digitalmars-d wrote: Walter and I are looking at ways to implement it. Here's a baseline without static foreach - a trace function that prints function calls before they are made: http://dpaste.dzfl.pl/762c83c7fe30 If the function is

Re: Eponymous/anonymous mixin templates

2015-06-08 Thread Artur Skawina via Digitalmars-d
On 06/08/15 17:14, Jeffrey Tsang via Digitalmars-d wrote: On Sunday, 7 June 2015 at 14:17:45 UTC, Artur Skawina wrote: On 06/07/15 11:05, Jeffrey Tsang via Digitalmars-d wrote: I use a mixin template to define exactly one symbol, and at instantiation I wish to use that symbol immediately

Re: Code behaves incorrectly if it is compiled in std.functional

2015-06-07 Thread Artur Skawina via Digitalmars-d
On 06/07/15 18:49, Timon Gehr via Digitalmars-d wrote: This is valid C: int main(){ const auto int x=2; return 0; } This is not valid C: int main(){ auto auto int x=2; return 0; } What is the problem? The problem is the apparently common misunderstanding that 'auto'

Re: Eponymous/anonymous mixin templates

2015-06-07 Thread Artur Skawina via Digitalmars-d
On 06/07/15 11:05, Jeffrey Tsang via Digitalmars-d wrote: I use a mixin template to define exactly one symbol, and at instantiation I wish to use that symbol immediately, once. AFAICT you're asking for the commented-out line in auto Tmpl() = l; void main(string[] argv) { auto l =

Re: Call-ie return on behalf of caller?

2015-06-04 Thread Artur Skawina via Digitalmars-d-learn
On 06/04/15 00:37, Tofu Ninja via Digitalmars-d-learn wrote: Is there a way other than exceptions for a called function to force the caller to return? Specifically, I know the return type of the caller(its always bool) and under certain circumstances I would like the caller to just give up

Re: Negation of attributes (DIP 79)

2015-06-02 Thread Artur Skawina via Digitalmars-d
On 06/03/15 01:41, ketmar via Digitalmars-d wrote: On Tue, 02 Jun 2015 18:49:09 +0200, Artur Skawina via Digitalmars-d wrote: On 06/02/15 14:21, ketmar via Digitalmars-d wrote: this opens a can of worms. should this be accepted too: enum doItFinal = false; final(doItFinal) ? or even

Re: Negation of attributes (DIP 79)

2015-06-02 Thread Artur Skawina via Digitalmars-d
On 06/02/15 14:21, ketmar via Digitalmars-d wrote: On Tue, 02 Jun 2015 11:50:15 +, Namespace wrote: For me it looks ugly. But I would prefer final(false) instead of !final. this opens a can of worms. should this be accepted too: enum doItFinal = false; final(doItFinal) ? or

Re: DIP78 - macros without syntax extensions

2015-05-27 Thread Artur Skawina via Digitalmars-d
On 05/27/15 17:47, Idan Arye via Digitalmars-d wrote: On Wednesday, 27 May 2015 at 08:14:36 UTC, Kagamin wrote: On Tuesday, 26 May 2015 at 23:47:41 UTC, Dennis Ritchie wrote: If this proposal is considered, it is required to propose to look at the implementation of macros in Nemerle. Many

Re: smart pointer for interior pointers

2015-05-27 Thread Artur Skawina via Digitalmars-d
On 05/28/15 01:31, Steven Schveighoffer via Digitalmars-d wrote: I just was working on a project, and I had a need for two members of a struct to share state. How could this work? A simple example: struct S { int x; int *y; // should refer to x this(int v) { x = v;

Re: Evaluation order of index expressions

2015-05-26 Thread Artur Skawina via Digitalmars-d
On 05/26/15 14:54, Timon Gehr via Digitalmars-d wrote: On 05/26/2015 06:35 AM, Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= ola.fosheim.grostad+dl...@gmail.com wrote: One of C's design mistakes is to make assignments expressions and not statements. I think it is more about returning void vs.

Re: Evaluation order of index expressions

2015-05-26 Thread Artur Skawina via Digitalmars-d
On 05/26/15 18:16, Timon Gehr via Digitalmars-d wrote: On 05/26/2015 06:13 PM, Artur Skawina via Digitalmars-d wrote: On 05/26/15 14:54, Timon Gehr via Digitalmars-d wrote: On 05/26/2015 06:35 AM, Ola Fosheim =?UTF-8?B?R3LDuHN0YWQi?= ola.fosheim.grostad+dl...@gmail.com wrote: One of C's

Re: Destructured Tuple Assignment

2015-05-15 Thread Artur Skawina via Digitalmars-d-learn
import std.algorithm; template magicassign(A...) { void magicassign(B)(B b) @property { foreach(I, ref a; A) static if (!is(typeof(A[I]):typeof(null))) a = b[I]; } } template let(string D) { mixin({ enum sdsl =

Re: Multiple template alias parameters

2015-05-09 Thread Artur Skawina via Digitalmars-d-learn
On 05/08/15 23:56, Brian Schott via Digitalmars-d-learn wrote: On Friday, 8 May 2015 at 12:44:31 UTC, Artur Skawina wrote: On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote: The problem occurs when I want to register multiple modules to scan for functions. The grammar does

Re: Multiple template alias parameters

2015-05-08 Thread Artur Skawina via Digitalmars-d-learn
On 05/08/15 03:53, Brian Schott via Digitalmars-d-learn wrote: The problem occurs when I want to register multiple modules to scan for functions. The grammar does not allow this syntax: ``` template (alias Modules ...) { ... ``` The grammar allows omitting the 'alias' keyword. artur

Re: Reducing source code: weak+alias values in array

2015-05-02 Thread Artur Skawina via Digitalmars-d-learn
On 05/02/15 05:28, Jens Bauer via Digitalmars-d-learn wrote: On Saturday, 2 May 2015 at 03:21:38 UTC, Jens Bauer wrote: For some reason, my build time has increased dramatically... Building with 1 vector takes 0.6 seconds. Building with 2 vector takes 0.7 seconds. Building with 4 vector

Re: Reducing source code: weak+alias values in array

2015-05-01 Thread Artur Skawina via Digitalmars-d-learn
On 05/01/15 22:29, Jens Bauer via Digitalmars-d-learn wrote: On Wednesday, 29 April 2015 at 13:58:14 UTC, Artur Skawina wrote: On 04/27/15 19:49, Jens Bauer via Digitalmars-d-learn wrote: I was wondering if there's a way to reduce my bulky startup files a bit. {snip} Just create a helper

Re: Reducing source code: weak+alias values in array

2015-04-29 Thread Artur Skawina via Digitalmars-d-learn
On 04/27/15 19:49, Jens Bauer via Digitalmars-d-learn wrote: I was wondering if there's a way to reduce my bulky startup files a bit. If using the GNU Assembler (GAS), then one can reduce the code using a macro like this: /* The EXC macro makes a weak+alias for the * symbol 'value',

Re: Make a type tuple from an array

2015-04-11 Thread Artur Skawina via Digitalmars-d-learn
On 04/10/15 17:36, John Colvin via Digitalmars-d-learn wrote: On Friday, 10 April 2015 at 15:13:54 UTC, Marc Schütz wrote: Is there a way to turn an array (known at compile time) into a TypeTuple? For input ranges in general: import std.range : isInputRange; template TypeTupleOf(TL...)

Re: Creating a microcontroller startup file

2015-04-09 Thread Artur Skawina via Digitalmars-d-learn
On 04/08/15 18:10, Jens Bauer via Digitalmars-d-learn wrote: On Wednesday, 8 April 2015 at 11:17:12 UTC, Mike wrote: On Tuesday, 7 April 2015 at 20:33:26 UTC, Jens Bauer wrote: enum weak = gcc.attribute.attribute(weak); enum isrDefault = gcc.attribute.attribute(alias, defaultHandler);

Re: Replace core language HexStrings with library entity

2015-03-17 Thread Artur Skawina via Digitalmars-d
On 03/17/15 22:18, Baz via Digitalmars-d wrote: On Tuesday, 17 March 2015 at 21:06:04 UTC, Artur Skawina wrote: On 03/17/15 20:47, deadalnix via Digitalmars-d wrote: Not that much. But q{ string are a pain in the ass. Why? I'm not sure if you're referring to using or parsing them. The only

Re: Replace core language HexStrings with library entity

2015-03-17 Thread Artur Skawina via Digitalmars-d
On 03/17/15 20:47, deadalnix via Digitalmars-d wrote: Not that much. But q{ string are a pain in the ass. Why? I'm not sure if you're referring to using or parsing them. The only problem with the former is the lack of a non-brace-nesting variant. Lexing is quite trivial, as long as the lexer

Re: Replace core language HexStrings with library entity

2015-03-17 Thread Artur Skawina via Digitalmars-d
On 03/17/15 15:15, Daniel Murphy via Digitalmars-d wrote: Nick Treleaven wrote in message news:me98hl$2erf$1...@digitalmars.com... They add complexity to tools such as ctags (written in C, the fishman fork supports D but not D-specific strings). Yes, but only a very little bit. How much

Re: enum and static if

2015-03-11 Thread Artur Skawina via Digitalmars-d-learn
On 03/11/15 15:41, ketmar via Digitalmars-d-learn wrote: On Wed, 11 Mar 2015 14:36:07 +, wobbles wrote: On Wednesday, 11 March 2015 at 14:34:32 UTC, ketmar wrote: On Wed, 11 Mar 2015 13:48:45 +, Namespace wrote: This code does not work: enum Test { Foo, static if

Re: Initializing defaults based on type.

2015-03-06 Thread Artur Skawina via Digitalmars-d-learn
On 03/06/15 22:29, Artur Skawina wrote: No, you implement it using CTFE magic, and then that code becomes: #foreach (N; 0..PairInitValues.length/2) { enum PairInitValue(T:PairInitValues[$N*2]) = PairInitValues[$N*2+1]; } Seriously though, avoid using `.stringof` when generating

Re: Initializing defaults based on type.

2015-03-06 Thread Artur Skawina via Digitalmars-d-learn
On 03/06/15 19:27, Kagamin via Digitalmars-d-learn wrote: On Friday, 6 March 2015 at 16:39:56 UTC, Ali Çehreli wrote: mixin (makePairInitValueDefinitions()); Oh, so that's how you do static foreach. No, you implement it using CTFE magic, and then that code becomes: import std.typetuple;

Re: Let's Play Code Golf

2015-02-23 Thread Artur Skawina via Digitalmars-d
On 02/23/15 21:21, Charles via Digitalmars-d wrote: My solution (150 characters, 15 points): void main(){import std.stdio;int t,n;readf( %d,t);while(t--){readf( %d,n);real a=0,i=0;for(;in;i++)a+=(i%2?-1:1)/(i+i+1);writefln(%.15f,a);}} void main(){import std.stdio;int t,n;for(readf(

Re: Labels in struct

2015-01-31 Thread Artur Skawina via Digitalmars-d-learn
On 01/31/15 17:04, tcak via Digitalmars-d-learn wrote: struct CommunicationMessage{ [...] content: } Example I defined something like above. I am using it as a base structure, and don't know how long the content of message will be. But I know that it will be at the end. I could use

Re: extern(C) symbol conflicts

2015-01-29 Thread Artur Skawina via Digitalmars-d
On 01/29/15 14:43, Steven Schveighoffer via Digitalmars-d wrote: I really think D should consider extern(C) functions as not overloadable, All functions are overloadable in D; ie you can mix C and D overloads freely; this is a feature. It allows you to extend the C i/f without adding an extra

Re: How to copy object of class A to another object of class B?

2015-01-28 Thread Artur Skawina via Digitalmars-d-learn
On 01/28/15 10:44, zhmt via Digitalmars-d-learn wrote: I have a struct created by thrift: struct Card { long id; string pwd; long agentId; bool valid; long rmb; long createDate; long soldDate; long chargeDate; mixin TStructHelpers!([ TFieldMeta(`id`, 1,

Re: static class vs. static struct

2015-01-27 Thread Artur Skawina via Digitalmars-d-learn
On 01/27/15 10:40, Daniel Kozak via Digitalmars-d-learn wrote: On Tuesday, 27 January 2015 at 09:36:49 UTC, Daniel Kozak wrote: On Tuesday, 27 January 2015 at 09:01:39 UTC, ref2401 wrote: For several times I've met struct(or static struct) usage in Phobos for singleton pattern implementation.

Re: accept @pure @nothrow @return attributes

2015-01-26 Thread Artur Skawina via Digitalmars-d
On 01/26/15 23:10, Walter Bright via Digitalmars-d wrote: On 1/26/2015 1:45 PM, Artur Skawina via Digitalmars-d wrote: Just 'no' on context-sensitive tokens. C. C++. D. Windows. Pascal. System. exit. success. failure. They're never keywords. Hence, some other ones also don't really need

Re: accept @pure @nothrow @return attributes

2015-01-26 Thread Artur Skawina via Digitalmars-d
On 01/26/15 20:43, Walter Bright via Digitalmars-d wrote: On 1/26/2015 8:13 AM, Foo wrote: You could do the same as C++ with override and final: they are only valid attributes if they appear _after_ the function/method. Elsewhere they are still valid as identifiers for e.g. variables.

Re: reinterpret array

2015-01-13 Thread Artur Skawina via Digitalmars-d-learn
On 01/13/15 21:52, Dominikus Dittes Scherkl via Digitalmars-d-learn wrote: On Tuesday, 13 January 2015 at 20:11:45 UTC, anonymous wrote: On Tuesday, 13 January 2015 at 20:00:57 UTC, Dominikus Dittes Scherkl wrote: So if I have a function that allowes to do this: uint a; a.bit[16] = true;

Re: D idioms list

2015-01-08 Thread Artur Skawina via Digitalmars-d-announce
On 01/08/15 21:23, ketmar via Digitalmars-d-announce wrote: i'm not sure, but maybe it worth renaming struct inheritance to extending a struct? or even something completely different. what it does is actually extending/augmenting the struct, but not OO-inheritance, as one cannot pass augmented

Re: Copy only frame pointer between objects of nested struct

2015-01-06 Thread Artur Skawina via Digitalmars-d-learn
On 01/06/15 23:14, Peter Alexander via Digitalmars-d-learn wrote: auto foo(T)(T a) { T b; // Error: cannot access frame pointer of main.X b.data[] = 1; return b; } void main() { struct X { this(int) {} int[4096] data; } foo(X()); } Note

Re: compile-time opIndex

2015-01-01 Thread Artur Skawina via Digitalmars-d
On 12/31/14 22:35, H. S. Teoh via Digitalmars-d wrote: On Wed, Dec 31, 2014 at 10:34:07PM +0100, Artur Skawina via Digitalmars-d wrote: On 12/18/14 16:43, Steven Schveighoffer via Digitalmars-d wrote: We currently have the ability to do opIndex for simulating an array or other type indexed

Re: compile-time opIndex

2014-12-31 Thread Artur Skawina via Digitalmars-d
On 12/18/14 16:43, Steven Schveighoffer via Digitalmars-d wrote: We currently have the ability to do opIndex for simulating an array or other type indexed at runtime. But we have no way to simulate the ability of tuple indexing. Such an ability would unleash a huge amount of possibilities,

Re: `shared Mutex`?

2014-12-28 Thread Artur Skawina via Digitalmars-d-learn
On 12/28/14 10:24, Aiden via Digitalmars-d-learn wrote: Is `shared` in a workable state? No. Shouldn't Mutex, Condition, etc be shared since they are basically only ever useful when used in multiple threads? Yes, but there are so many problems with 'shared' that using it that way (even only

Re: Named parameter builder pattern for template parameters

2014-11-22 Thread Artur Skawina via Digitalmars-d
On 11/21/14 14:39, monarch_dodra via Digitalmars-d wrote: D has phenomenal meta programming possibilities [...] alias MyContainerType = ContainerBuilder!int //.setUseGC!??? //Don't care about GCm use default. .setScan!false .setUSomeOtherThing!true .Type;

Re: transversal sum

2014-11-06 Thread Artur Skawina via Digitalmars-d-learn
On 11/06/14 18:32, bearophile via Digitalmars-d-learn wrote: Marc Schütz: We'd need something taking and returning a RoR that mirrors them diagonally. Then we could simply apply `map!(r = r.sum)` on the result. A simple solution is to create a row of values, and then sum them correctly

Re: Error with constraints on a templated fuction

2014-08-25 Thread Artur Skawina via Digitalmars-d-learn
On 08/25/14 18:52, Jonathan M Davis via Digitalmars-d-learn wrote: Another commonly used one is is(typeof(foo)). typeof(foo) gets the type of foo and will result in void if foo doesn't exist, and is(void) is false, whereas D is not quite that simple. ;) static assert(is(void)==true); (a)

Re: auto ref deduction and common type deduction inconsistency

2014-08-20 Thread Artur Skawina via Digitalmars-d
On 08/20/14 23:39, deadalnix via Digitalmars-d wrote: On Tuesday, 19 August 2014 at 22:28:27 UTC, Peter Alexander wrote: It is especially problematic in generic code where you opportunistically want to return by ref when possible, e.g.: auto ref f(alias g, alias h)() { if (condition)

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Artur Skawina via Digitalmars-d-learn
On 08/16/14 13:18, Philippe Sigaud via Digitalmars-d-learn wrote: We indeed need to put annotations inside aggregates to affect their innards. If that's true, I have a lot of annotation sprinkling to do. It's not true for @safe, but true for some other attributes.

Re: @safe, pure and nothrow at the beginning of a module

2014-08-16 Thread Artur Skawina via Digitalmars-d-learn
On 08/16/14 13:58, Philippe Sigaud via Digitalmars-d-learn wrote: On Sat, Aug 16, 2014 at 1:30 PM, Artur Skawina via Digitalmars-d-learn http://forum.dlang.org/post/mailman.125.1397731134.2763.digitalmar...@puremagic.com Okay... So @safe includes child scopes. I suppose @trusted

Re: Named Global Arrays

2014-08-12 Thread Artur Skawina via Digitalmars-d
On 08/12/14 08:09, Tofu Ninja via Digitalmars-d wrote: This might already exist but I thought that it was cool that it was possible in D non the less. Just thought I would share :) struct namedGlobalArray(string name, T) { import std.typecons; T opDispatch(string var)(T x) {

Re: Named Global Arrays

2014-08-12 Thread Artur Skawina via Digitalmars-d
On 08/12/14 17:51, Tofu Ninja via Digitalmars-d wrote: On Tuesday, 12 August 2014 at 08:46:33 UTC, Artur Skawina via Digitalmars-d wrote: struct namedGlobalArray(string name, T) { template opDispatch(string M) { static T opDispatch; } } I love D so much 3 D can also be rather

Re: proposal: allow 'with(Foo):' in addition to 'with(Foo){..}'

2014-08-11 Thread Artur Skawina via Digitalmars-d
On 08/10/14 23:01, Era Scarecrow via Digitalmars-d wrote: Does with have to be only for statements? Real example. In my code somewhere i have a large list of enum types that specify a type of formatting and visibility options. [...] Now since i can't use with(): I'm forced to do aliases,

Re: opDispatch compiles fine, but still fails to resolve?

2014-08-09 Thread Artur Skawina via Digitalmars-d-learn
On 08/09/14 03:20, Vlad Levenfeld via Digitalmars-d-learn wrote: More opDispatch woes. This feature keeps biting me, yet I keep trying to use it. This time I'm trying to access elements of a vector GLSL-style (without swizzling... for now). Here's the relevant code: struct Vector

Re: assert semantic change proposal

2014-08-06 Thread Artur Skawina via Digitalmars-d
On 08/06/14 10:28, eles via Digitalmars-d wrote: On Wednesday, 6 August 2014 at 07:29:02 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 6 August 2014 at 06:56:40 UTC, eles wrote: Not right: b = a+1 assume(bC) implies assume(a+1C) b = a+1 b = a+1 if(C=b) exit(1); implies

  1   2   3   4   5   6   7   8   9   >