Re: Orange not working?

2018-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-07-13 20:52, Jacob Carlborg wrote: Orange master is working properly. The tests are run on each push and PR with the latest DMD compiler. I just added a cron job in Travis CI as well to make sure it every month even though there hasn't been a commit. This will make sure it always

Re: Orange not working?

2018-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-07-13 14:59, Timoses wrote: Huh, see this issue on github: https://github.com/jacob-carlborg/orange/issues/39 which references to https://github.com/jacob-carlborg/mambo . Although that repository has last been updated in 2016 whereas Orange's was Oct. 2017. Yeah, Mambo was a

Re: Orange not working?

2018-07-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-07-12 22:44, JN wrote: I am trying to make use of the Orange package, I added the latest version from dub to my project: "orange": "~>1.0.0" and copy pasted the "simple usage" code from https://github.com/jacob-carlborg/orange , but I am getting a long list of errors:

Re: [dub] Error: module `main` from file source\main.d is specified twice on the command line

2018-06-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-06-22 21:41, Anonymouse wrote: I'm trying to set up AppVeyor to build and test my project. After some dancing to get a 64-bit dmd.exe in there (which should really be included in the 7z in 2018) everything seems like it should work, but compiling with dub build fails. dub test works but

Re: Orange check failling all of a sudden

2018-06-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-06-11 20:00, DigitalDesigns wrote: Changed some things in my app but unrelated to serialization and now my app fails when trying to read the xml that was generated at the output of the previous run. Where it is failing is here: void checkSpace(ref string s) @safe pure // rule 3

Re: Orange check failling all of a sudden

2018-06-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-06-12 02:13, DigitalDesigns wrote: I also get a lot of inout's attached to key names. Seems excessive but inout(inout(double)[]) Maybe they are necessary but seems like they are redundant. I don't think they're technically necessary. -- /Jacob Carlborg

Re: Orange check failling all of a sudden

2018-06-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-06-13 02:31, DigitalDesigns wrote: Also, is there any way to have a field as optional? Right now when I update a filed in a serialized type the app crashes because it can't find the field in the serialized data(since it was just added in the code). This requires either regenerating the

Re: Orange serializer/deserializer

2018-06-07 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 6 June 2018 at 20:46:22 UTC, InfiniteDimensional wrote: I did register the main derived type and everything seems to work. Why do I have to reset the registered types? Do you have to reset the registered types? What happens otherwise? I still can't have a void* in my class

Re: Runtime introspection, or how to get class members at runtime Fin D

2018-06-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-06-06 15:28, Arafel wrote: Hi, What is the state of runtime introspection in D, specifically for classes? Is there any way to get *at runtime* the (public or otherwise accessible) members of a class? I have had a look as TypeInfo_Class [1], but apparently I can only get a list of

Re: Orange serializer/deserializer

2018-06-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-06-05 19:47, InfiniteDimensional wrote: Thanks. I'm having problems preventing void* pointers from not being serialized ..\..\..\orange\serialization\Serializer.d(975): Error: expression `*value` is `void` and has no value ..\..\..\orange\serialization\Serializer.d(1491): Error:

Re: Orange serializer/deserializer

2018-06-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-06-05 20:14, InfiniteDimensional wrote: I'm also having some issue now when I changed a type from using a class to using it's base interface Unhandled exception: orange.serialization.SerializationException.SerializationException The object of the static type "const(ItemInterface)"

Re: Orange serializer/deserializer

