Re: Utf8 to Utf32 cast cost

2015-06-08 Thread Anonymouse via Digitalmars-d-learn
On Monday, 8 June 2015 at 18:48:17 UTC, Daniel Kozak wrote: Yep, but I dont care, I am the one who makes transcode faster, so I am happy with results :P. P.S. I care and probably when I have some spare time I will improve to!dstring too Ah, so you are. I confused you with Kadir Erdem Demir.

Re: problem with gc?

2015-05-27 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 08:42:01 UTC, zhmt wrote: When I enable the --profle, get something like this, it doesnt give me too much help: [...] Tried callgrind and kcachegrind? If nothing else it's better at illustrating the same output, assuming you have graphviz/dot installed. Given

Re: problem with gc?

2015-05-27 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 27 May 2015 at 10:24:59 UTC, zhmt wrote: @Anonymouse Thank u very much, I have tried this: valgrind --tool=callgrind ./gamelibdtest callgrind_annotate callgrind.out.29234 Ir

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread Anonymouse via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: A extern( C ) function should be able to take it as either one. Missed this bit. Not sure about that one.

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread Anonymouse via Digitalmars-d-learn
On Monday, 6 June 2016 at 09:43:23 UTC, ParticlePeter wrote: In C NULL can be used as integer as well as null pointer. Is there a way to create such a type in D? The type should have only one value which is obviously (0/null). A extern( C ) function should be able to take it as either one.

Re: Emulate C's (polymorphic) NULL type

2016-06-06 Thread Anonymouse via Digitalmars-d-learn
On Monday, 6 June 2016 at 12:09:33 UTC, ParticlePeter wrote: I don't see the connection here, you introduced two symbols with two different types. I want one symbol which can pose as two different (constant) types. Ah, my apologies, I misunderstood the question.

Re: Is there a sorted map?

2016-03-13 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 13 March 2016 at 13:44:35 UTC, cym13 wrote: Note that implementing an (admitedly not perfect) ordered associative array yourself really isn't much work: https://github.com/cym13/miscD/blob/master/ordered_aa.d Unsigned integer comparison with -1 in the remove function, by the way.

Re: Checking if a port is listening

2016-03-19 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 20:44:12 UTC, Lucien wrote: Hello, I want to know if a port of an ip address is listening, actually, I've this : http://pastebin.com/pZhm0ujy (checking port 22/ssh) It works, but it took me ~10min to scan 30 addresses. How can reduce the expiration delay ? I

Re: size_t index=-1;

2016-03-18 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 16 March 2016 at 21:49:05 UTC, Steven Schveighoffer wrote: No, please don't. Assigning a signed value to an unsigned (and vice versa) is very useful, and there is no good reason to break this. -Steve I agree, but implicitly allowing for comparisons between the two allows for

Re: Iterating over thread local storage variables

