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

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:

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

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

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.

[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: 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

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

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: 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.

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

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: 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();

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

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 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].

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

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

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

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

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."

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

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

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: 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: 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: 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: 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); }

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

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

<    1   2   3