2018-06-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-06-02 03:30, IntegratedDimensions wrote: How can I modify the pre serialization and post serialization values? I need to transform some variables that are stored but I would like to do this easily "inline"(would be cool to be able to provide a delegate to do the transformations at the

Re: Translate C/C++ patern: return a pointer

2018-05-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-05-24 11:10, biocyberman wrote: Thanks for the hints. `Read` in C++ and D are both classes. And the function is inside the class definition itself. In that case specifying the type as `Read` is the correct thing to do. Note that `new` always allocates on the heap and returns a

Re: try & catch / repeating code - DRY

2018-05-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-05-24 08:05, Robert M. Münch wrote: Hi, great! Thanks for the examples... BTW: Is there a place where such generic and fundamental examples are collected? Not as far as I know. void handleException1(alias dg)() { try dg(); catch (Exception e) { /* handle exception */ } }

Re: try & catch / repeating code - DRY

2018-05-22 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-05-22 20:20, Robert M. Münch wrote: I see that I'm writing try { ... different code ... } catch (myException e) { ... same handling code ... } over and over again. Of course I can put the exception handling code into a function to not duplicate it. However, I still need to write

Re: Optional parameters?

2018-04-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-04-01 17:54, Steven Schveighoffer wrote: I currently have a situation where I want to have a function that accepts a parameter optionally. I thought maybe Nullable!int might work: void foo(Nullable!int) {} void main() {    foo(1); // error    int x;    foo(x); // error }

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

2018-03-29 Thread Jacob Carlborg via Digitalmars-d-learn
On Wednesday, 28 March 2018 at 20:09:24 UTC, Johan Engelen wrote: On Wednesday, 28 March 2018 at 17:03:07 UTC, Seb wrote: dub supports dflags and lflags in the config file. lflags are the linker commands. Please read the thread. `lflags` is for passing flags to the _linker_ (i.e. those

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-22 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 22 March 2018 at 09:55:44 UTC, Russel Winder wrote: I am guessing you mean against DStep rather than D :-) Yes :) Though clearly T and I would prefer version not to be a D keyword. I suspect I have seen one place where DStep has turned version into version_ where version was

Re: OK, I'm stumped on this one: dstep, struct, mixin, bitfields

2018-03-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-21 20:30, Russel Winder wrote: Thanks to Adam and Ali, it was clear and obvious. Please report and issue so it's not forgotten. -- /Jacob Carlborg

Re: Packages and module import

2018-03-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-21 17:06, Russel Winder wrote: No I wasn't. And it works a treat. Cool :). I recommend having a look at the changelog and the usage information (--help). -- /Jacob Carlborg

Re: Packages and module import

2018-03-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-19 18:29, Russel Winder wrote: I had assumed that a directory of modules was a package. So for example: A/a.d A/b.d were two modules in package A. Especially given there is a module statement at the beginning of each module: A/a.d has module A.a; A/b.d has module

Re: Incomprehensible error message

2018-03-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-19 19:03, H. S. Teoh wrote: Yeah, the compiler really ought to be outputting FQNs in error messages, since otherwise you get baffling A != A messages. Though outputting FQNs everywhere has the tendency of bloating error messages to unreadable lengths, esp. when templates are

Re: How to build static linked executable

2018-03-20 Thread Jacob Carlborg via Digitalmars-d-learn
On Tuesday, 20 March 2018 at 10:37:55 UTC, zunkree wrote: So, how to build static binary for macOS? I don't see a need to do that. I build static binaries on Linux because they work across all distros and all versions. But for macOS, there are no distros. For supporting multiple versions,

Re: How to build static linked executable

2018-03-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-17 16:42, Seb wrote: Yes, use -static Here's how we build the DTour: https://github.com/dlang-tour/core/blob/master/dub.sdl FYI, -static is not support on macOS. -- /Jacob Carlborg

Re: Can't "is null" an interface?!?! Incompatible types???

2018-03-08 Thread Jacob Carlborg via Digitalmars-d-learn
On Thursday, 8 March 2018 at 08:04:54 UTC, Nick Sabalausky (Abscissa) wrote: Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't appear to work on run.dlang.io). But it does seem to work for me if I use 'v0.8.3-alpha.1'. I wonder what could have changed to result in this? It's a

Re: What's the proper way to add a local file dependence to dub?

2018-03-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-04 17:46, Marc wrote: then copy it to sources folder? let's say I have a small library folder at C:\mylibrary\D where I want to use dir.d from it. How do I add that file dependence to dub? But I do not want to that file be passed directly to dmd, I want to that file be copied to

Re: Is it possible to return the subclass from a method of the parent class in dlang?

2018-03-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-03-02 21:23, Christian Köstlin wrote: To give an example: class Thread { ... Thread start() {...} } class Timer : Thread { ... } void main() { // Timer timer = new Timer().start; // this does not work auto timer = new Timer().start; // because timer is of type Thread

Re: what's the point of function template declarations if they can't be defined?

2018-02-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-07 22:39, Timothee Cour wrote: ``` void fun_bad3(T)(T a); // declaration [1] void fun_bad3(T)(T a){}; // definition [2] void test(){ fun_bad3(1); } ``` Error: test_all.fun_bad3 called with argument types (int) matches both: main.d(11): test_all.fun_bad3!int.fun_bad3(int a)

Re: macOS preview D files

2018-02-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-07 20:28, Joel wrote: On Wednesday, 7 February 2018 at 12:45:43 UTC, Jacob Carlborg wrote: On 2018-02-07 02:24, Joel wrote: Using finder, I want to see D files shown in the preview column, I some times have with TextMate. Also on my iPhone (in iCloud app, open as a text file) would

Re: Vibe.d rest & web service?

2018-02-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-07 18:04, Nicholas Wilson wrote: Is it possible to have some urls routed to serve content and some to receive JSON in the same class? Basically I want: shared static this() { auto router = new URLRouter; auto a = new MyInterface; router.registerWebInterface(new

Re: extern(C++) in win32.mak

2018-02-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-07 14:47, Paul D Anderson wrote: I get Error: 'of..\generated\windows\release\32\lexer.lib' not found I don't think this file is built anymore. -- /Jacob Carlborg

Re: macOS preview D files

2018-02-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-07 02:24, Joel wrote: Using finder, I want to see D files shown in the preview column, I some times have with TextMate. Also on my iPhone (in iCloud app, open as a text file) would be a bonus too. D is not recognized correctly by TextMate, I'm working on fixing that. -- /Jacob

Re: DLangUI Drag and Drop support?

2018-02-06 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-06 09:32, Andres Clari wrote: But DWT doesn't support macOS right? That would be my main target... Aha, no it doesn't. -- /Jacob Carlborg

Re: GUI program on Mac OS in D?

2018-02-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-05 16:49, mrphobby wrote: I've been playing around with this a bit and it works pretty well. One thing that bothers me is the handling of NSString. I came up with the following class to handle strings and make sure they do not leak. But maybe there is a nicer way to handle this in

Re: Getting compiler Segfault

2018-02-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-04 13:52, Ur@nuz wrote: Getting compiler stack overflow when building my project, but still do not know how to localize piece of code that triggers this bug. Maybe this bug is already registered in bugzilla or someone could give some advice where to dig into? Just runed building

Re: DLangUI Drag and Drop support?

2018-02-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-02-03 19:06, Andres Clari wrote: Hi, is there support for drag and drop in dlangui?? I haven't found anything on the docs, issues or forums. I'm building a project that requires support for dropping URLs from the browser into a ListWidget. Is this possible with dlangui at all? DWT

Re: How to test a DUB-based library during development?

2018-02-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-11 13:27, DanielG wrote: I want to create a library and eventually publish it via the DUB registry. Is there a simple example that shows how to test the library during development, before publishing (ie, before being able to add it as a dependency to another project)? I guess I'm

Re: Cannot initialize associative array

2018-01-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-20 00:16, rumbu wrote: According to this (https://dlang.org/spec/hash-map.html#static_initialization) this is correct static initialization for AA: immutable RoundingMode[string] ibmRounding = [     ">" : RoundingMode.towardPositive,     "<" : RoundingMode.towardNegative,    

Re: core.sys.posix.setjmp unavailable for OS X?

2018-01-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-16 08:29, Jacob Carlborg wrote: They're used to implement Objective-C exceptions on macOS 32bit and iOS. Forgot the second part: ... so I assume that means it works. -- /Jacob Carlborg

Re: core.sys.posix.setjmp unavailable for OS X?

2018-01-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-15 20:37, H. S. Teoh wrote: It's probably just a matter of adding the appropriate prototypes / declarations to druntime. Provided that they actually work as advertised, of course. They're used to implement Objective-C exceptions on macOS 32bit and iOS. -- /Jacob Carlborg

Re: Cannot use local lambda as parameter to non-global template

2018-01-15 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-15 14:55, Nordlöw wrote: Why do I get errors like template instance remove!((_) => _ == 1) cannot use local '__lambda5' as parameter to non-global template remove()(in K key) for     x.remove!(_ => _ == 1); but not for     x.remove!"a == 11"; ? How are these two lambdas

Re: Using Postgres connection functions

2018-01-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-13 05:17, Joe wrote: I'm trying to learn how to use D to connect (and send queries) to Postgres, i.e., libpq in C. So my question is: is there an easier or better way of passing two arrays of C null-terminated strings to an extern(C) function? There's a native D library, ddb [1],

Re: Is there a way to get this associative array initialization to work?

2018-01-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-10 17:29, Steven Schveighoffer wrote: Right, but it doesn't work in variable declarations if that variable is part of an associative array. In other words: struct S {    int x; } struct T {    S s; } T t = {s: {x: 1}}; // nesting works here S[] arr = [{x: 1}, {x:2}]; // and

Re: Is there a way to get this associative array initialization to work?

2018-01-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-10 00:19, Steven Schveighoffer wrote: https://issues.dlang.org/buglist.cgi?list_id=218715=not%20an%20associative%20array%20initializer_type=allwordssubstr_format=advanced=--- Note, I think you need at least Sound.SOUND_EFFECT, etc. This bug looks particularly relevant:

Re: Efficient way to pass struct as parameter

2018-01-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-03 08:02, Tim Hsu wrote: It needs some experiment. This is the correct answer. Never assume anything about performance before having tested it. -- /Jacob Carlborg

Re: C++ interfaces and D dynamic arrays

2018-01-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2018-01-02 17:48, Void-995 wrote: Hi, everyone. I would like to have an interface that can be implemented and/or used from C++ in D. One of the things I would like to keep is the nice feature of D dynamic arrays in terms of bounding checks and "length" property. Let's assume: extern

Re: A DUB Case Study: Compiling DMD as a Library

2017-12-21 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-21 05:12, Venkat wrote: I did a fresh clone of dmd and added that as a dependency. That fixed it. Should've thought of it !! Thankyou. Great that it works :) -- /Jacob Carlborg

Re: A DUB Case Study: Compiling DMD as a Library

2017-12-20 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-20 05:52, Venkat wrote: This is regarding the latest D blog post. Jacob Carlborg is here, so I figured I'd post it. https://dlang.org/blog/2017/08/01/a-dub-case-study-compiling-dmd-as-a-library/#comment-2922 Simply changing the targetType from library to dynamicLibrary breaks

Re: Dub project has both .sdl and .json files. Is this normal or did I do something wrong?

2017-12-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-18 23:36, WhatMeWorry wrote: I've been using Dub for a while but from the very beginning I decided to go with SDL 100% of the time, So I've got a dub.sdl file like: name "01_10_camera_view_space" description "A minimal D application." authors "kheaser" copyright "Copyright © 2017,

Re: Dub project has both .sdl and .json files. Is this normal or did I do something wrong?

2017-12-19 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-18 23:57, WebFreak001 wrote: dub.selections.json is basically broken design The design is fine, not so sure about the implementation. I've explain many time before why it's necessary. -- /Jacob Carlborg

Re: Write native GUI applications for Windows

2017-12-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-18 08:55, Andrey wrote: Hello! I have a question about creating native GUI applications for Windows 7 or/and Windows 10. I know that exist DWT, DlangUI and other... But I'm interesting in native GUI. If it will be C++ then I would use WinAPI from SDK. DWT _is_ a native GUI, it

Re: Passing anonymous enums as function parameters

2017-12-18 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-17 20:45, Jonathan M Davis wrote: That's pretty much just declaring manifest constants with braces so that you don't repeat the keyword enum a bunch of times. Anonymous enum is what the spec calls it and was available before manifest constants. -- /Jacob Carlborg

Re: Passing anonymous enums as function parameters

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-17 12:49, kerdemdemir wrote: I have an enum statement : enum : string {     KErdem     Ali     Zafer     Salih     //etc... } I don't want to give a name to my enum class since I am accessing this variables very often. But I also have a function like: double

Re: Dub generate import files

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-17 02:32, Venkat wrote: dmd has the -H and -Hd switches. Does dub have any setting to make it generate D interface files ? Not that I know of, but you can create your own build type for that [1] [1] http://code.dlang.org/package-format?lang=sdl#build-types -- /Jacob Carlborg

Re: Does D have class' attributes like C#'s?

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-16 22:11, Marc wrote: I can't "pack" an object, right? In C#, TextSize is a class and 256 is constructor's first argument. In D it's pretty much an array but I guess it's close enough. Thanks! In D it's an tuple of basically anything that is known at compile time, values or

Re: Dynamic Array reserve

2017-12-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-16 15:11, Vino wrote: Hi All,  Request your help on reserve an dynamic array when the capacity is reached to a point(eg: 80%) so the array to extend the reserve by next 20% Example: Array!string Test; Test. reserve(100) - Initall Test =(.) - The number of entries are

Re: GUI program on Mac OS in D?

2017-12-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-14 20:06, mrphobby wrote: Ok, I see! Sounds like I'll have to wait then. How long do you think it will take until DIP43 is available for use? Is it months or years we are talking about here? It will take more than months to have the complete set of features of DIP43 available,

Re: GUI program on Mac OS in D?

2017-12-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-14 14:56, mrphobby wrote: Also, it feels a bit awkward to implement the callback handling methods as static methods, with the "self" and SEL arguments. Would have been nice if it was possible to use instance methods. That's currently not possible. The "self" and SEL arguments are

Re: Global variable type does not match previous declaration

2017-12-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-13 22:38, Satoshi wrote: What means this error and how to solve it? object.d-mixin-1072(1112): Error: Global variable type does not match previous declaration with same mangled name: _D10TypeInfo_m6__initZ Actually, I'm working on OS with minimal D runtime and I'm unable to

Re: GUI program on Mac OS in D?

2017-12-14 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-13 16:59, mrphobby wrote: I have another question about your Webkit test example... I see that you are doing some elaborate setup in order to bind the application delegate methods. Can you explain a bit about why you are doing it in this way instead of using the @selector attribute

Re: GUI program on Mac OS in D?

2017-12-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-13 16:07, Jacob Carlborg wrote: On 2017-12-13 13:18, mrphobby wrote: Would it be possible to somehow hook this up automatically to the D destructor perhaps? Interested in hearing your thoughts on this! As far as I know, the destructor is only called (automatically by the GC).

Re: GUI program on Mac OS in D?

2017-12-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-13 13:18, mrphobby wrote: I have been taking a look at your example. Looks pretty neat! Some advanced mixin stuff there that looks pretty useful. They're pretty basic ;) However, as far as I can tell there is no handling of retain/release. No, that's correct. How would you

Re: Create D portable binary

2017-12-08 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-08 06:16, Fra Mecca wrote: Is there a way to compile a project and deploying it as a single statically linked binary? My main target would be something like a self contained jar (like .war files), but something that is in the style of go binaries and portable to another Linux

Re: What is "stringImportPaths"

2017-12-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-06 20:05, mrphobby wrote: Can anyone explain what "stringImportPaths" is? I have seen this being used in dub.json files and I think I kind of know what it does, but I haven't been able to find a clear explanation in any documentation of what it does. It does not look like anything

Re: GUI program on Mac OS in D?

2017-12-07 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-06 17:50, mrphobby wrote: I'm also interested in making native macOS apps. I have a lot of experience in Objective-C but I'm new at D. I'm a bit confused at what documentation to look at. In [1] I get the impression that support for creating instances is very rudimentary, but in

Re: lower case only first letter of word

2017-12-05 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-05 15:34, Mengu wrote: this is how i'd do it: string upcaseFirst(string wut) {   import std.ascii : toUpper;   import std.array : appender;   auto s = appender!string;   s ~= wut[0].toUpper;   s ~= wut[1..$];   return s.data; } That's not Unicode aware and is only safe to

Re: Object oriented programming and interfaces

2017-12-04 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-04 21:43, Dirk wrote: Hi! I defined an interface: interface Medoid {     float distance( Medoid other );     uint id() const @property; } and a class implementing that interface: class Item : Medoid {     float distance( Item i ) {...}     uint id() const @property {...} }

Re: Struct inside a class: How to get outer?

2017-12-03 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-03 10:57, Nick Sabalausky (Abscissa) wrote: On 12/03/2017 03:46 AM, bauss wrote: It wouldn't make much sense either, if a struct  was able to do it. Why is that? It would get an extra field, making the size of the struct larger and not compatible with a C struct. But I guess

Re: scope(exit) and Ctrl-C

2017-12-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-02 02:26, Adam D. Ruppe wrote: But this is intentional - there is no generic, reliable, cross-platform way of handling it natively. So you need to know the system and code it yourself. Not super hard but does take a bit of effort in your code. Since the "scope" block is not

Re: gdc-6.3.0 on travis borked?

2017-12-01 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-01 07:20, Nick Sabalausky (Abscissa) wrote: When using gdc-6.3.0 on travis-ci, travis is reporting that it can't download the compiler: -- $ source "$(CURL_USER_AGENT="$CURL_USER_AGENT" bash install.sh gdc-6.3.0 --activate)"

Re: Instructions to build DMD from source don't work (anymore) here

2017-11-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-30 12:19, Basile B. wrote: That's strange because as said i had g++ / c++ but DMD compiles only once gcc-c++ setup. Anyway, working now. It should be possible to get which package the "g++" file belongs to [1]. [1]

Re: Instructions to build DMD from source don't work (anymore) here

2017-11-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-30 09:56, Basile B. wrote: On Thursday, 30 November 2017 at 08:38:15 UTC, Basile B. wrote: [...] All required tools are setup. I do not set AUTOBOOTSTRAP=1 since dmd 2.077 is setup. I needed gcc-c++... I don't know why but since "which g++" gave a valid file name i thought it was

Re: Shared and race conditions

2017-11-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-29 17:13, Wanderer wrote: I'm trying to simulate a race condition in D with the following code: I'm not sure what your end goal is but perhaps you could try to see if the LLVM thread sanitizer [1] can be used with LDC. The thread sanitizer can identify race conditions even though

Re: Linking multiple libraries

2017-11-26 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-25 23:31, Mike Parker wrote: You don't link static libraries with each other. They're just collections of object files intended to be linked with an executable or a DLL. Order doesn't matter for optlink or the MS linker, but other linkers, such as ld (which is commonly used with

Re: GUI program on Mac OS in D?

2017-11-24 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-24 16:09, Adam D. Ruppe wrote: Thanks, this gets me started. Do you happen to know if there is anything like "pragma(lib)" for the -framework argument? (I don't use dub, so I took your config there to make my own command line, but it would be nice if I didn't have to specify the

Re: GUI program on Mac OS in D?

2017-11-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-23 17:06, Adam D. Ruppe wrote: I know we have the extern(Objective-C) stuff from https://wiki.dlang.org/DIP43 now, but do we have existing bindings anywhere along the lines of the win32 ones we can just import and start calling the operating system functions? Not as far as I know.

Re: Error: 'this' is only defined in non-static member functions

2017-11-23 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-23 01:35, Jonathan M Davis wrote: It would make sense with something like the nodes of a linked list if they needed access to the container for some reason. Pretty much any case where a an instance of a nested class is going to be associated with a specific instance of its parent

Re: How you guys go about -BetterC Multithreading?

2017-11-10 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-10 14:30, Petar Kirov [ZombineDev] wrote: static constructors Yeah, those won't work. I don't think that's really related to TLS, hence my confusion. -- /Jacob Carlborg

Re: How you guys go about -BetterC Multithreading?

2017-11-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-09 17:52, Petar Kirov [ZombineDev] wrote: Thanks for reminding me, I keep forgetting that it should just work (minus initialization?). What do you mean "initialization"? Any type that can be used in C in TLS should work in D as well (except for macOS 32bit, if anyone cares). --

Re: How you guys go about -BetterC Multithreading?

2017-11-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-11-09 13:19, Petar Kirov [ZombineDev] wrote: Though you need to be extra careful not to use thread-local storage I think TLS should work, it's the OS that handles TLS, not druntime. -- /Jacob Carlborg

Re: "version" private word

2017-10-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-31 16:36, Dr. Assembly wrote: thanks. I just find it werid, maybe because I came from C/C++ background, where it means only integer types. So enum s = "foo"; is really werid. But I'll get used to it. Think of it more like #define in C/C++ than "const". The above defines a

Re: "version" private word

2017-10-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-31 14:46, Igor Shirkalin wrote: Hello! We need some conditional compilation using 'version'. Say we have some code to be compiled for X86 and X86_64. How can we do that using predefined (or other) versions? Examples:    version(X86 || X86_64) // failed    version(X86) ||

Re: How to find the content of core.sys.* ?

2017-10-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-28 13:48, user1234 wrote: It's not documented because everything is already well documented either at microsoft, posix reference, c reference etc. It would be copy and paste monkey work to do that. I would be nice to have empty Ddoc comments so the symbols show up in the

Re: How to modify process environment variables

2017-10-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-17 06:51, Ky-Anh Huynh wrote: Hi, Is it possible to change the current process's environment variables? I have looked at `std/process.d` source code, and there is only a private method `createEnv` used when new (sub)process is created. In C `putEnv` the answer is positive:

Re: Tango + D2 + Mac

2017-10-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-17 04:52, Fat_Umpalumpa wrote: I am having a lot of trouble trying to install Tango to use with D2 on my mac os Sierra. Is this even possible? Thanks! It can be used as a Dub package [1]. But it will not compile with the latest version of DMD. 2.071.0 is the latest version it

Re: What's the best way to programmatically detect the most recent release of DMD and others?

2017-10-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-16 20:32, Andrew Edwards wrote: You're a godsend. Thank you very much. :D -- /Jacob Carlborg

Re: What's the best way to programmatically detect the most recent release of DMD and others?

2017-10-16 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-16 17:13, Andrew Edwards wrote: The best way I know to determine the latest DMD release is http://ftp.digitalmars.com/LATEST. I'm not aware that such a file exists for LDC and GDC so I'm currently doing: string latest(string url) {     return executeShell("git ls-remote --tags " ~

Re: Does D have an equivalent to C#'s String.IsNullOrWhiteSpace?

2017-10-13 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-12 21:42, Daniel Kozak wrote: Wow, C# is really wierd. They have method IsNullOrEmpty (OK why not), but they have IsNullOrWhiteSpace OK little akward but still OK until you realized it is more like IsNullOrEmptyOrWhiteSpace :D It's pretty neat functionality. Ruby has it (or rather

Re: Dustmite always reduced to empty set after two iterations

2017-10-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-11 22:36, Nordlöw wrote: My first idea is to make stderr "core dumped" the invariant. Therefore my first try becomes to redirect stderr to stdout (in bash) and grep for the pattern 'core dumped' as follows IIRC, segmentation faults are printed by the shell and not the

Re: Add a precompiled c++ obj file to dub

2017-10-09 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-08 04:58, Fra Mecca wrote: At the end I added them as linking options (lflags) but it is kinda odd that it works given that everything is supplied to dmd as -Lobj.o Everything passed to DMD with the -L flag is passed to the linker, basically as is. So if the linker accepts object

Re: When to opCall instead of opIndex and opSlice?

2017-10-02 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-10-02 17:57, Nordlöw wrote: Is implementing opCall(size_t) for structures such as array containers that already define opIndex and opSlice deprecated? I can't find any documentation on the subject on when opCall should be defined to enable foreach (isIterable). opCall is not related

Re: core.stdc.time

2017-09-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-09-30 08:56, Tony wrote: The documentation says: -- This module contains bindings to selected types and functions from the standard C header . Note that this is not automatically generated, and may omit some types/functions from the

Re: Cannot make LDC use LTO when called via DUB

2017-09-25 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-09-25 09:47, Sebastiaan Koppe wrote: I didn't know dflags-* was a thing, and I can't find it in docs either. That's how it works in the JSON package description file. -- /Jacob Carlborg

Re: extern(C) and slices

2017-09-12 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-09-12 01:03, Nordlöw wrote: If I have a function like `extern(C) void f(void *x, size_t x_sz)` can I instead declare it as `extern(C) void f(void[] x)` ? It looks like the length needs to come first [1]. I think it would be technically possible if you flipped the parameters but

Re: Output range with custom string type

2017-08-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-29 19:35, Moritz Maxeiner wrote: void put(T t) {     if (!store)     {     // Allocate only once for "small" vectors     store = alloc.makeArray!T(8);     if (!store) onOutOfMemoryError();     }     else if (length ==

Re: hijack dub test

2017-08-31 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-31 08:41, Nicholas Wilson wrote: My project is a library, but I also need to test it and unit tests won't cut it (external hardware). How do you set up the dub.json to build the library normally but when it is invoked with `dub test` it runs a separate configuration that also

Re: Output range with custom string type

2017-08-30 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-29 19:35, Moritz Maxeiner wrote: On Tuesday, 29 August 2017 at 09:59:30 UTC, Jacob Carlborg wrote: [...] But if I keep the range internal, can't I just do the allocation inside the range and only use "formattedWrite"? Instead of using both formattedWrite and sformat and go through

Re: Output range with custom string type

2017-08-29 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-28 23:45, Moritz Maxeiner wrote: If you want the caller to be just in charge of allocation, that's what std.experimental.allocator provides. In this case, I would polish up the old "format once to get the length, allocate, format second time into allocated buffer" method used with

Output range with custom string type

2017-08-28 Thread Jacob Carlborg via Digitalmars-d-learn
I'm working on some code that sanitizes and converts values of different types to strings. I thought it would be a good idea to wrap the sanitized string in a struct to have some type safety. Ideally it should not be possible to create this type without going through the sanitizing functions.

Re: How do I create a fileWatcher with an onFileChange event using spawn?

2017-08-28 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-08-28 08:31, Nemanja Boric wrote: On Monday, 28 August 2017 at 06:27:20 UTC, Jacob Carlborg wrote: http://code.dlang.org/packages/vibe-core http://code.dlang.org/packages/libasync In addition, to avoid polling, it's possible to register yourself to the operating system so it will

<    1   2   3   4   5   6   7   >