Re: Typescript with vibe.d

2020-03-09 Thread GreatSam4sure via Digitalmars-d-learn
On Monday, 9 March 2020 at 17:46:42 UTC, Steven Schveighoffer wrote: On 3/9/20 1:23 PM, GreatSam4sure wrote: [...] You can use it, but you have to compile it yourself. Vibe.d does nothing with the javascript except serve it to the browser. It has no restrictions on what files can be sent, bu

New with alias

2020-03-09 Thread tcak via Digitalmars-d-learn
I write a code as below: auto result = new char[4]; It allocates memory as expected. Later I define an alias and do the above step: alias Pattern = char[4]; auto result = new Pattern; But compiler says: Error: new can only create structs, dynamic arrays or class objects, not `char[4]`'s

Introduction and request for help

2020-03-09 Thread Kendell via Digitalmars-d-learn
Hey Everyone, I'm a new D developer and therefore new to Gtkd. By day I'm an android developer using Kotlin and most of my hobby projects are in Go. So far I've enjoyed my time working in D. I've been working on this project, https://gitlab.com/kendellfab/rest-scope, a rest testing proje

Re: @property with opCall

2020-03-09 Thread Timon Gehr via Digitalmars-d-learn
On 09.03.20 13:14, Adam D. Ruppe wrote: Here's a wiki page referencing one of the 2013 discussions https://wiki.dlang.org/Property_Discussion_Wrap-up https://wiki.dlang.org/DIP24

Re: Docs 6.9.4: Implicit Conversion to bool

2020-03-09 Thread Manfred Nowak via Digitalmars-d-learn
On Monday, 9 March 2020 at 16:44:55 UTC, Steven Schveighoffer wrote: You're not the first person to ask. Accepted.

Re: An struct copy constructor that can cope with an AA?

2020-03-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/9/20 11:49 AM, mark wrote: On Monday, 9 March 2020 at 14:45:15 UTC, Steven Schveighoffer wrote: On 3/9/20 9:23 AM, mark wrote: I have this struct: [snip] I would name it dup instead of copy for consistency with D. A copy constructor is pretty heavy for a struct to do a complete duplicati

Re: Typescript with vibe.d

2020-03-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/9/20 1:23 PM, GreatSam4sure wrote: On Monday, 9 March 2020 at 15:11:48 UTC, Steven Schveighoffer wrote: On 3/9/20 5:42 AM, GreatSam4sure wrote: I want to know if it is possible to use typescript with the vibe.d since typescript is a superset of javascript. I will appreciate any example if

Re: Typescript with vibe.d

2020-03-09 Thread GreatSam4sure via Digitalmars-d-learn
On Monday, 9 March 2020 at 15:11:48 UTC, Steven Schveighoffer wrote: On 3/9/20 5:42 AM, GreatSam4sure wrote: I want to know if it is possible to use typescript with the vibe.d since typescript is a superset of javascript. I will appreciate any example if it is possible My understanding is tha

Re: Docs 6.9.4: Implicit Conversion to bool

2020-03-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/9/20 11:35 AM, Manfred Nowak wrote: Having a function `f' overloaded for argument types `bool' and `ulong', the specs guarantee, that for `f( 1uL)' the boolean overload of `f' is called. What is this good for? You're not the first person to ask. https://github.com/dlang/DIPs/blob/maste

Re: std.datetime & timzone specifier: 2018-11-06T16:52:03+01:00

