Re: auto function attributes based on type

2015-03-11 Thread weaselcat via Digitalmars-d-learn
On Thursday, 12 March 2015 at 05:01:50 UTC, amber wrote: On Thursday, 12 March 2015 at 04:51:42 UTC, amber wrote: On Thursday, 12 March 2015 at 04:04:28 UTC, weaselcat wrote: On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote: ... http://dlang.org/function.html#function-attribute-inferenc

Re: auto function attributes based on type

2015-03-11 Thread amber via Digitalmars-d-learn
On Thursday, 12 March 2015 at 04:51:42 UTC, amber wrote: On Thursday, 12 March 2015 at 04:04:28 UTC, weaselcat wrote: On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote: ... http://dlang.org/function.html#function-attribute-inference might be a good read if you haven't read it already.

Re: auto function attributes based on type

2015-03-11 Thread amber via Digitalmars-d-learn
On Thursday, 12 March 2015 at 04:04:28 UTC, weaselcat wrote: On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote: ... http://dlang.org/function.html#function-attribute-inference might be a good read if you haven't read it already. I did read it but didn't really understand it, so I've com

Re: auto function attributes based on type

2015-03-11 Thread weaselcat via Digitalmars-d-learn
On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote: ... http://dlang.org/function.html#function-attribute-inference might be a good read if you haven't read it already.

auto function attributes based on type

2015-03-11 Thread amber via Digitalmars-d-learn
Hi, Is there a way in D to specify function attributes for a template struct/class by type? E.g. given a template struct/class as follows: --- struct S(T) { T[] values; void someFunc(int i) pure nothrow @safe {} } --- For some types the pure, nothrow, @safe attributes are valid and

Re: embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 21:45:20 UTC, Matt wrote: On Wednesday, 11 March 2015 at 19:32:05 UTC, Matt wrote: I'm trying to build a simple platformer using SDL2 and python to script entities, but I'm struggling to include Pyd. I'm using DMD v2.066.1, with dub as the package manager, and de

Re: is eC alot like D?

2015-03-11 Thread Parke via Digitalmars-d-learn
> On Wed, 11 Mar 2015 06:22:32 +, sclytrack wrote: >> - You can include C library headers directly in your .ec code, without >> any special keyword (like extern "C" in C++) On Wed, Mar 11, 2015 at 1:59 AM, ketmar via Digitalmars-d-learn wrote: > either i missed something, misunderstood what h

Re: How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 10:13:12 UTC, Théo Bueno wrote: On Wednesday, 11 March 2015 at 08:16:17 UTC, zhmt wrote: Now , my question is: How to get the position it crashes? Or get the method call stack? If you are developing under Linux, you can use GDB to debug your D apps, just like an

Re: Template Parameter Deduction

2015-03-11 Thread John Colvin via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 22:44:12 UTC, Paul D Anderson wrote: This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context con

Re: Template Parameter Deduction

2015-03-11 Thread Ali Çehreli via Digitalmars-d-learn
On 03/11/2015 03:44 PM, Paul D Anderson wrote: This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context context = T.context)

Re: Template Parameter Deduction

2015-03-11 Thread Paul D Anderson via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 22:44:12 UTC, Paul D Anderson wrote: This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context con

Template Parameter Deduction

2015-03-11 Thread Paul D Anderson via Digitalmars-d-learn
This used to work in D2.065: given 1) public T mul(T)(in T x, in T y, Context context = T.context) if (isDecimal!T) // one template parameter for the two input values and 2) public T mul(T, U)(in T x, U n, Context context = T.context) if (isDecimal!T && isIntegral!U) // two dif

Re: embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 19:32:05 UTC, Matt wrote: I'm trying to build a simple platformer using SDL2 and python to script entities, but I'm struggling to include Pyd. I'm using DMD v2.066.1, with dub as the package manager, and derelict for the SDL2 bindings. Now, when I add Pyd to my

embedding Pyd in Windows program

2015-03-11 Thread Matt via Digitalmars-d-learn
I'm trying to build a simple platformer using SDL2 and python to script entities, but I'm struggling to include Pyd. I'm using DMD v2.066.1, with dub as the package manager, and derelict for the SDL2 bindings. Now, when I add Pyd to my dub.json everything works fine, but as soon as I add py_i