2016-03-11 Thread Anonymouse via Digitalmars-d-learn
On Friday, 11 March 2016 at 15:21:38 UTC, maik klein wrote: static Singleton!T get() { if (!instantiated_) { synchronized(Singleton!T.classinfo){ if (!instance_){ instance_ = new Singleton!T(); }

Re: Iterating over thread local storage variables

2016-03-11 Thread Anonymouse via Digitalmars-d-learn
On Friday, 11 March 2016 at 17:33:43 UTC, sigod wrote: On Friday, 11 March 2016 at 17:03:38 UTC, Anonymouse wrote: On Friday, 11 March 2016 at 15:21:38 UTC, maik klein wrote: static Singleton!T get() { if (!instantiated_) {

Re: Using a macro for a function signature

2016-04-05 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 11:35:24 UTC, pineapple wrote: If I have a common function signature I'm using throughout my code, and I feel like there should be a way to condense it using a macro. The intuitive method isn't working, but this seems like something D would be able to do. What've I

Re: immutable array in constructor

2016-03-19 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 17 March 2016 at 09:57:37 UTC, Jeff Thompson wrote: In the following code, I explicitly declare array as immutable. But it compiles with the error shown below in the comment. The array object is declared immutable, so how can the compiler say it is a mutable object? In summary,

Re: Checking if a port is listening

2016-03-20 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 17 March 2016 at 10:41:55 UTC, Marc Schütz wrote: On Wednesday, 16 March 2016 at 22:22:15 UTC, Anonymouse wrote: import core.thread; // for .seconds Nitpick: `seconds` is defined in `core.time`; `core.thread` just reexports it. s.setOption(SocketOptionLevel.SOCKET, SNDTIMEO,

Re: Error with associative array initializer DMD32 D Compiler v2.070.0

2016-03-03 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 3 March 2016 at 10:01:47 UTC, MGW wrote: immutable long[string] aa = [ "foo": 5, "bar": 10, "baz": 2000 ]; ... Error: non-constant expression ["foo":5L, "bar":10L, "baz":2000L] I'm not sure there's a way around this except by initialising it at runtime. So you can't

Re: Possible bug in RVO?

2016-04-04 Thread Anonymouse via Digitalmars-d-learn
On Monday, 4 April 2016 at 03:55:26 UTC, Yuxuan Shui wrote: On Monday, 4 April 2016 at 03:28:01 UTC, Yuxuan Shui wrote: auto clobber(ref Set x, ref Set o) { Set ret; ret.aa = x.aa; assert(x.aa.length > 0); // <-- boom return ret; } No idea myself but that's

Re: Why I can't pass to datetime.benchmark function with parameters?

2016-04-23 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 23 April 2016 at 15:11:13 UTC, Suliman wrote: Working: void main() { auto r = benchmark!(foo)(1); } [...] Do not working: void main() { auto r = benchmark!(foo())(1); } [...] Error: expression foo() is void and has no value Do not working: void main() { auto r =

Re: Confusion with anonymous functions and method overloads

2016-05-21 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 21 May 2016 at 14:39:59 UTC, pineapple wrote: void clean(in void delegate(in T value) func){ this.clean((in T values[]) => { foreach(value; values) func(value); }); This doesn't do what you think it does. It passes a lambda that *returns* that

Re: binary expression...

2016-05-21 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 21 May 2016 at 18:10:55 UTC, captain_fid wrote: Please forgive if asked before. My google skills seemed to fail me and didn't see any result from search. My problem is simple (though not my understanding LOL). struct D { int value; bool opEquals()(bool value) const {

Re: Ascii string literal.

2016-05-06 Thread Anonymouse via Digitalmars-d-learn
On Friday, 6 May 2016 at 20:29:35 UTC, Adam D. Ruppe wrote: On Friday, 6 May 2016 at 20:01:27 UTC, Alexandru Ermicioi wrote: Is it possible somehow to convert implicitly a string literal Not implicitly (well, unless you just use string, ascii is a strict subset of utf-8 anyway), but you

Re: Using a string generated at compile-time in a @nogc function

2016-05-01 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 1 May 2016 at 05:28:36 UTC, Mithun Hunsur wrote: Hi all, I'm working on removing the string mixins from my code, but have run into an issue: http://dpaste.dzfl.pl/ecd7eb53947e As far as I can tell, this should work; the enum should force compile-time execution (which it does, as

Re: Internal compiler erorr

2016-04-15 Thread Anonymouse via Digitalmars-d-learn
On Friday, 15 April 2016 at 16:53:27 UTC, Eric wrote: On Monday, 11 April 2016 at 00:55:44 UTC, Mike Parker wrote: I don't see this specific error in bugzilla. Unfortunately I am getting this error in a large module that has "const string" all over. So I can't come up with a simple test case.

Re: Dealing with type information loss in Parameters Fields and Return type

2016-04-17 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 17 April 2016 at 10:12:29 UTC, Nicholas Wilson wrote: So currently there is a loss of information when Parameters Fields and Return type. i.e. assuming 64 bits size_t foo(ptrdiff_t) {}; writeln(ReturnType!foo); // prints ulong Is there any way to get the types as (tuples of)

Re: Dealing with type information loss in Parameters Fields and Return type

2016-04-17 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 17 April 2016 at 10:27:10 UTC, Nicholas Wilson wrote: On Sunday, 17 April 2016 at 10:22:00 UTC, Anonymouse wrote: On Sunday, 17 April 2016 at 10:12:29 UTC, Nicholas Wilson wrote: So currently there is a loss of information when Parameters Fields and Return type. i.e. assuming 64

Re: Accessing __FILE__ and __LINE__ of caller in combination with varargs?

2016-04-17 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 16 April 2016 at 12:37:46 UTC, Simen Kjaeraas wrote: On Saturday, 16 April 2016 at 00:03:59 UTC, Jonathan M Davis wrote: On Friday, April 15, 2016 20:52:42 WebFreak001 via Digitalmars-d-learn wrote: void assertf(string file = __FILE__, size_t line = __LINE__, Args...)(lazy bool

Re: Enabling Only Top-Level Unittests

2016-04-21 Thread Anonymouse via Digitalmars-d-learn
On Monday, 21 March 2016 at 10:29:36 UTC, Nordlöw wrote: I want to enable unittests only at the top-level of a module compilation. If I have a module top.d that imports dep1.d dep2.d ... which all contain unittests, how do I compile top.d with only the unittests for top.d

Re: alias to function literal, call without () not possible

2016-08-03 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 3 August 2016 at 17:16:10 UTC, Andre Pany wrote: Hi, I just stumbled over this behavior. I am not sure whether the behavior is correct or not. [...] alias foo = () => new Object; ...is an alias for a delegate/function returning an Object. It is analogous to alias foo = () {

Re: how to mark an extern function @nogc?

2016-07-11 Thread Anonymouse via Digitalmars-d-learn
On Monday, 11 July 2016 at 15:54:02 UTC, Seb wrote: On Monday, 11 July 2016 at 01:59:51 UTC, Adam Sansier wrote: On Monday, 11 July 2016 at 01:58:23 UTC, Adam Sansier wrote: I'm using some win functions that don't use the gc and are not marked, specifically CLSIDFromString that I imported

Re: aspects on methods?

2016-07-13 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 12 July 2016 at 11:26:20 UTC, jj75607 wrote: I want to use aspect-like annotations to transform [...] Two methods spring to mind but both create new types. You can either write a function that iterates through the members of your class, generating a string mixin that selectively

Re: alias and UFCS

2017-01-24 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 24 January 2017 at 13:11:41 UTC, ixid wrote: This code: T tFunc(alias F, T)(T n) { n.F; return n; } Produces this error: Error: no property 'F' for type 'int[]' (or whatever type I use). I believe UFCS is supposed to only work with top-level functions. I don't

Re: Static CT Factory

2016-08-18 Thread Anonymouse via Digitalmars-d-learn
On Friday, 19 August 2016 at 01:10:42 UTC, Engine Machine wrote: I have a template that is suppose to create a type based on a template parameter static if (T == "int") { auto x = New!int(); } else static if (T == "double") { auto x = New!double(); } x = 1.234; This is just an

Re: Getting a String Literal From an Aliased Template Mixin Parameter

2016-09-14 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 15 September 2016 at 00:15:42 UTC, jsako wrote: I was making a quick mocking infrastructure for internal mocks so I wouldn't have to pass in objects to constructors all the time and came up with this: [...] This works great as long as there is only one mock object. I thought

Re: What exactly does the compiler switch -betterC do?

2016-09-20 Thread Anonymouse via Digitalmars-d-learn
On Monday, 20 June 2016 at 06:35:32 UTC, Jacob Carlborg wrote: On 2016-06-19 21:53, Gary Willoughby wrote: When compiling, what exactly does the -betterC flag do? The command help says "omit generating some runtime information and helper functions" but what does this really mean? Is there any

Re: Correct way to create singleton?

2016-11-10 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 10 November 2016 at 17:17:51 UTC, Konstantin Kutsevalov wrote: Hi, what is a correct (and simple) way to create an singleton? https://wiki.dlang.org/Low-Lock_Singleton_Pattern

Re: Dustmite can't handle my memory segfault

2016-10-22 Thread Anonymouse via Digitalmars-d-learn
On Friday, 21 October 2016 at 10:13:23 UTC, Nordlöw wrote: #!/usr/bin/env python3 import sys import pty stat = pty.spawn(sys.argv[1:]) if stat == 256: exit(42)# remap to 42 else: exit(stat) Assuming you want to remap 134 to 0 (success): #!/bin/bash cmd="$1"

Re: Separate IP parts

2016-12-09 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 10 December 2016 at 03:51:34 UTC, brocolis wrote: How do I separate IP parts with dlang? I found this very cool trick, with C++: http://stackoverflow.com/a/5328190 std::string ip ="192.168.1.54"; std::stringstream s(ip); int a,b,c,d; //to store the 4 ints char ch; //to

Re: Impressed with Appender - Is there design/implementation description?

2016-12-06 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 6 December 2016 at 10:52:44 UTC, thedeemon wrote: It's rather simple, just take a look at its source code in std.array. It's an ordinary linear array partially filled with your data. [...] 2. Up until 4 KB it reallocates when growing, but after 4 KB the array lives in a larger

Re: String characters not extended

2017-01-03 Thread Anonymouse via Digitalmars-d-learn
On Monday, 2 January 2017 at 21:07:37 UTC, Ignacious wrote: [...] Assuming Windows: version(Windows) shared static this() { import core.sys.windows.windows; SetConsoleCP(65001); SetConsoleOutputCP(65001); }

Standard output does not get flushed in cygwin?

2017-01-01 Thread Anonymouse via Digitalmars-d-learn
Try this in a cygwin terminal: import std.stdio; import core.thread; void main() { foreach (i; 0..10) { writeln(i); Thread.sleep(1.seconds); } } This program will not output i, wait a second and then output i+1, etc. It will be silent for ten seconds and then spam

Re: Standard output does not get flushed in cygwin?

2017-01-02 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 1 January 2017 at 13:04:30 UTC, rikki cattermole wrote: What is your terminal emulator? Poderosa has a known problem for this. Where as ConEmu (which I have since moved over to) works fine. Fun fact, I had a similar file to the yours in /tmp/test.d :) The default mintty. I tried

Re: String characters not extended

2017-01-04 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 3 January 2017 at 19:40:20 UTC, Daniel Kozák wrote: Why do not use CP_UTF8 constant instead of 65001? It is safer, easier to read and understand I have no reason to back it up with. I'm literally just copy/pasting what others have suggested I use.

Re: is char[] faster than string?

2017-04-07 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 5 April 2017 at 22:05:07 UTC, H. S. Teoh wrote: If you are doing lots of concatenation and produce a single big string at the end, take a look at std.array.appender. Though if you're concerned about performance, you really should run a profiler. Last I heard, appender may not be

Re: It makes me sick!

2017-07-28 Thread Anonymouse via Digitalmars-d-learn
On Friday, 28 July 2017 at 05:14:16 UTC, FoxyBrown wrote: If dmd breaks in strange and unpredictable ways IT IS DMD's fault! No exceptions, no matter what you believe, what you say, what lawyer you pay to create a law for you to make you think you are legally correct! You can make any claim

Re: Compile Time versus Run Time

2017-07-31 Thread Anonymouse via Digitalmars-d-learn
On Monday, 31 July 2017 at 15:46:47 UTC, inevzxui wrote: On Monday, 31 July 2017 at 15:43:21 UTC, Martin Tschierschke wrote: As a rookie in D programming I try to understand the power of templated functions with compile time parameters. With DMD 2.074 a compile time format (auto output =

Re: opEquals nothrow

2017-07-20 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 20 July 2017 at 15:10:24 UTC, Aldo wrote: extern(C) nothrow { void onMouseClick(GLFWwindow* window, int button, int action, int d) { try { // my code } catch { } } } Tangent but an easy way of nothrowing:

Re: It makes me sick!

2017-07-28 Thread Anonymouse via Digitalmars-d-learn
On Friday, 28 July 2017 at 21:23:22 UTC, FoxyBrown wrote: So, the program, if it is updated shouldn't use the mp3's then. Why the hell is the program that you say was upgraded to use the ogg still searching and using mp3's? You are trying to make up reasons why it shouldn't work... at least

Re: Efficiently streaming data to associative array

2017-08-08 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven Schveighoffer wrote: I wouldn't use formattedRead, as I think this is going to allocate temporaries for a and b. What would you suggest to use in its stead? My use-case is similar to the OP's in that I have a string of tokens that I want

Re: Estimating free system resource at runtime

2017-08-20 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 20 August 2017 at 15:49:09 UTC, seany wrote: However, i cant find anything on google to tell me how to estimate system resource using D. for C++ and windowes, i could find some API-s Can e do this in D? You can just use those C APIs. I believe the GC does, unless I'm reading it

Re: No tempFile() in std.file

2017-05-16 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 16 May 2017 at 05:09:12 UTC, Era Scarecrow wrote: On Monday, 15 May 2017 at 22:38:15 UTC, Jonathan M Davis wrote: Personally, I think that it would be very much worth making hello world larger, since hello world really doesn't matter, but because there are plenty of folks checking

Re: Zero-cost version-dependent function call at -O0.

2017-06-25 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 25 June 2017 at 15:58:48 UTC, Johan Engelen wrote: How would you solve this problem: do an optional function call depending on some version(X). If version(X) is not defined, there should be no call and no extra code at -O0. ``` { ... foo(); // either compiles to a function

Searching strings with indexOf vs countUntil

2017-05-25 Thread Anonymouse via Digitalmars-d-learn
I was profiling my program with callgrind and saw that a lot of time was spent in countUntil (std.algorithm.searching) on strings. I had chosen to use it instead of indexOf (std.string), with the plain assumption that countUntil wouldn't decode, while indexOf would. Comparing microbenchmarks

Re: Searching strings with indexOf vs countUntil

2017-05-25 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 25 May 2017 at 11:55:21 UTC, Kagamin wrote: I would guess indexOf returns a value suitable for indexing, therefore it counts code units, while countUntil counts range elements - code points in case of a string. Also number of code points is not suitable for indexing an utf8

Avast virus warning?

2017-06-05 Thread Anonymouse via Digitalmars-d-learn
I just sent a pre-compiled .exe of my project to a friend, and his Avast anti-virus promptly quarantined it and sent it off for analysis. I tried sending him a Hello World[1] with the same results. Is this something common for d programs? Anything I can do to work around it from my end?

Re: Avast virus warning?

2017-06-05 Thread Anonymouse via Digitalmars-d-learn
On Monday, 5 June 2017 at 16:40:25 UTC, rikki cattermole wrote: It would be nice to get in touch with their engineers to find out what is really going on. Tried an email and hit a paywall. :c "We’re sorry, but we can’t seem to find a record of your license in our system."

Re: when I run dub within git bash, dub prompts are not displayed. For instance...

2017-06-10 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 10 June 2017 at 16:11:31 UTC, WhatMeWorry wrote: kheaser@IT-ASST-SB MINGW64 /c/Users/kheaser/Git/Delivery/projects (master) $ dub init 00_01_print_ogl_ver ... All this white space here is me just pressing the Enter key ... to get the default values. If the problem is that the

Deprecation: foo.bar is not visible from module traits

2017-05-07 Thread Anonymouse via Digitalmars-d-learn
I'm reworking my code to use UDAs, and I'm running into a wall of text of deprecation warnings when compiling. import std.traits; private: struct SomeUDA {} @SomeUDA void foo() {} @SomeUDA void bar() {} @SomeUDA void etc() {} public: void main() { mixin("static import thisModule = "

Re: Remove all blank lines from a file

2017-08-31 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 31 August 2017 at 14:44:07 UTC, vino wrote: Hi All, Can some provide me a example of how to remove all blank lines from a file. From, Vino.B Super verbose, but: import std.stdio; import std.file; import std.algorithm.iteration; enum inFilename = "in.txt"; enum outFilename

Re: dmd/ldc failed with exit code -11

2017-11-22 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 19:22:47 UTC, Anonymouse wrote: Compiling a debug dmd and running the build command in gdb, it seems to be a stack overflow at ddmd/dtemplate.d:6241, TemplateInstance::needsCodegen(). After a lot of trial and error I managed to find /a/ line which lets it

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

2017-12-16 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote: C# has a quite nice way to store metadata about a property by a feature called atributes[1]. For example, I can write something like this: class A { [TextSize(256)] string Name { get; set; } } So using runtime/reflection I

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-17 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 17 December 2017 at 08:10:06 UTC, codephantom wrote: On Sunday, 17 December 2017 at 00:10:27 UTC, Anonymouse wrote: If you return inside a scopeguard though, the exception (or error!) is swallowed. https://run.dlang.io/is/GEtQ6D The scope guard will not 'swallow' it, if you use

Re: Scope failure is not preventing application crush in case of uncaught exceptions

2017-12-16 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 16 December 2017 at 21:56:49 UTC, Jonathan M Davis wrote: The only way to catch an exception is with a catch block, and if you do If you return inside a scopeguard though, the exception (or error!) is swallowed. https://run.dlang.io/is/GEtQ6D void main() { foo();

dmd/ldc failed with exit code -11

2017-11-20 Thread Anonymouse via Digitalmars-d-learn
I have a large named enum (currently 645 members) of IRC event types. It's big by neccessity[1]. I'm using dub, and both dmd and ldc successfully build it in test and debug modes, but choke and die on plain and release. I bisected it down to when I did a big addition to the enum to encompass

Re: dmd/ldc failed with exit code -11

2017-11-21 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 00:36:00 UTC, rikki cattermole wrote: Source code please. https://github.com/zorael/kameloso.git I'm not proud of some of the early bits there (main.d) so don't judge me, please. I'm learning as I go. The offending bits are IRCEvent.Type in ircstructs.d[1].

Re: dmd/ldc failed with exit code -11

2017-11-21 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 10:12:11 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 21 November 2017 at 10:10:59 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 21 November 2017 at 00:15:04 UTC, Anonymouse wrote: I have a large named enum (currently 645 members) of IRC event types. It's

Re: dmd/ldc failed with exit code -11

2017-11-21 Thread Anonymouse via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 13:28:44 UTC, Anonymouse wrote: Looking at the dmd command dub issues and testing them myself I notice that if I reorder the arguments it builds. $ dmd -d -oftest source/arsd/*.d source/kameloso/plugins/*.d source/kameloso/*.d zsh: segmentation fault (core

How do I use Socket.select?

2017-11-12 Thread Anonymouse via Digitalmars-d-learn
I've been using blocking Sockets with timeouts for a while now, but wherever I look the word is "do consider using a non-blocking socket". Even the docs for std.socket.setOption; In a typical application, you might also want to consider using a non-blocking socket instead of setting a timeout

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

2018-06-22 Thread Anonymouse via Digitalmars-d-learn
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 claims that it's excluding main.d

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

2018-06-23 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 23 June 2018 at 08:10:08 UTC, Jacob Carlborg wrote: On 2018-06-22 21:41, Anonymouse wrote: What can I do? It might be this issue [1], should be fixed in the latest version of Dub. [1] https://github.com/dlang/dub/issues/1454 Thanks.

template alias that includes a parameter

2018-06-30 Thread Anonymouse via Digitalmars-d-learn
I have a template that I want to provide easy aliases for, where the aliases includes (partially applies?) a template parameter. void fooImpl(char token, T)(const T line) { // ... } alias quoteFoo(T) = fooImpl!('"', T); alias singlequoteFoo(T) = fooImpl!('\'', T); void main() {

Error: out of memory

2018-01-10 Thread Anonymouse via Digitalmars-d-learn
I've been building and testing my project on linux, juggling the ~5GB+ RAM needed to actually compile, but it's been working. I want to test it on a Windows 10 PC now but compilation with dmd (2.078.1) fails, both with --arch x86 and x86_64. LDC works, but it easily takes twice the time to

Re: Error: out of memory

2018-01-10 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 10 January 2018 at 19:21:21 UTC, Adam D. Ruppe wrote: On Wednesday, 10 January 2018 at 19:15:00 UTC, Anonymouse wrote: I want to test it on a Windows 10 PC now but compilation with dmd (2.078.1) fails, both with --arch x86 and x86_64. LDC works, but it easily takes twice the time

invalid or corrupt file: duplicate COMDAT / Previous Definition Different

2018-01-10 Thread Anonymouse via Digitalmars-d-learn
I haven't been testing my project on Windows for a while, and on top of having issues with out of memory errors when unittesting I see I can't build it normally either. dmd is 2.078.0. $ dub build -c cygwin -a x86_64 Performing "debug" build using dmd for x86_64. kameloso

Re: Error: out of memory

2018-01-10 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 10 January 2018 at 19:15:00 UTC, Anonymouse wrote: I've been building and testing my project on linux, juggling the ~5GB+ RAM needed to actually compile, but it's been working. I want to test it on a Windows 10 PC now but compilation with dmd (2.078.1) That's naturally

Re: invalid or corrupt file: duplicate COMDAT / Previous Definition Different

2018-01-10 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 10 January 2018 at 20:19:50 UTC, Benjamin Thaut wrote: Am 10.01.2018 um 20:32 schrieb Anonymouse: I don't have a reduced testcase yet. I figured I'd ask if it's something known before making the effort. Are you by any chance mixing debug and release builds? Or are the

Re: invalid or corrupt file: duplicate COMDAT / Previous Definition Different

2018-01-12 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 10 January 2018 at 20:53:24 UTC, Anonymouse wrote: None of the (version specifiers in the) build configurations I have touch upon the part of the fairly innocent code mentioned in the error message, if I'm reading it right.

Re: getSymbolsByUDA does not take private symbols under consideration. Should I file a bug?

2018-02-16 Thread Anonymouse via Digitalmars-d-learn
On Friday, 16 February 2018 at 09:26:47 UTC, Piotr Mitana wrote: Hello, The code below: import std.traits; enum Attr; class MyClass { private @Attr int a; static assert(getSymbolsByUDA!(typeof(this), MyClass).length == 1); } does not compile as

Re: Version Cygwin

2017-12-22 Thread Anonymouse via Digitalmars-d-learn
On Friday, 22 December 2017 at 03:24:15 UTC, rikki cattermole wrote: You are not using a Cygwin build. It doesn't matter who calls a process, it doesn't change the version's by itself. As far as I know, nobody supports Cygwin like this. I see, thank you.

Version Cygwin

2017-12-21 Thread Anonymouse via Digitalmars-d-learn
Cygwin is a reserved version[1], alongside Windows and linux and the like. However it doesn't seem to be automatically recognised. import std.stdio; void main() { version(Cygwin) writeln("Cygwin"); } Compiled from a Cygwin prompt this prints nothing. So I thought to add versions: [

Re: It's possible to declare a variable inside a static foreach()?

2017-12-21 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 21 December 2017 at 16:25:00 UTC, Marc wrote: For example, I'd like to declare a variable inside a static foreach like in below code, just for better organization, otherwise, I have to use the value directly instead of the variable. If the value is used more than once, it might be

Re: Find out druntime/import and phobos folder on Linux

2018-07-14 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 14 July 2018 at 17:19:20 UTC, Andre Pany wrote: Is there a way to find out both paths based on the dmd executable folder? What I found out so far, these paths are not always correct: /usr/include/dmd/druntime/import /usr/include/dmd/phobos Arch Linux and derivatives keep them

-allinst and linker errors

2018-07-25 Thread Anonymouse via Digitalmars-d-learn
I'm trying to build my project with -allinst, after reading the comments of issue 18026[1]. Manjaro/Arch 64-bit, dmd 2.081.1 and ldc 1.0.0. I get a wall of text with linker errors, both with dmd and ldc. Demangled excerpt: characterencodings.o: In function `pure nothrow @nogc @safe void

Re: dustmite watch shell script (.test vs .lookahead.*)

2018-04-07 Thread Anonymouse via Digitalmars-d-learn
On Friday, 6 April 2018 at 15:42:04 UTC, Vladimir Panteleev wrote: On Friday, 6 April 2018 at 15:35:59 UTC, Anonymouse wrote: The dustmite wiki[0] lists the following example script for use to monitor the reduction progress: Here's a more complete version that also works with -j:

dustmite watch shell script (.test vs .lookahead.*)

2018-04-06 Thread Anonymouse via Digitalmars-d-learn
The dustmite wiki[0] lists the following example script for use to monitor the reduction progress: #!/bin/sh watch -cn 0.1 "zsh -c 'ls -al $1.reduced/**/*.d ; colordiff -ru $1.reduced $1.test'" This repeatedly compares the $1.reduced directory with a $1.test directory. The dustmite run

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

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: Template/mixin ideas?

2018-10-05 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 11:01:53 UTC, Chris Katko wrote: I've got this simple task but I'm trying to perfect it as best I can to learn something in the process. I have Linux terminal ASCII codes for coloring terminal output. string red(string) { /* ... */ } "Hello world".red =>

Reverse JSON toPrettyString

2018-12-17 Thread Anonymouse via Digitalmars-d-learn
I have a JSON string[][string] associative array object that I want to take the .toPrettyString value of. However, it sorts the output alphabetically. string[][string] aa = [ "abc" : [], "def" : [], "ghi" : [] ]; auto asJSON = JSONValue(aa); writeln(asJSON.toPrettyString); Output: {

ddox and exempting dependencies

2018-12-05 Thread Anonymouse via Digitalmars-d-learn
As far as I understand you use dub.json "-ddoxFilterArgs": [ "--ex", "pattern" ] to make ddox exclude files from the documentation it generates. However, it still parses, warns and errors out on dependencies, even if they're set up to be exempted. 1. $ dub init [...] Add dependency (leave

Non-blocking reads of a fifo (named pipe)?

2018-12-03 Thread Anonymouse via Digitalmars-d-learn
I have a fifo that I want to read lines from, but everything is blocking. execute([ "mkfifo", filename ]); File fifo = File(filename, "r"); // blocks already immutable input = fifo.readln(); // blocks foreach (line; fifo.byLineCopy) { /* blocks */ } How can I go about doing this to get

Re: ddox and exempting dependencies

2018-12-05 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 5 December 2018 at 16:56:12 UTC, Andre Pany wrote: The compiler (DMD) is triggered to generate a JSON file docs.json which contains technical information used by ddox in a later step. The error message you see is thrown by dmd. At this point of time, ddoxFilterArgs isn't

Re: How to get all modules in a package at CT?

2018-11-24 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 24 November 2018 at 08:44:19 UTC, Domain wrote: I have a package named command, and many modules inside it, such as command.build, command.pack, command.help... I want to get all these modules at compile time so that I know what command is available. If you just want static if

Re: Generating API documention

2019-01-10 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 10 January 2019 at 08:50:27 UTC, Anonymouse wrote: Then just dub build -ddox Naturally dub build -b ddox.

Re: Generating API documention

2019-01-10 Thread Anonymouse via Digitalmars-d-learn
On Thursday, 10 January 2019 at 07:04:52 UTC, George wrote: What do people use to generate nice looking and simple html documentation for their projects? I would be glad (and if possible), someone could share some actual instructions rather than just tell me ddoc. For example I have seen the

Variadic template with template arguments in pairs

2018-09-12 Thread Anonymouse via Digitalmars-d-learn
I'm trying to create a variadic template function that takes pairs of arguments. Sort of like getopt, I want to pass any number of pairs of a string and some pointer. Or any size chunk larger than one. Something like the following, assuming the existence of a hypothetical template pairwise:

Getting started with separate compilation

2018-09-15 Thread Anonymouse via Digitalmars-d-learn
My project [1] has enough language coverage to expose two issues that break compilation. 1. Stack overflow in ddmd/dtemplate.d:6241, TemplateInstance::needsCodegen(); https://issues.dlang.org/show_bug.cgi?id=18026 2. -allinst gives undefined reference linker errors;

Re: Variadic template with template arguments in pairs

2018-09-15 Thread Anonymouse via Digitalmars-d-learn
On Wednesday, 12 September 2018 at 21:33:17 UTC, Paul Backus wrote: Another alternative is to write the function recursively: void doByPair(T, Rest...)(string desc, T* valuePtr, Rest rest) { writefln("%s %s: %s", T.stringof, desc, *valuePtr); if (rest.length) doByPair(rest); } Rest...

Re: Trying to extract string from curl redirected URL

2019-02-10 Thread Anonymouse via Digitalmars-d-learn
On Sunday, 10 February 2019 at 14:12:02 UTC, Josh wrote: Is there something I'm missing? It it possible to access the private handle? Is there a better way to do what I'm trying to achieve? Assuming I'm understanding your question (you want to get the path of a URL after redirects), if

Re: [dub] Passing --DRT-gcopt to dmd

2019-05-31 Thread Anonymouse via Digitalmars-d-learn
On Friday, 31 May 2019 at 10:47:20 UTC, Mike Parker wrote: On Friday, 31 May 2019 at 10:27:44 UTC, Anonymouse wrote: What is the correct way? --DRT flags are for run time, not compile time. They're intended to be passed to your executable and not the compiler. From the docs [1]: "By

[dub] Passing --DRT-gcopt to dmd

2019-05-31 Thread Anonymouse via Digitalmars-d-learn
I'm trying to tweak the GC when compiling with dub, starting with something easy like profile:1. $ grep dflags dub.json "dflags": [ "-lowmem", "--DRT-gcopt=profile:1" ], $ dub test Doesn't work, doesn't give any extra output. Entering bogus flags like --DRT-gcopt=banana:1 doesn't evoke

Re: [dub] Passing --DRT-gcopt to dmd

2019-05-31 Thread Anonymouse via Digitalmars-d-learn
On Friday, 31 May 2019 at 13:50:57 UTC, Andre Pany wrote: You can specify the parameters also in code. See example here https://dlang.org/changelog/2.085.0.html#gc_cleanup I need it to apply to dmd though, I'm exceeding memory limits when compiling. Once done the program doesn't need a whole

  1   2   >