question

2023-12-13 Thread fred via Digitalmars-d-learn
import core.thread; import std.concurrency; import std.stdio : w = writeln; void w2(shared(bool) *done) { while (*done == false) { Thread.sleep(100.msecs); w("print done? ", *done); } } void s2() { shared(bool) i

inout question

2018-02-11 Thread Norm via Digitalmars-d-learn
Hi, I'm new to D so can someone explain to me what is happening here? void func(const char* s, char** e) { import core.stdc.stdlib; auto result = strtod(s, e); } Error: function core.stdc.stdlib.strtod (scope inout(char)* nptr, scope inout(char)** endptr) is not callable using argumen

signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the sign of an integer? Thanks in advance

htod question

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
I tried using htod but got errors as it could not handle the std C header files (Visual C++). How do people work around this? Thanks and Regards Dibyendu

std.socket question

2016-02-03 Thread sanjayss via Digitalmars-d-learn
Are the functions lastSocketError() and wouldHaveBlocked() from std.socket thread-safe? i.e. can they be reliably used to see the status of the last socket call when sockets are being read/written in multiple threads?

Assert question

2016-07-26 Thread DLearner via Digitalmars-d-learn
Suppose a program contains several points that control should not get to. So each such point is blocked by assert(0). What is the recommended way of identifying which assert has been triggered? Is one allowed anything like 'assert(0,"Crashed at point A");', where the message goes to stderr?

GC question

2017-01-31 Thread osa1 via Digitalmars-d-learn
Hi all, I was looking at D as the next language to use in my hobby projects, but the "conservative GC" part in the language spec (http://dlang.org/spec/garbage.html) looks a bit concerning. I'm wondering what are the implications of the fact that current GC is a Boehm-style conservative GC ra

purity question

2017-05-28 Thread Brad Roberts via Digitalmars-d-learn
Is there a mechanism for declaring something pure when it's built from parts which individually aren't? string foo(string s) { // do something arbitrarily complex with s that doesn't touch globals or change global state except possibly state of the heap or gc return s; }

Template Question

2017-11-19 Thread Jiyan via Digitalmars-d-learn
Hello, i wanted to ask why this isnt working: struct Text(T : char) { size_t _len; T* _ptr; } Thanks :)

'typeof' question

2023-11-28 Thread DLearner via Digitalmars-d-learn
Trying to manipulate 'typeof' return strings, preferably at compile-time. e.g. to produce struct B below (intended to have an A sub-struct), from A_Ptr alone. ``` struct A { int AFld1; } A* A_Ptr; struct B { int BFld2; typeof(A_Ptr)[0..($-1)] ASUB; // Idea is ASUB of type A, from A_

Re: question

2023-12-13 Thread Basile B. via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 12:49:14 UTC, fred wrote: [...] a bug ? thanks anyway Try to define the flag as static ```d static shared(bool) isDone = false; ``` I dont know if that should be a compiler error to have local shared (I tend to think yes as locals are specific to a frame, i

Re: question

2023-12-13 Thread Adam D Ruppe via Digitalmars-d-learn
On Wednesday, 13 December 2023 at 12:49:14 UTC, fred wrote: a bug ? It helps if you explain what you're talking about so we don't have to guess. I tried the code on my computer and it worked fine. But then figuring, you must be saying something doesn't work right, I tried it on another com

Quick question

2021-01-29 Thread Ruby The Roobster via Digitalmars-d-learn
I have question here. Is there a difference between .sizeof and .length(of a char[])? For example, let's say you have the following array: char[2][] members. Is it possible for members[0].sizeof == members[1].sizeof but members[0].length != members[1].length? Thanks in advance.

@safe question

2022-01-09 Thread forkit via Digitalmars-d-learn
Do not understand why one line is not considered @safe, but the other is. // module test; import std; @safe void main() { immutable string[] strings = ["one", "one", "two"]; immutable(string)*[] pointers = null; foreach(size_t i, ref str; strings) { if(str == "on

-debug question

2022-01-20 Thread forkit via Digitalmars-d-learn
I have a line of code, that I do NOT want executed when -debug is passed in. enforce(!exists(fname), "Oop! That file already exists!"); Is this even possible? (with using -version ..)

map question

2022-01-22 Thread forkit via Digitalmars-d-learn
trying to make sense of the below: // --- module test; import std; void main() { auto rnd = Random(unpredictableSeed); int howManyTimes = 5; // ok - using 'e =>' makes sense writeln(howManyTimes.iota.map!(e => rnd.dice(0.6, 1.4)).format!"%(%s,%)"); // ok - though using

Linkage question

2022-01-24 Thread frame via Digitalmars-d-learn
If I declare a function as extern(C) inside a DLL, I have also to cast the function pointer as extern(C) or it fails calling, eg. ```d // --- my.dll export extern (C) void log(int mode, string a, string b, string c) { /* stuff */ } // --- main.d alias T = extern (C) void function(int, strin

betterC question

2020-11-18 Thread Dibyendu Majumdar via Digitalmars-d-learn
I have simple test program: import core.stdc.stdio : printf; void test() { int* a; printf("a == null %d\n", a == null); } int function() fp = test; extern (C) void main() { fp(); } Why do I get: \d\dmd-2.092.1\windows\bin64\dmd.exe -betterC tests.d tests.d(5): Error: printf canno

question -property

2012-01-04 Thread sclytrack
.property = "test"; .method = "test"; .method("test"); What does -property exactly do? If you had like a dynamic where you don't know if it's member is a property or a method. You would choose method right? scratch the invalid ones below. --- .property="test"; .pr

Range question

2012-02-17 Thread H. S. Teoh
I'm trying to write a range-based template that iterates over a range and returns one of its elements according to some criterion: ElementType!R choose(R, E)(R range) if (isInputRange!R) { ElementType!R e; while (!range.empty) {

Regex question

2012-03-28 Thread James Blewitt
I'm having a problem with regexes. The following code gives a compilation error. If I comment out the regex outside of main and comment in the regex inside of main then it does compile. I'm using DMD v2.058 Any ideas what is going on? -- import std.regex; Regex!(char) testRegex = rege

CTFE question

2012-08-28 Thread Danny Arends
I have the following code: import std.stdio; import std.metastrings; pure int[] testCTFE(){ int[] r; pragma(msg, "Testing CTFE"); foreach(i; 0 .. 360){ r ~= i; pragma(msg, Format!("Loop: %d",i)); } pragma(msg, "Done CTFE test"); return r;

Threading Question

2012-10-23 Thread Peter Sommerfeld
y understanding daemons will survive the termination of the main-thread and be killed by a signal (KILL, SIGTERM etc) or finish itself. I think that is the case here too. Is that true ? Another question: I cannot find a reference how D deals with OS SIGNALS, especially about differences betwe

cast question

2012-10-31 Thread Dan
Why do the commented out calls to goo fail? Thanks Dan - import std.stdio; struct S { } void goo(const ref S s) { writeln(s); } struct T { S s; void foo(const ref T other) const { goo(s); // Error: function fdsaf.goo (ref const(S) s) is //

Style question

2013-07-11 Thread Namespace
I have a style question, because a friend of mine has a similar problem currently and I have no good advice for him. Let's assume we have this classes: class MyClass { public: enum A { Foo = 0, Bar = 1 } private: A _a; p

std.base64 question

2013-11-26 Thread Parke
Hi, The following does not compile, and I do not understand what I am doing wrong. import std.base64; ubyte[] s0 = ['H','e','l','l','o']; char[40] s1; void main () { Base64.encode (s0, s1); } The compile error is: [snip]/src/phobos/std/range.d(614): Error: static assert "Cannot put a im

Heap question

2011-08-13 Thread bearophile
I'd like to create an empty heap, and then add to it an arbitrary (and statically unknown) number of items, keeping the heap invariant valid all the time (this means the heap invariant is valid after each item is added to the heap, so I am free to pop items in any moment). Do you know if this is

newbie question

2011-09-19 Thread %u
does D compatibility with C restrict D from evolving ? and if D drop this will that prevent complexity?

array question

2013-12-08 Thread seany
consider the follwoing: import tango.io.Stdout, tango.io.Path, tango.text.Util; import std.algorithm, std.string , std.stdio, std.array, std.conv, std.regex, std.typecons; //i know al imports are not necessary for this example, just ^c^v from my actual code alias string[] surSegments void

enum question

2014-03-18 Thread Eric
I would like to use enums with elements that are either a struct type or a class type. However, using struct type seems inefficient because structs are pass by value. Apparently you can't pass an enum as a reference, so eliminating the pass by value for enums does not seem possible. I have

DDOX question

2015-01-08 Thread Vadim Lopatin via Digitalmars-d-learn
Hello! I'm trying to generate documentation for a library. I like result of DDOX generation - nice navigation by modules and classes. But I cannot figure out how to generate custom pages (e.g. from .dd .d Ddoc), and how to add links to custom pages to all generated pages, e.g. like on Vibe.d d

std.random question

2015-05-03 Thread tired_eyes via Digitalmars-d-learn
Feels pretty silly, but I can't compile this: import std.random; auto i = uniform(0, 10); DMD spits this: /usr/include/dmd/phobos/std/random.d(1188): Error: static variable initialized cannot be read at compile time /usr/include/dmd/phobos/std/random.d(1231):called from here: rndGen

rt_finalize question

2015-06-09 Thread Oleg B via Digitalmars-d-learn
Hello. In object.di rt_finalize calls for class objects in destroy func. I not found it in dmd source on github and not found in druntime sources. I think rt_finalize must call dtors for object and base classes, but I think that's not all. Or if it all has it code logic problems? void myDestr

Theory question

2009-05-21 Thread BCS
Are there any cases where the following cases both compile but are not identical? A a; B b; a = b; a.Foo(); and A a; B b; a = b; b.Foo(); The reason I ask is I'm wondering if making the type (and value) of an assignment expression the right hand side rather than the left hand side wou

std.conv question.

2009-07-15 Thread Q
Does to! (uint) recognize hexadecimal strings? Cause if i put int by = to!(int)("0x0FFF"); throws an exception saying; std.conv.ConvError: Can't convert value `x0FFF' of type const(char)[] to type int dmd 2.031;

std.conv question.

2009-07-15 Thread Q
Does to! (uint) recognize hexadecimal strings? Cause if i put int by = to!(int)("0x0FFF"); throws an exception saying; std.conv.ConvError: Can't convert value `x0FFF' of type const(char)[] to type int dmd 2.031;

std.conv question.

2009-07-15 Thread Q
Does to! (uint) recognize hexadecimal strings? Cause if i put int by = to!(int)("0x0FFF"); throws an exception saying; std.conv.ConvError: Can't convert value `x0FFF' of type const(char)[] to type int dmd 2.031;

noob question

2009-08-06 Thread llltattoolll
hi im noob here and try learn D language, i try make this example but when run have 2 problems. 1) when i show name and lastname show me in two lines and i wanna make in the same line. 2) can´t validate option si ( yes ) or no ( no ) and always show the else line. what happend? thx ---

RegExp.match question

2009-08-17 Thread Saaa
const char[] re1 = `(re)1`; const char[] re2 = `(re)2`; char[] matchWrite(RegExp re) { writefln(re.match(1),`,`,re.match(2)); return ""; } std.regexp.sub(`re1 re2`, re1~'|'~re2, &matchWrite, "g"); --- prints re, re,re // shouldn't this be `,re`?

wchar* question

2009-09-03 Thread Sam Hu
Given below code(Win32 SDK): int /*LRESULT*/ wndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch(msg) { case WM_LBUTTONDOWN: {

metaprogramming question

2010-04-18 Thread Graham Fawcett
Hi folks, I'd like to wrap a family of C functions that look like this: gboolean fooXXX(arg1, ..., argN, GError** err) Their signatures and arities vary, but they all have a GError** as their last argument. If a function returns false, then 'err' will be set to a relevant Error struct. I

variable template question

2018-01-14 Thread kdevel via Digitalmars-d-learn
vartmpl.d ``` import std.stdio : writeln; import decimal : decimal32; template F(T) { immutable T c = 3; } void foo (T) () { immutable T t = 1; } void main () { // immutable decimal32 i = 1; // Error: none of the overloads of '__ctor' are callable using a immutable object // foo!dec

Question about std.conv.parse

2018-01-30 Thread Jacky via Digitalmars-d-learn
Hello everyone.I'm a newbie on the D language.When i use the library 'std.conv' ,i met some problem. This is what I have: static import std.conv; string aaa = "123456789"; uint idx = 5; string bbb = aaa[0 .. idx]; uint work = std.conv.parse!(uint)(bbb); // this works ui

Re: inout question

2018-02-11 Thread ketmar via Digitalmars-d-learn
Norm wrote: Hi, I'm new to D so can someone explain to me what is happening here? void func(const char* s, char** e) { import core.stdc.stdlib; auto result = strtod(s, e); } Error: function core.stdc.stdlib.strtod (scope inout(char)* nptr, scope inout(char)** endptr) is not callab

Re: inout question

2018-02-12 Thread Kagamin via Digitalmars-d-learn
On Monday, 12 February 2018 at 05:33:16 UTC, Norm wrote: I thought inout was supposed to take const or non-const variants, so expected the original const char* s to work. The problem is in argument e: it's mutable, and strtod stores there a part of s, if s is const you end up with const data

Re: inout question

2018-02-12 Thread lobo via Digitalmars-d-learn
On Monday, 12 February 2018 at 05:37:23 UTC, ketmar wrote: Norm wrote: Hi, I'm new to D so can someone explain to me what is happening here? void func(const char* s, char** e) { import core.stdc.stdlib; auto result = strtod(s, e); } Error: function core.stdc.stdlib.strtod (scope

Re: inout question

2018-02-12 Thread ketmar via Digitalmars-d-learn
lobo wrote: sure, i meant that you have to modify the second parameter accordingly. ;-) anyway, it's good that you fixed it.

Re: inout question

2018-02-13 Thread Steven Schveighoffer via Digitalmars-d-learn
On 2/12/18 12:33 AM, Norm wrote: Hi, I'm new to D so can someone explain to me what is happening here? void func(const char* s, char** e) {     import core.stdc.stdlib;     auto result = strtod(s, e); } Error: function core.stdc.stdlib.strtod (scope inout(char)* nptr, scope inout(char)** e

Re: signbit question

2018-03-15 Thread Seb via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? I guess because for integers you don't need to distinguish between +0.0 and -0.0, so no one bother until now to add it to

Re: signbit question

2018-03-15 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Integers are stored in an entirely different way, twos-complement instead of having a sign bit. You probably shouldn't be using the sign bit function at all, it is for d

Re: signbit question

2018-03-15 Thread Stefan Koch via Digitalmars-d-learn
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the sign of an integer? Thanks in advance integers don't have a

Re: signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
faster you have to experiment. Thanks. Just one more question: Is this code correct? I don't care about +0 or -0 as the calculations on f guarantee it cannot be 0 at all. int a; float f; if((a<0)==signbit(f)) {} else {...}

Re: signbit question

2018-03-15 Thread Seb via Digitalmars-d-learn
On Thursday, 15 March 2018 at 16:31:56 UTC, Stefan Koch wrote: On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote: Why does std.math.signbit only work for floating point types? Is there an analogue function for integer types? what is the best way to compare the sign of a float with the

Re: signbit question

2018-03-15 Thread rumbu via Digitalmars-d-learn
lt; (sizeof(var)*8 - 1)); though I cannot tell which one is faster you have to experiment. Thanks. Just one more question: Is this code correct? I don't care about +0 or -0 as the calculations on f guarantee it cannot be 0 at all. int a; float f; if((a<0)==signbit(f)) {...

Re: signbit question

2018-03-15 Thread Miguel L via Digitalmars-d-learn
they are not necessarily singed. However if an integer is signed and using 1-complement you can either do sign = var < 0 or sign = (var & (1 << (sizeof(var)*8 - 1)); though I cannot tell which one is faster you have to experiment. Thanks. Just one more question: Is this code correct?

Re: signbit question

2018-03-15 Thread Dlang User via Digitalmars-d-learn
: [...] integers don't have a sign-bit. since they are not necessarily singed. However if an integer is signed and using 1-complement you can either do sign = var < 0 or sign = (var & (1 << (sizeof(var)*8 - 1)); though I cannot tell which one is faster you have to experiment. Thanks. Just

Re: signbit question

2018-03-15 Thread ketmar via Digitalmars-d-learn
Miguel L wrote: as the calculations on f guarantee it cannot be 0 at all. than `f` will become zero very soon. something that "cannot happen" is the most probable thing to happen. otherwise, LGTM.

Re: signbit question

2018-03-16 Thread ashit axar via Digitalmars-d-learn
On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); } this generate error for dmd there.

Re: signbit question

2018-03-16 Thread Radu via Digitalmars-d-learn
On Friday, 16 March 2018 at 07:00:36 UTC, ashit axar wrote: On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); } this generate error for dmd there. `writeln` is not sup

Re: signbit question

2018-03-16 Thread Seb via Digitalmars-d-learn
On Friday, 16 March 2018 at 08:35:58 UTC, Radu wrote: On Friday, 16 March 2018 at 07:00:36 UTC, ashit axar wrote: On Thursday, 15 March 2018 at 17:30:48 UTC, Seb wrote: They generate the same assembly: https://godbolt.org/g/4ohTJx import std.stdio; void main() { writeln("hello"); } th

simple newbie question

2015-11-22 Thread fred via Digitalmars-d-learn
Hi. Dll or shared library is important feature of software development. So why most d library still static link. I am sorry for my stupid question. Thanks.

simple newbie question

2015-11-22 Thread fred via Digitalmars-d-learn
How to generate temporary files so compilation time speeds up. Normal compilation only produce obj, exe. If what i mean is that if we compile the files that unchanged, dmd will look for that temporary files instead of .d files.

Multidimensional AA question

2015-11-26 Thread André via Digitalmars-d-learn
Hi, I have a maybe trivial question on how to insert or update a given entry in a multidimensional AA. So I have this AA: /// language, chapter, section. Content is a magic struct Content[int][string][string] contentAA; In some part of my code I want to either add a complete new entry

Re: htod question

2016-01-21 Thread W.J. via Digitalmars-d-learn
ork around this? Thanks and Regards Dibyendu They don't. Counter question: What's so bad about the D std library ?

Re: htod question

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:03:09 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 00:52:59 UTC, W.J. wrote: Counter question: What's so bad about the D std library ? I am trying to create bindings for existing C library so I was trying to use htod for that. The li

Re: htod question

2016-01-21 Thread Dibyendu Majumdar via Digitalmars-d-learn
On Friday, 22 January 2016 at 00:52:59 UTC, W.J. wrote: Counter question: What's so bad about the D std library ? I am trying to create bindings for existing C library so I was trying to use htod for that.

Re: htod question

2016-01-21 Thread W.J. via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:04:50 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 01:03:09 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 00:52:59 UTC, W.J. wrote: Counter question: What's so bad about the D std library ? I am trying to create binding

Re: htod question

2016-01-22 Thread Jacob Carlborg via Digitalmars-d-learn
On 2016-01-22 01:31, Dibyendu Majumdar wrote: I tried using htod but got errors as it could not handle the std C header files (Visual C++). How do people work around this? You could try DStep [1]. Although I'm not entirely sure if it works on Windows. It uses libclang, so if Clang can handle t

Shared library question

2016-01-22 Thread Dibyendu Majumdar via Digitalmars-d-learn
Hi I am trying to create a simple shared library that exports a D function, but when I try to link to it I get errors such as: error LNK2001: unresolved external symbol _D7xxx12__ModuleInfoZ Here xxx is the module inside the shared library. I am using DMD and MS LINKER (Windows 64-bit) to c

Re: htod question

2016-01-23 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:04:50 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 01:03:09 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 00:52:59 UTC, W.J. wrote: Counter question: What's so bad about the D std library ? I am trying to create binding

Re: std.socket question

2016-02-04 Thread tcak via Digitalmars-d-learn
On Thursday, 4 February 2016 at 06:40:15 UTC, sanjayss wrote: Are the functions lastSocketError() and wouldHaveBlocked() from std.socket thread-safe? i.e. can they be reliably used to see the status of the last socket call when sockets are being read/written in multiple threads? Not directly

simple range question

2016-04-08 Thread Laeeth Isharc via Digitalmars-d-learn
suppose I have a forward or random access range. what's the best way to compare each element with the element 4 elements prior to that element? I could map each element to a tuple of the element and the element 4 bars previously and do it that way. any neater way ?

Re: Assert question

2016-07-26 Thread Steven Schveighoffer via Digitalmars-d-learn
On 7/26/16 8:13 AM, DLearner wrote: Suppose a program contains several points that control should not get to. So each such point is blocked by assert(0). What is the recommended way of identifying which assert has been triggered? Is one allowed anything like 'assert(0,"Crashed at point A");', wh

Re: Assert question

2016-07-26 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 26 July 2016 at 12:13:02 UTC, DLearner wrote: What is the recommended way of identifying which assert has been triggered? If you compile with -g, run the program in a debugger. It will tell you. If you compile and do NOT use -release, the error message automatically printed by t

Question about __treats

2016-09-21 Thread Suliman via Digitalmars-d-learn
It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't understand difference https://dlang.org/spec/traits.html https://dlang.org/phobos/std_traits.html Could you explain the difference?

Real Simple Question?

2016-10-22 Thread WhatMeWorry via Digitalmars-d-learn
This is probably so simple that there's no example anywhere. Basically, I've got a huge array definition (see below) which I reuse over and over again in different projects. GLfloat[] vertices = [ // Positions // Texture Coords -0.5f, -0.5f, -0.5f, 0.0f, 0.0f, 0.5f, -0.5

Question about dsfml.system.err

2016-11-08 Thread Konstantin Kutsevalov via Digitalmars-d-learn
I need to see errors from dsfml.system.err, but it doesn't write to terminal as I expected. The general problem is that I cannot listen any port by tcplistener. And listen method is: Status accept(TcpSocket socket) { import dsfml.system.string;

Question on syntax

2016-11-08 Thread Jim via Digitalmars-d-learn
Hi, I'm a very experienced C++ programmer, looking at a program written in D. D is similar enough to C++ and Java that I have no problem understanding it - except for one thing. I think I may have figured it out, but I want to confirm my understanding. What does it mean when a variable name

Template specialization question

2016-11-24 Thread Steven Schveighoffer via Digitalmars-d-learn
void foo(T)(T t){writeln("a");} void foo(T...)(T t){writeln("b");} foo(1); Compiles? If so, which prints out? I was surprised by the answer. I can't find docs for it. Is the behavior intended? -Steve

Question about DUB

2016-12-11 Thread Xavier Bigand via Digitalmars-d-learn
Hi, I am using DUB with the SDL language and I have two questions: 1. How can I add some text file to my project? I want to add shaders in my Visual Project. 2. How to make a compiler option depending on the platform and debug mode at the same time? Thanks.

Re: GC question

2017-02-01 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 06:58:43 UTC, osa1 wrote: I'm wondering what are the implications of the fact that current GC is a Boehm-style conservative GC rather than a precise one, I've never worked with a conservative GC before. The GC isn't competitive with the ones you find in GC lan

Re: GC question

2017-02-01 Thread osa1 via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 09:40:17 UTC, Ola Fosheim Grøstad wrote: On Wednesday, 1 February 2017 at 06:58:43 UTC, osa1 wrote: I'm wondering what are the implications of the fact that current GC is a Boehm-style conservative GC rather than a precise one, I've never worked with a conserva

Re: GC question

2017-02-01 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 09:50:42 UTC, osa1 wrote: Thanks for the answer. Could you elaborate on the lacklustre part? It's fine if I have to do manual memory management, but I don't want any leaks. Ideally I'd have a precise GC + RAII style resource management when needed. Rust, Go, J

Re: GC question

2017-02-03 Thread Kagamin via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 06:58:43 UTC, osa1 wrote: Are there any disallowed memory operations? Currently can't touch GC from destructor during collection. Another concern is interoperability with C-allocated memory: GC knows nothing about C heap. How often does it leak? Leaks are

Re: GC question

2017-02-03 Thread osa1 via Digitalmars-d-learn
On Friday, 3 February 2017 at 10:49:00 UTC, Kagamin wrote: Leaks are likely in 32-bit processes and unlikely in 64-bit processes. See e.g. https://issues.dlang.org/show_bug.cgi?id=15723 This looks pretty bad. I think I'll consider something else until D's memory management story gets better.

Re: GC question

2017-02-03 Thread Dsby via Digitalmars-d-learn
On Friday, 3 February 2017 at 11:36:26 UTC, osa1 wrote: On Friday, 3 February 2017 at 10:49:00 UTC, Kagamin wrote: Leaks are likely in 32-bit processes and unlikely in 64-bit processes. See e.g. https://issues.dlang.org/show_bug.cgi?id=15723 This looks pretty bad. I think I'll consider someth

Re: GC question

2017-02-04 Thread thedeemon via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 06:58:43 UTC, osa1 wrote: I'm wondering what are the implications of the fact that current GC is a Boehm-style conservative GC rather than a precise one, I've never worked with a conservative GC before. Are there any disallowed memory operations? Can I break thi

Re: GC question

2017-02-04 Thread osa1 via Digitalmars-d-learn
On Saturday, 4 February 2017 at 11:09:21 UTC, thedeemon wrote: On Wednesday, 1 February 2017 at 06:58:43 UTC, osa1 wrote: I'm wondering what are the implications of the fact that current GC is a Boehm-style conservative GC rather than a precise one, I've never worked with a conservative GC bef

Re: GC question

2017-02-04 Thread Kagamin via Digitalmars-d-learn
On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote: I'm surprised that D was able to come this far with this. It's used mostly for server software. Things are moving to 64 bit, so this will be less of an issue.

Re: GC question

2017-02-04 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote: - Automatic but conservative. Can leak at any time. All GCs are prone to leak, including precise ones. The point of garbage collection is not to prevent leaks, but rather to prevent use-after-free bugs. Granted, the D 32 bit GC is mo

Re: GC question

2017-02-04 Thread osa1 via Digitalmars-d-learn
All GCs are prone to leak, including precise ones. The point of garbage collection is not to prevent leaks, but rather to prevent use-after-free bugs. Of course I can have leaks in a GC environment, but having non-deterministic leaks is another thing, and I'd rather make sure to delete my ref

Re: GC question

2017-02-04 Thread thedeemon via Digitalmars-d-learn
On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote: - Automatic but conservative. Can leak at any time. You have to implement manual management (managed heaps) to avoid leaks. Leaks are hard to find as any heap value may be causing it. By "managed heap" I just meant the GC heap, the one

Re: GC question

2017-02-04 Thread rikki cattermole via Digitalmars-d-learn
On 05/02/2017 5:02 PM, thedeemon wrote: snip It may look so from a distance. But in my experience it's not that bad. In most software I did in D it did not matter really (it's either 64-bit or short lived programs) and the control D gives to choose how to deal with everything makes it all quite

Re: GC question

2017-02-05 Thread Cym13 via Digitalmars-d-learn
On Sunday, 5 February 2017 at 04:22:30 UTC, rikki cattermole wrote: On 05/02/2017 5:02 PM, thedeemon wrote: snip It may look so from a distance. But in my experience it's not that bad. In most software I did in D it did not matter really (it's either 64-bit or short lived programs) and the co

Re: GC question

2017-02-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn
On Saturday, 4 February 2017 at 15:23:53 UTC, Adam D. Ruppe wrote: On Saturday, 4 February 2017 at 12:56:55 UTC, osa1 wrote: - Automatic but conservative. Can leak at any time. All GCs are prone to leak, including precise ones. The point of garbage collection is not to prevent leaks, but rath

Re: purity question

2017-05-28 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, May 28, 2017 16:49:16 Brad Roberts via Digitalmars-d-learn wrote: > Is there a mechanism for declaring something pure when it's built from > parts which individually aren't? > > string foo(string s) > { > // do something arbitrarily complex with s that doesn't touch > globals or cha

Re: purity question

2017-05-28 Thread Brad Roberts via Digitalmars-d-learn
On 5/28/2017 5:34 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, May 28, 2017 16:49:16 Brad Roberts via Digitalmars-d-learn wrote: Is there a mechanism for declaring something pure when it's built from parts which individually aren't? string foo(string s) { // do something

Re: purity question

2017-05-28 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 29 May 2017 at 00:53:25 UTC, Brad Roberts wrote: On 5/28/2017 5:34 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, May 28, 2017 16:49:16 Brad Roberts via Digitalmars-d-learn wrote: Is there a mechanism for declaring something pure when it's built from parts which indi

Re: purity question

2017-05-28 Thread Brad Roberts via Digitalmars-d-learn
On 5/28/2017 6:01 PM, Stefan Koch via Digitalmars-d-learn wrote: On Monday, 29 May 2017 at 00:53:25 UTC, Brad Roberts wrote: On 5/28/2017 5:34 PM, Jonathan M Davis via Digitalmars-d-learn wrote: On Sunday, May 28, 2017 16:49:16 Brad Roberts via Digitalmars-d-learn wrote: Is there a mechanism f

Re: purity question

2017-05-28 Thread Stefan Koch via Digitalmars-d-learn
On Monday, 29 May 2017 at 01:01:46 UTC, Stefan Koch wrote: There is void[] myPureMalloc(uint size) pure @trusted nothrow @nogc { import core.stdc.stdlib : malloc; alias pure_malloc_t = @nogc pure nothrow void* function(size_t size); return (cast(pure_malloc_t)&malloc)(size)[0 .. siz

  1   2   3   4   5   6   7   8   9   10   >