Re: C++ to D

2015-03-11 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 18:10:55 UTC, FG wrote: And your point was...? I take it, "poor c++" is a hint. Don't compare apples to oranges. No, I forgot to remove from the foreign code.

Re: C++ to D

2015-03-11 Thread Dennis Ritchie via Digitalmars-d-learn
Thank you very much, Ali Çehreli and FG.

Re: C++ to D

2015-03-11 Thread FG via Digitalmars-d-learn
On 2015-03-11 at 18:27, Dennis Ritchie wrote: The same without classes in Lisp: [...] And your point was...? I take it, "poor c++" is a hint. Don't compare apples to oranges.

Re: C++ to D

2015-03-11 Thread FG via Digitalmars-d-learn
On 2015-03-11 at 17:42, Dennis Ritchie wrote: On Wednesday, 11 March 2015 at 16:08:22 UTC, Kagamin wrote: A hash table? See http://dlang.org/hash-map.html That is, the input is a string and, depending on what word it contains, is called one of the three methods of the class that this line han

Re: C++ to D

2015-03-11 Thread Ali Çehreli via Digitalmars-d-learn
On 03/11/2015 07:33 AM, Dennis Ritchie wrote: How to rewrite this in D to the handler method for the input parameter was determined on average in O(1)? D's associative arrays are hash tables. The following program is as similar to the C++ one as possible: import std.stdio; import std.range;

Re: enum and static if

2015-03-11 Thread Nicolas Sicard via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 17:19:20 UTC, ketmar wrote: On Wed, 11 Mar 2015 18:17:38 +0100, Artur Skawina via Digitalmars-d-learn wrote: 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

Re: C++ to D

