Re: unittests, dub and libraries

2018-03-27 Thread Joe via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 03:07:23 UTC, Jonathan M Davis wrote: Run dub test The problem is that an executable needs a main, and a library doesn't have one, whereas when you're testing a library, you need an executable. So, a main must be inserted - e.g. with the -main flag to dmd.

Re: unittests, dub and libraries

2018-03-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 28, 2018 02:16:59 Joe via Digitalmars-d-learn wrote: > I'm trying to build a very simple library. For now it just has a > single class, constructor, destructor and one method. I added a > unit test right after the method, declared the targetType to be > "library" and a

unittests, dub and libraries

2018-03-27 Thread Joe via Digitalmars-d-learn
I'm trying to build a very simple library. For now it just has a single class, constructor, destructor and one method. I added a unit test right after the method, declared the targetType to be "library" and a buildType of "unittest" (with options "unittests", "debugMode", "debugInfo"). When I

Re: Checking if a structs .init value is zero bits only

2018-03-27 Thread Seb via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 00:15:34 UTC, Per Nordlöw wrote: Is there a way to check if a struct `S` can be initialized using zero bits only, so that we can allocate and initialize an array of `S` in one go using `calloc`? If not, what should such a trait look like? Have a look at:

Re: Checking if a structs .init value is zero bits only

2018-03-27 Thread Ali Çehreli via Digitalmars-d-learn
On 03/27/2018 05:15 PM, Per Nordlöw wrote: Is there a way to check if a struct `S` can be initialized using zero bits only, so that we can allocate and initialize an array of `S` in one go using `calloc`? If not, what should such a trait look like? The following idea should work. One question

Checking if a structs .init value is zero bits only

2018-03-27 Thread Per Nordlöw via Digitalmars-d-learn
Is there a way to check if a struct `S` can be initialized using zero bits only, so that we can allocate and initialize an array of `S` in one go using `calloc`? If not, what should such a trait look like?

Re: utf.d codeLength asserts false on certain input

2018-03-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 27, 2018 23:29:57 Anonymouse via Digitalmars-d-learn wrote: > My IRC bot is suddenly seeing crashes. It reads characters from a > Socket into an ubyte[] array, then idups parts of that (full > lines) into strings for parsing. Parsing involves slicing such > strings into

utf.d codeLength asserts false on certain input