2020-03-09 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, March 8, 2020 11:19:33 PM MDT tchaloupka via Digitalmars-d-learn wrote: > On Sunday, 8 March 2020 at 17:28:33 UTC, Robert M. Münch wrote: > > On 2020-03-07 12:10:27 +, Jonathan M Davis said: > > > > DateTime dt = > > DateTime.fromISOExtString(split("2018-11-06T16:52:03+01:00", > > r

Re: An struct copy constructor that can cope with an AA?

2020-03-09 Thread mark via Digitalmars-d-learn
On Monday, 9 March 2020 at 14:45:15 UTC, Steven Schveighoffer wrote: On 3/9/20 9:23 AM, mark wrote: I have this struct: [snip] I would name it dup instead of copy for consistency with D. A copy constructor is pretty heavy for a struct to do a complete duplication of the AA. You should have to

Docs 6.9.4: Implicit Conversion to bool

2020-03-09 Thread Manfred Nowak via Digitalmars-d-learn
Having a function `f' overloaded for argument types `bool' and `ulong', the specs guarantee, that for `f( 1uL)' the boolean overload of `f' is called. What is this good for?

Re: static foreach / How to construct concatenated string?

2020-03-09 Thread MoonlightSentinel via Digitalmars-d-learn
On Sunday, 8 March 2020 at 20:28:01 UTC, Robert M. Münch wrote: You can get rid of the enum [...] That depends on your use case. You will need enum if you want to use the value at compile time (e.g. when using it as a template parameter). Otherwise a normal string will suffice. und the sta

Re: Typescript with vibe.d

2020-03-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/9/20 5:42 AM, GreatSam4sure wrote: I want to know if it is possible to use typescript with the vibe.d since typescript is a superset of javascript. I will appreciate any example if it is possible My understanding is that Typescript needs to be compiled to javascript. You can't serve type

Re: Typescript with vibe.d

2020-03-09 Thread Panke via Digitalmars-d-learn
On Monday, 9 March 2020 at 09:42:16 UTC, GreatSam4sure wrote: I want to know if it is possible to use typescript with the vibe.d since typescript is a superset of javascript. I will appreciate any example if it is possible What do you want to do?

Re: An struct copy constructor that can cope with an AA?

2020-03-09 Thread Steven Schveighoffer via Digitalmars-d-learn
On 3/9/20 9:23 AM, mark wrote: I have this struct: struct Deb {     string name;     ...     Unit[string] tags; // set of tags     Deb copy() const {     Deb deb;     ...     foreach (key, value; tags) // XXX     deb.tags[key] = value;     return deb;     }  

Re: " include imported modules in the compilation " should exclude di file

2020-03-09 Thread Calvin P via Digitalmars-d-learn
On Monday, 9 March 2020 at 13:55:08 UTC, Calvin P wrote: The current compiler "-i=module_name" option will include imported modules as source code. When the module define from di file extension, I think compiler should avoid treat it as source file. What do you think? The use case: If I

" include imported modules in the compilation " should exclude di file

2020-03-09 Thread Calvin P via Digitalmars-d-learn
The current compiler "-i=module_name" option will include imported modules as source code. When the module define from di file extension, I think compiler should avoid treat it as source file. What do you think?

Re: @property with opCall

2020-03-09 Thread Calvin P via Digitalmars-d-learn
On Monday, 9 March 2020 at 12:14:06 UTC, Adam D. Ruppe wrote: Here's a wiki page referencing one of the 2013 discussions https://wiki.dlang.org/Property_Discussion_Wrap-up though i'll note the thing is older than that. What especially drove me nuts is people would so often say "property *synt

Re: @property with opCall

2020-03-09 Thread 12345swordy via Digitalmars-d-learn
On Monday, 9 March 2020 at 12:14:06 UTC, Adam D. Ruppe wrote: On Monday, 9 March 2020 at 10:09:56 UTC, Calvin P wrote: @property exists so many years, Druntime & Phobos use it 2280 times. I can't believe it is not recommended. They never implemented it right. This opCall type thing was THE

An struct copy constructor that can cope with an AA?

2020-03-09 Thread mark via Digitalmars-d-learn
I have this struct: struct Deb { string name; ... Unit[string] tags; // set of tags Deb copy() const { Deb deb; ... foreach (key, value; tags) // XXX deb.tags[key] = value; return deb; } void clear() { name = "";

Re: @property with opCall

2020-03-09 Thread Adam D. Ruppe via Digitalmars-d-learn
On Monday, 9 March 2020 at 10:09:56 UTC, Calvin P wrote: @property exists so many years, Druntime & Phobos use it 2280 times. I can't believe it is not recommended. They never implemented it right. This opCall type thing was THE case we brought up to introduce @property in the first place..

Re: static foreach / How to construct concatenated string?

2020-03-09 Thread Timon Gehr via Digitalmars-d-learn
On 07.03.20 17:41, MoonlightSentinel wrote: On Saturday, 7 March 2020 at 16:30:59 UTC, Robert M. Münch wrote: Is this possible at all? You can use an anonymous lambda to build the string in CTFE: It turns out that if you do use this standard idiom, you might end up getting blamed for an unr

Re: @property with opCall

2020-03-09 Thread Calvin P via Digitalmars-d-learn
On Monday, 9 March 2020 at 09:44:40 UTC, Simen Kjærås wrote: As written on https://dlang.org/spec/function.html#property-functions: WARNING: The definition and usefulness of property functions is being reviewed, and the implementation is currently incomplete. Using property functions is not r

Re: @property with opCall

2020-03-09 Thread Simen Kjærås via Digitalmars-d-learn
On Monday, 9 March 2020 at 09:25:31 UTC, Calvin P wrote: Is this a bugs ? == struct A { ref auto opCall(string tmp) scope return { return this; } } struct B { A _a; @property ref auto a() scope return { return _a;

Typescript with vibe.d

2020-03-09 Thread GreatSam4sure via Digitalmars-d-learn
I want to know if it is possible to use typescript with the vibe.d since typescript is a superset of javascript. I will appreciate any example if it is possible

@property with opCall

2020-03-09 Thread Calvin P via Digitalmars-d-learn
Is this a bugs ? == struct A { ref auto opCall(string tmp) scope return { return this; } } struct B { A _a; @property ref auto a() scope return { return _a; } } extern(C) int main(){ A a; a("a")

Re: Idiomatic way to express errors without resorting to exceptions

2020-03-09 Thread Simen Kjærås via Digitalmars-d-learn
On Saturday, 7 March 2020 at 15:44:38 UTC, Arine wrote: The case when there isn't a value should be handled explicitly, not implicitly. Propogating a None value isn't useful Except when it is useful, and shouldn't be handled explicitly. I have code in D, C and C++ that looks like this:

Re: How to use sets in D?

2020-03-09 Thread mark via Digitalmars-d-learn
On Sunday, 8 March 2020 at 17:58:16 UTC, Jesse Phillips wrote: On Friday, 7 February 2020 at 19:37:08 UTC, mark wrote: [snip] I think I've usually used the associative arrays, but I also think I tend to avoid using this approach but couldn't quite remember what I do instead. I believe I have