2015-03-11 Thread Dennis Ritchie via Digitalmars-d-learn
The same without classes in Lisp: (define (foo) (let ((foo1 (lambda (s) s)) (foo2 (lambda (s) (list->string (reverse (string->list s) (foo3 (lambda (s) (string-append s ", " s " " (lambda (in) (match in ("first" foo1) ("second" foo2) (

Re: enum and static if

2015-03-11 Thread ketmar via Digitalmars-d-learn
On Wed, 11 Mar 2015 18:17:38 +0100, Artur Skawina via Digitalmars-d-learn wrote: > 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 +00

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 { >

Re: C++ to D

2015-03-11 Thread Dennis Ritchie via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 16:08:22 UTC, Kagamin wrote: A hash table? See http://dlang.org/hash-map.html That is, the input is a string and, depending on what word it contains, is called one of the three methods of the class that this line handles. And this happens in average cons

Re: C++ to D

2015-03-11 Thread Kagamin via Digitalmars-d-learn
A hash table? See http://dlang.org/hash-map.html

Re: Parallelization of a large array

2015-03-11 Thread Russel Winder via Digitalmars-d-learn
On Wed, 2015-03-11 at 07:10 -0700, Ali Çehreli via Digitalmars-d-learn wrote: > On 03/11/2015 01:07 AM, Russel Winder via Digitalmars-d-learn wrote: > > On Tue, 2015-03-10 at 15:34 -0700, Ali Çehreli via Digitalmars-d-learn > > wrote: > > […] > >> We can hope to make it simpler by taking advantage

Re: Bypass the protection level

2015-03-11 Thread Ali Çehreli via Digitalmars-d-learn
On 03/11/2015 04:40 AM, Namespace wrote: > I can call draw on Drawable, because it is declared public and I cannot > call draw on Sprite because it is declared protected (this is already a > bit weird, why can I redeclare the interface method draw as protected?) It is the same in C++. > but I c

Re: enum and static if

2015-03-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 11, 2015 14:55:01 Namespace via Digitalmars-d-learn wrote: > Thanks, I've hoped that 'static if' is a full replacement for #if Walter Bright has a rather dim view of #if and friends in C/C++ given how often he's seen them abused, which is why version and static if are more rest

Re: Bypass the protection level

2015-03-11 Thread Namespace via Digitalmars-d-learn
Could it be that this is intentional and has always worked?

Re: enum and static if

2015-03-11 Thread Namespace via Digitalmars-d-learn
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 (__VERSION__ >= 2067) Bar, } Quatz } Any chance that this could work? nope. `static if` is statement,

Re: enum and static if

2015-03-11 Thread ketmar via Digitalmars-d-learn
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 (__VERSION__ >= 2067) >>> Bar, >>>

Re: enum and static if

2015-03-11 Thread wobbles via Digitalmars-d-learn
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 (__VERSION__ >= 2067) Bar, } Quatz } Any chance that this could work? nope. `static if` is statement,

C++ to D

2015-03-11 Thread Dennis Ritchie via Digitalmars-d-learn
Hi. How to rewrite this in D to the handler method for the input parameter was determined on average in O(1)? #include #include #include #include class A { public: void foo(const std::string &s); protected: void foo1(const std::string &s); void foo2(const std::string &s);

Re: Parallelization of a large array

2015-03-11 Thread Ali Çehreli via Digitalmars-d-learn
On 03/11/2015 01:07 AM, Russel Winder via Digitalmars-d-learn wrote: On Tue, 2015-03-10 at 15:34 -0700, Ali Çehreli via Digitalmars-d-learn wrote: […] We can hope to make it simpler by taking advantage of parallel map but it requires a static local function or a global function (a lambda cannot

enum and static if

2015-03-11 Thread Namespace via Digitalmars-d-learn
This code does not work: enum Test { Foo, static if (__VERSION__ >= 2067) Bar, } Quatz } Any chance that this could work?

Re: D + .NET

2015-03-11 Thread Sativa via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 08:45:15 UTC, Kagamin wrote: http://wiki.dlang.org/Libraries_and_Frameworks#GUI_Libraries Can you point out where it says anything about wpf or .NET? I'm having trouble finding it. I even searched for .net and wpf but still no luck ;/ Maybe you posted the wrong

Re: Template. C++ to D

2015-03-11 Thread Dennis Ritchie via Digitalmars-d-learn
Thank you all.

Re: Template. C++ to D

2015-03-11 Thread Namespace via Digitalmars-d-learn
Or even shorter: import std.stdio; T foo(T, Args...)(auto ref const T val, auto ref const Args u) { static if (Args.length > 0) { static if (is(T == string)) return val ~ foo(u); else return val + foo(u); } else { return val; } } void

Re: Template. C++ to D

2015-03-11 Thread Rikki Cattermole via Digitalmars-d-learn
On 12/03/2015 1:02 a.m., Dennis Ritchie wrote: Hi. How to rewrite this code on D? #include #include template T foo(const T &val) { return val; } template T foo(const T &val, const U &...u) { return val + foo(u...); } int main() { std::cout << foo(std::string("some "), std::

Re: Template. C++ to D

2015-03-11 Thread Namespace via Digitalmars-d-learn
import std.stdio; T foo(T)(auto ref const T val) { return val; } T foo(T, Args...)(auto ref const T val, auto ref const Args u) { static if (is(T == string)) return val ~ foo(u); else return val + foo(u); } void main() { writeln(foo("some ", "test")); // prin

Template. C++ to D

2015-03-11 Thread Dennis Ritchie via Digitalmars-d-learn
Hi. How to rewrite this code on D? #include #include template T foo(const T &val) { return val; } template T foo(const T &val, const U &...u) { return val + foo(u...); } int main() { std::cout << foo(std::string("some "), std::string("test")) << std::endl; // prints some test

Bypass the protection level

2015-03-11 Thread Namespace via Digitalmars-d-learn
Let's say we have these files: module Foo.Graphic.Drawable; interface Drawable { void draw(bool); } module Foo.Graphic.Sprite; import Foo.Graphic.Drawable; class Sprite : Drawable { protected: void draw(bool enable) { import core.stdc.stdio : pri

Re: How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 10:13:12 UTC, Théo Bueno wrote: On Wednesday, 11 March 2015 at 08:16:17 UTC, zhmt wrote: Now , my question is: How to get the position it crashes? Or get the method call stack? If you are developing under Linux, you can use GDB to debug your D apps, just like an

Re: chaining splitters

2015-03-11 Thread Baz via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 00:00:39 UTC, dnoob wrote: Hello, I am parsing some text and I have the following; string text = "some very long text"; foreach(line; splitter(text, [13, 10])) { foreach(record; splitter(line, '*')) { foreach(field; splitter(record

Re: How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 11:09:42 UTC, Daniel Kozák wrote: On Wed, 11 Mar 2015 10:05:39 + zhmt via Digitalmars-d-learn wrote: I want to know how to locate the position of crashing in dlang? for example: there is stack dump in c, exception stack in java, they could help to locat

Re: How to find the cause of crash?

2015-03-11 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 11 Mar 2015 10:05:39 + zhmt via Digitalmars-d-learn wrote: > I want to know how to locate the position of crashing in dlang? > > for example: there is stack dump in c, exception stack in java, > they could help to locate the root of problems. > D has these too, you just need to

Re: How to find the cause of crash?

2015-03-11 Thread Daniel Kozák via Digitalmars-d-learn
On Wed, 11 Mar 2015 10:05:39 + zhmt via Digitalmars-d-learn wrote: > I want to know how to locate the position of crashing in dlang? > > for example: there is stack dump in c, exception stack in java, > they could help to locate the root of problems. > D has these too, you just need to

Re: How to find the cause of crash?

2015-03-11 Thread via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 08:16:17 UTC, zhmt wrote: Now , my question is: How to get the position it crashes? Or get the method call stack? If you are developing under Linux, you can use GDB to debug your D apps, just like any C/C++ program. Make sure you are compiling in debug mode in o

Re: chaining splitters

2015-03-11 Thread Dave S via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 00:00:39 UTC, dnoob wrote: Hello, I am parsing some text and I have the following; string text = "some very long text"; foreach(line; splitter(text, [13, 10])) { foreach(record; splitter(line, '*')) { foreach(field; splitter(record

Re: chaining splitters

2015-03-11 Thread ketmar via Digitalmars-d-learn
On Wed, 11 Mar 2015 00:00:38 +, dnoob wrote: > Hello, > > I am parsing some text and I have the following; > > string text = "some very long text"; > > foreach(line; splitter(text, [13, 10])) > { > foreach(record; splitter(line, '*')) > { > foreach(field; splitter(

Re: is eC alot like D?

2015-03-11 Thread ketmar via Digitalmars-d-learn
On Wed, 11 Mar 2015 06:22:32 +, sclytrack wrote: > - You can include C library headers directly in your .ec code, without > any special keyword (like extern "C" in C++) either i missed something, misunderstood what he means or he is simply wrong. i remember that there is no CPP macro process

Re: D + .NET

2015-03-11 Thread Kagamin via Digitalmars-d-learn
http://wiki.dlang.org/Libraries_and_Frameworks#GUI_Libraries

How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
I developed a socks5 proxy server with vibe.d. but it crashed after running a few minutes, with the output below: Task terminated with uncaught exception: Operating on closed TCPConnection. Task terminated with uncaught exception: Operating on closed TCPConnection. Task terminated with unhandl

Re: How to find the cause of crash?

2015-03-11 Thread zhmt via Digitalmars-d-learn
On Wednesday, 11 March 2015 at 08:16:17 UTC, zhmt wrote: I developed a socks5 proxy server with vibe.d. but it crashed after running a few minutes, with the output below: Task terminated with uncaught exception: Operating on closed TCPConnection. Task terminated with uncaught exception: Opera

Re: 2.067 Beta: Behavior of enum and ref changed

2015-03-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 10, 2015 13:26:00 Ali Çehreli via Digitalmars-d-learn wrote: > On 03/10/2015 11:05 AM, Ali Çehreli wrote: > > > In other words, the result of the implicit conversion is an rvalue > > Steven Schveighoffer says there is no rvalue in this case; "an enum is a > derivative": > >htt

Re: Parallelization of a large array

2015-03-11 Thread Russel Winder via Digitalmars-d-learn
On Tue, 2015-03-10 at 15:34 -0700, Ali Çehreli via Digitalmars-d-learn wrote: […] > We can hope to make it simpler by taking advantage of parallel map but > it requires a static local function or a global function (a lambda > cannot be used): […] Is there a reason for excluding lambdas, it a pri

D + .NET

2015-03-11 Thread Sativa via Digitalmars-d-learn
If I write a business model in D, how hard is it to hook up a presentation using something like wpf, win32, or even whatever mac does?