2018-03-27 Thread Anonymouse via Digitalmars-d-learn
My IRC bot is suddenly seeing crashes. It reads characters from a Socket into an ubyte[] array, then idups parts of that (full lines) into strings for parsing. Parsing involves slicing such strings into meaningful segments; sender, event type, target channel/user, message content, etc. I can

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-27 Thread Per Nordlöw via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 22:00:42 UTC, Johan Engelen wrote: Indeed. Please try to manually link first (without dub) by modifying the command on which dub errors: ``` ldmd2 -flto=thin

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-27 Thread Johan Engelen via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 13:28:08 UTC, kinke wrote: On Monday, 26 March 2018 at 23:32:59 UTC, Nordlöw wrote: forwarded as `-L-flto=thin` but still errors as Which is wrong, it's not a ld command-line option (i.e., the `-L` prefix is wrong). Indeed. Please try to manually link first

Re: Where is TypeInfo stored?

2018-03-27 Thread Jeremy DeHaan via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 19:06:38 UTC, Adam D. Ruppe wrote: On Tuesday, 27 March 2018 at 18:56:58 UTC, Jeremy DeHaan wrote: Are these put into the text or data segments? Yeah, they are in the data segment as static data (just like if you declared your own static array). Awesome,

Re: Where is TypeInfo stored?

2018-03-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 18:56:58 UTC, Jeremy DeHaan wrote: Are these put into the text or data segments? Yeah, they are in the data segment as static data (just like if you declared your own static array).

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 27, 2018 16:16:15 Adam D. Ruppe via Digitalmars-d-learn wrote: > On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: > > it was deemed too dangerous to have in suddenly really mean > > both scope and const, because it would potentially break a lot > > of code. > >

Where is TypeInfo stored?

2018-03-27 Thread Jeremy DeHaan via Digitalmars-d-learn
I was doing some experiments with the runtime and I didn't notice the TypeInfo instances being allocated by the GC. Are these put into the text or data segments? Is there anyway to find out more about this process?

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread Schrom, Brian T via Digitalmars-d-learn
On Tue, Mar 27, 2018 at 03:27:07AM -0600, Jonathan M Davis via Digitalmars-d-learn wrote: > > Because scope has mostly done nothing (it only affected delegates), in has > effectively been const without scope for its entire existence in D2 in spite > of the fact that it was supposed to be the

Comparing In-Person Interpretation Vs Video Interpretation

2018-03-27 Thread Globibo via Digitalmars-d-learn
In recent years, thanks to the rapid and continuous advancements in the field of technology, more companies are doing businesses across borders. Hence, language interpretation services have become extremely crucial in today's world. There are different types of interpretation services such as

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Mar 27, 2018 at 04:16:15PM +, Adam D. Ruppe via Digitalmars-d-learn wrote: > On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: > > it was deemed too dangerous to have in suddenly really mean both > > scope and const, because it would potentially break a lot of code. >

Re: How to use annotation get key name?

2018-03-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 15:38:48 UTC, Brian wrote: but you don't understand my means, I want have keys with multiple indeterminate names. You can pass an associative array (or better yet, a struct containing one) as a UDA and then use the regular loop over its keys and values. struct

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: it was deemed too dangerous to have in suddenly really mean both scope and const, because it would potentially break a lot of code. To be frank, this pisses me off to a ridiculous extent because if it "breaks" at all... THAT

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread SimonN via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 15:28:40 UTC, jmh530 wrote: static if (isMutable!T) bag[0] = rhs; else bag = [rhs]; I like this idea. I'd even take it a step futher: When T is a pointer or class reference, then we can put the reference on the stack

Re: How to use annotation get key name?

2018-03-27 Thread Brian via Digitalmars-d-learn
On Monday, 26 March 2018 at 08:50:31 UTC, Simen Kjærås wrote: On Monday, 26 March 2018 at 08:29:31 UTC, Brian wrote: Rust sample code: #[cfg(name = "users")] PHP sample code: /* @Table(name = "users") */ Java sample code: @Table(name = "users") How to use dlang get key name? If I

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 13:51:20 UTC, jmh530 wrote: How about: [snip] I can kind of like this more, but after re-reading your original post I'm not sure it really resolves your issue: struct Optional(T) { import std.traits : isMutable; T[] bag; this(T t) inout {

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread SimonN via Digitalmars-d-learn
On Monday, 26 March 2018 at 14:17:03 UTC, Jonathan M Davis wrote: Rebindable does is pretty questionable as far as the type system goes, but it does what it does by forcing pointer semantics on a class reference, so the point is arguable. Yeah, I've always assumed that Rebindable cannot be

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 13:02:50 UTC, aliak wrote: Hmm, now that I'm explicitly trying to produce it, I feel I maybe using inout incorrectly? struct Optional(T) { T[] bag; this(T t) { bag = [t]; } } struct S { Optional!(inout(int)) f() inout { return

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-27 Thread kinke via Digitalmars-d-learn
On Monday, 26 March 2018 at 23:32:59 UTC, Nordlöw wrote: forwarded as `-L-flto=thin` but still errors as Which is wrong, it's not a ld command-line option (i.e., the `-L` prefix is wrong). I don't use dub though, so I don't know how to fix it.

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread aliak via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 11:57:28 UTC, jmh530 wrote: On Tuesday, 27 March 2018 at 06:26:57 UTC, aliak wrote: [snip] By the by, how come inout has to be stack based and const/immutable/mutable doesn't? Isn't inout just one of those depending on context? Example? Hmm, now that I'm

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread Seb via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 11:24:01 UTC, Jonathan M Davis wrote: On Tuesday, March 27, 2018 09:58:11 bauss via Digitalmars-d-learn wrote: On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: > [...] So now "in" is basically just an alias and serves no real purpose or is there

Re: Is there something special required to use Appender.clear

2018-03-27 Thread Simen Kjærås via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote: Sorry if this is a stupid question, but is there something special required to call Appender.clear? When I attempt even just a simple use I am getting compile errors relating to `template object.clear`. From the documentation

Re: Is there something special required to use Appender.clear

2018-03-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote: Sorry if this is a stupid question, but is there something special required to call Appender.clear? When I attempt even just a simple use I am getting compile errors relating to `template object.clear`. When I try: import

Re: Is there something special required to use Appender.clear

2018-03-27 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote: Sorry if this is a stupid question, but is there something special required to call Appender.clear? When I attempt even just a simple use I am getting compile errors relating to `template object.clear`. When I try: import

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 11:24:01 UTC, Jonathan M Davis wrote: On Tuesday, March 27, 2018 09:58:11 bauss via Digitalmars-d-learn wrote: On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: > On Tuesday, March 27, 2018 09:15:43 Boris-Barboris via > > Digitalmars-d-learn wrote:

Is there something special required to use Appender.clear

2018-03-27 Thread Ellie Harper via Digitalmars-d-learn
Sorry if this is a stupid question, but is there something special required to call Appender.clear? When I attempt even just a simple use I am getting compile errors relating to `template object.clear`. When I try: import std.array; void main(string[] args){ auto foo =

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 06:26:57 UTC, aliak wrote: [snip] By the by, how come inout has to be stack based and const/immutable/mutable doesn't? Isn't inout just one of those depending on context? Example?

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 27, 2018 09:58:11 bauss via Digitalmars-d-learn wrote: > On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: > > On Tuesday, March 27, 2018 09:15:43 Boris-Barboris via > > > > Digitalmars-d-learn wrote: > >> Hello! Can someone point me to the changelong entry or

Re: Building application with LDC and -flto=thin fails in link stage

2018-03-27 Thread Arek via Digitalmars-d-learn
On Monday, 26 March 2018 at 22:07:49 UTC, Nordlöw wrote: When I try build my application using LDC and -flto=thin it fails in the final linking as According to LDC's Release info: Known issues: ThinLTO may not work well with the ld.bfd linker, use ld.gold instead (-linker=gold). Maybe

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: On Tuesday, March 27, 2018 09:15:43 Boris-Barboris via Digitalmars-d-learn wrote: Hello! Can someone point me to the changelong entry or maybe a pull request, wich changed the "in" from "scope const" to "const"? I thought the

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread Boris-Barboris via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 09:27:07 UTC, Jonathan M Davis wrote: On Tuesday, March 27, 2018 09:15:43 Boris-Barboris via Now that DIP 1000 is being implemented, and scope is actually going to do something for more than just delegates, it was deemed too dangerous to have in suddenly really

Re: "in" no longer "scope" since 2.079.0?

2018-03-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, March 27, 2018 09:15:43 Boris-Barboris via Digitalmars-d-learn wrote: > Hello! Can someone point me to the changelong entry or maybe a > pull request, wich changed the "in" from "scope const" to > "const"? I thought the previous matter of things was pretty > natural, and current "in"

"in" no longer "scope" since 2.079.0?

2018-03-27 Thread Boris-Barboris via Digitalmars-d-learn
Hello! Can someone point me to the changelong entry or maybe a pull request, wich changed the "in" from "scope const" to "const"? I thought the previous matter of things was pretty natural, and current "in" is now redundant. Would be glad to read up on this design decision.

Re: Truly automatic benchmarking

2018-03-27 Thread Nordlöw via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 08:41:41 UTC, bauss wrote: Perhaps https://dlang.org/phobos/std_datetime_stopwatch.html#benchmark ? That fulfils neither of my two requirements mentioned in above; it requires explicit iteration count given by the caller and no automatic printing of results.

Re: Truly automatic benchmarking

2018-03-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 08:18:43 UTC, Nordlöw wrote: Have anybody implemented anything near the expressiveness and ease of use of Rust's builtin benchmarking features https://doc.rust-lang.org/1.16.0/book/benchmark-tests.html I'm mostly interested in completely automatic printing of

Truly automatic benchmarking

2018-03-27 Thread Nordlöw via Digitalmars-d-learn
Have anybody implemented anything near the expressiveness and ease of use of Rust's builtin benchmarking features https://doc.rust-lang.org/1.16.0/book/benchmark-tests.html I'm mostly interested in completely automatic printing of results such as test tests::bench_add_two ... bench:

Re: importPaths option in dub

2018-03-27 Thread bauss via Digitalmars-d-learn
On Tuesday, 27 March 2018 at 06:34:29 UTC, ANtlord wrote: Hello! I work using Linux. Is it possible to use environment variables like $HOME in option importPaths of Dub project file? I tried it but dub concatenates the path and current path so I get something like this

importPaths option in dub

2018-03-27 Thread ANtlord via Digitalmars-d-learn
Hello! I work using Linux. Is it possible to use environment variables like $HOME in option importPaths of Dub project file? I tried it but dub concatenates the path and current path so I get something like this /develop/project/$HOME/.dub/packages/gtk-d/generated/gtkd or

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread aliak via Digitalmars-d-learn
On Monday, 26 March 2018 at 11:19:31 UTC, Seb wrote: On Monday, 26 March 2018 at 10:13:08 UTC, Simen Kjærås wrote: On Monday, 26 March 2018 at 09:46:57 UTC, Nicholas Wilson wrote: Have a look at Rebindable: https://dlang.org/phobos/std_typecons.html#rebindable Allow me to quote from aliak's

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread aliak via Digitalmars-d-learn
On Monday, 26 March 2018 at 21:17:10 UTC, jmh530 wrote: On Sunday, 25 March 2018 at 21:26:57 UTC, aliak wrote: Hi, I have this optional type I'm working on and I've run in to a little snag when it comes to wrapping an immutable. Basically what I want is for an Optional!(immutable T) to still

Re: Is socket.send thread safe?

2018-03-27 Thread Dmitry Olshansky via Digitalmars-d-learn
On Monday, 26 March 2018 at 16:14:31 UTC, Jonathan wrote: Can I send data over an std.socket on multiple threads without manual mutexing? If not, can I send data on a separate thread than receive? The docs for std.socket say nothing of it (which I guess means I should assume it is not thread

Re: Optional type - how to correctly reset a wrapped immutable T

2018-03-27 Thread aliak via Digitalmars-d-learn
On Sunday, 25 March 2018 at 23:00:11 UTC, Simen Kjærås wrote: On Sunday, 25 March 2018 at 21:26:57 UTC, aliak wrote: struct Optional(T) { Unqual!T value; opAssign(T t) { value = cast(Unqual!T)(t); } } Consider this case: Optional!(immutable int) a = some(3); immutable int* p = a =