So you assert that variable length structs can't be allocated on
heap and sokoban example is a wrong example of variable length
struct usage?
And how heap indirection is different from stack indirection?
It's still indirection.
Well, cache locality can be optimized without reducing number of
indirections, as long as the data is likely to be in cache.
I agree with bearophile that variable size structs reduce number
of indirections and have no direct relation to cache locality.
One may have no time or no desire to
Well, it's proof of concept of bound checked variable-size
struct, I wrote it in a minute. It even compiles and runs.
On Wednesday, 16 April 2014 at 23:36:05 UTC, bearophile wrote:
Jeroen Bollen:
Is it possible to have a structure with a dynamic size?
See an usage example I have written here:
http://rosettacode.org/wiki/Sokoban#Faster_Version
This can illustrate
1. fairly straightforward translation of
Oh, and I don't believe, that a variable-size struct can be
emplaced inside fixed-size struct or class. Only as a smart
pointer from the example.
I mean, it doesn't cover all scenarios, but can be extended to
support them. The indexes array does just that: it's emplaced
without indirection, but still is bound checked.
On Friday, 18 April 2014 at 13:10:28 UTC, Steven Schveighoffer
wrote:
Note, you could probably, with mixin magic, make a version that
could be emplaced inside a struct or class without an extra
indirection.
Speaking about mixin magic, you probably suggest to do it overly
generically, though
You should write and register a signal handler. Implementation
for x86-32 was posted here.
Fibers are more lightweight, they're not kernel objects. Threads
are scheduled by kernel (usually). Fibers are better if you can
get better resource usage with manual scheduling - less context
switches, or don't want to consume resources need by threads.
On Friday, 25 April 2014 at 19:06:33 UTC, brad clawsie wrote:
My code compiles and fails silently.
How do you want it to fail? C code doesn't throw exceptions.
Known bug https://issues.dlang.org/show_bug.cgi?id=2742
On Sunday, 11 May 2014 at 08:48:43 UTC, FreeSlave wrote:
On Sunday, 11 May 2014 at 07:43:07 UTC, Kagamin wrote:
Known bug https://issues.dlang.org/show_bug.cgi?id=2742
It's not bug. Write-functions are designed to output text to
stdout, and it's issue of programmer to make sure that expected
AFAIK, addRoot is for memory allocated in GC heap, and addRange
is for other types of memory, so you can't add non-gc memory as
root (just a guess, see docs). I would allocate whole Args in GC
heap and add is as root, yes, it would prevent collection until
the root is removed. A better way
You can write a tool, which will construct an amalgamation build
of your code.
Why many? I'd say, you typically have 0 subscriptions (label,
textbox) per widget, seldom - 1 (button, combobox, checkbox).
combobox and checkbox usually don't require a subscription
either. Only button requires a reaction from your code,
everything else usually works on its own.
Do you always bind all of them?
Another option is to allocate from pool.
It must be scanned, so you shouldn't specify NO_SCAN attribute,
it's for memory blocks, which are guaranteed to not hold pointers
to GC memory, like ubyte[] buffers for i/o, so managed blocks can
be safely collected without looking at content of NO_SCAN blocks.
On Tuesday, 13 May 2014 at 18:47:45 UTC, Gary Willoughby wrote:
They are not bound automatically but may be bound later.
So they will be allocated on demand - only if it's bound, Args
will be allocated, so widget will have only one Args allocated,
or as many as were actually bound. Or do you
On Tuesday, 13 May 2014 at 20:02:59 UTC, Tim Holzschuh via
Digitalmars-d-learn wrote:
Still: Would it be very difficult to write a suitable parser
from scratch?
See http://forum.dlang.org/post/lbnheh$2ssm$1...@digitalmars.com
with duscussion about parsers on reddit.
For example, windows headers do use C++ -references in function
signatures and msdn provides code examples using that convention,
the equivalent in D is ref.
On Friday, 16 May 2014 at 14:52:17 UTC, Marc Schütz wrote:
But that's extern(C++), not extern(C)...
That should be a different name mangling, so won't link. Winapi
functions are declared as extern C for C++ compiler.
foreach over string apparently iterates over chars by default
instead of dchars. Didn't it prefer dchars?
string s=weiß;
int i;
foreach(c;s)i++;
assert(i==5);
On Saturday, 24 May 2014 at 18:18:37 UTC, John Colvin wrote:
if you use foreach(dchar c; s) you will get the iteration by
code-point you are looking for.
Actually I was trying to prevent decoding :) It just occurred to
me it can be tricky in generic code.
On Saturday, 24 May 2014 at 17:09:24 UTC, Tim wrote:
But doing this in all my methods
You shouldn't do it in all methods, only top-level ones, because
they are called from 3rd party code, which will do whatever
things with the exceptions from nothing to terminating the
application. Already
If it's for 32-bit windows, convert oci import libraries to omf.
http://forum.dlang.org/thread/dpaolp$1oek$1...@digitaldaemon.com
You can try ldc, which uses mingw toolchain, it's probably
compatible with msvc.
They may use different debugging formats, but just linking should
be possible, especially with import libraries.
By dynamic linking do you mean LoadLibrary or linking with import
library?
http://www.xomb.org/ ?
Try to report as a bug.
On Sunday, 1 June 2014 at 12:11:22 UTC, Ivan Kazmenko wrote:
I second the thought that reproducibility across different
versions is an important feature of any random generation
library. Sadly, I didn't use a language yet which supported
such a flavor of reproducibility for a significant
LLVM never supported OMF. LDC uses msvcrt runtime, and MS claims
that whatever can link with msvcrt, it also can link with later
versions of msvcrt.
On Saturday, 31 May 2014 at 23:27:45 UTC, Qox wrote:
On Saturday, 31 May 2014 at 07:57:18 UTC, Kagamin wrote:
http://www.xomb.org/ ?
seems to be outdated, but its another OS written in D.
It's dead for only a year, the developer have probably graduated.
Try to reduce it: remove code from the program piece by piece
until you find a fragment, which causes the problem.
debug version = DebugOrUnittest;
else version(unittest)version = DebugOrUnittest;
version(DebugOrUnittest) { static
assert(false,DebugOrUnittest); }
On Wednesday, 18 June 2014 at 20:55:09 UTC, GoD wrote:
D, very fast programming language. But I can not WinForm
applications from D. I'm using C# for WinForm applications.
DWT and TkD didn't work for you?
On Wednesday, 18 June 2014 at 19:24:03 UTC, Bienlein wrote:
Hello,
I'm looking for a way to do some kind of RPC in D. Some way of
being able to say aFoo.bar(int i, ...) with receiver object and
method being marshalled at the sender's site and being
unmarshalled and invoked at the receiver's
On Friday, 20 June 2014 at 10:51:20 UTC, Johann Lermer wrote:
`_D6deimos5cairo5cairo14cairo_matrix_t6__initZ'
it's an init value for the struct; in D all data is initialized.
See if stdio allows you to specify delete sharing when opening
the file.
On windows files are traditionally opened without delete sharing,
such files can't be deleted until closed, because all sharing
options are always honored.
It can be also a bad user experience, when delete succeeds only
pertially and doesn't free the disk space. Delete-on-close flag
should be better in this regard.
On Monday, 7 July 2014 at 14:25:54 UTC, Regan Heath wrote:
If I had to guess, I would say it would still be possible to
access the file.
It's documented so. I guess, linux implements file deletion with
delete-on-close feature too, if it exists, a separate deletion
operation is not needed.
Since you access a field through `a` instance, this is usually
done by loading the instance address into some register and
reading from a location at a certain offset from that register
mov esi, [ebp-4] # the instance address
mov eax, [esi+8] # first field
...
mov [ebp-4], 0 # clear stack
On Wednesday, 16 July 2014 at 12:15:34 UTC, bearophile wrote:
Such kind of bugs are impossible in Rust. Hopefully we'll
eventually remove them from D too.
Seems like a popular issue. Is there a bug report for it?
Report for the problem when a temporary fixed-size array is
assigned to a slice, which is escaped.
I have a more pragmatic view. Do you know the issue number?
Aren't these your words: fixing as many errors as possible always
helps even if we don't fix all errors?
The compiler would generate calls to toDelegate and toFunction
automatically.
On Wednesday, 16 July 2014 at 18:17:25 UTC, Ali Çehreli wrote:
On 07/16/2014 06:31 AM, Kagamin wrote:
I have a more pragmatic view. Do you know the issue number?
https://issues.dlang.org/show_bug.cgi?id=8838
This is not about temporary. Well, looks like it's not there.
It's ok to deduce opDispatch as pure, but then its purity should
be enforced and error reported.
On Saturday, 19 July 2014 at 17:05:27 UTC, Sean Campbell wrote:
surely not by writing another class with wrapper methods for
the existing one.
If you don't want to write the class, you can write a generator
for it. See BlackHole wrapper for an example.
On Saturday, 19 July 2014 at 17:28:13 UTC, Frustrated wrote:
If you do this you are potentially asking for a lot of access
violation errors or undefined behavior.
Of course, the object should not be used after destruction. The
trick is to reliably diagnose it. If such uses are not
You can also try class invariant.
On Wednesday, 16 July 2014 at 19:43:26 UTC, Martijn Pot wrote:
On Tuesday, 15 July 2014 at 22:09:43 UTC, ponce wrote:
On Tuesday, 15 July 2014 at 20:46:32 UTC, Martijn Pot wrote:
To make a long story short:
Is there any math library with e.g. mean, std, polynomial
fitting, ...?
On Sunday, 20 July 2014 at 18:14:29 UTC, Eric wrote:
Use @property when you want a pseudo-variable or something
that might be conceptually considered a property of the
object, i.e. to do this:
auto blah = thing.someProperty;
thing.someProperty = blahblah;
This is basically what I
I first try to load the file as utf8 (or some 8kb at the start of
it) with encoding exceptions turned on, if I catch an exception,
I reload it as ansi, otherwise I assume it's valid utf8.
AFAIK, Variant is not transparent. You can't write
parsed[field1][field2], it should be
parsed[field1].get!(Variant[string])[field2].
Registering a descriptor with moving GC is not enough, you should
also fix the pointer so that it's not moved.
The better way would be to interact through a COM interface,
which would abstract tricks of the library code. Advanced
environments are usually able to generate such interface.
On Thursday, 31 July 2014 at 12:02:22 UTC, Kozzi11 wrote:
module m;
@someUda
class C {
void someFun();
}
@someUda
class D {
void anotherFun();
}
mixin(generateFunDefForClassesWithSomeUda!m);
This is usually done by generating functions in the classes
directly.
class C {
mixin
It's an optimization of memory allocation: you can always have a
usable AA without allocating anything for it, so when you fill it
with data, you may want to assign it back to where it should
stay, similar to a slice.
Search gave result enough rope to hang yourself.
On Thursday, 14 August 2014 at 18:52:00 UTC, Sean Kelly wrote:
On 64 bit, reserve a huge chunk of memory, set a SEGV handler
and commit more as needed. Basically how kernel thread stacks
work. I've been meaning to do this but haven't gotten around to
it yet.
AFAIK, OS already provides this
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366887%28v=vs.85%29.aspx
Allocates memory charges (from the overall size of memory and
the paging files on disk) for the specified reserved memory
pages. The function also guarantees that when the caller later
initially accesses the
On Thursday, 14 August 2014 at 07:46:29 UTC, Carl Sturtivant
wrote:
The default size of the runtime stack for a Fiber is 4*PAGESIZE
which is very small, and a quick test shows that a Fiber
suffers a stack overflow that doesn't lead to a clean
termination when this limit is exceeded.
Pass a
On Friday, 15 August 2014 at 14:26:28 UTC, Sean Kelly wrote:
Oh handy, so there's basically no work to be done on Windows.
I'll have to check the behavior of mmap on Posix.
I heard, calloc behaves this way on linux (COW blank page mapped
to the entire range), it was discussed here some time
On Friday, 15 August 2014 at 14:28:34 UTC, Kagamin wrote:
On Friday, 15 August 2014 at 14:26:28 UTC, Sean Kelly wrote:
Oh handy, so there's basically no work to be done on Windows.
I'll have to check the behavior of mmap on Posix.
I heard, calloc behaves this way on linux (COW blank page
On Friday, 15 August 2014 at 14:28:34 UTC, Dicebot wrote:
Won't that kind of kill the purpose of Fiber as low-cost
context abstraction? Stack size does add up for thousands of
fibers.
I didn't measure it.
On Friday, 15 August 2014 at 22:26:54 UTC, ketmar via
Digitalmars-d-learn wrote:
and we -- 32-bit addicts -- will run out of address space while
64-bit
happy people will laugh looking at us. ;-)
You should only choose stack size carefully or keep data in
TempAlloc instead of stack.
http://dlang.org/phobos/std_traits.html#TemplateOf
On Friday, 22 August 2014 at 02:22:16 UTC, Timothee Cour via
Digitalmars-d-learn wrote:
Especially the part mentioning D:{
D’s scope keyword, Python’s with statement and C#’s using
declaration all
provide limited RAII, by allowing resources to have a scoped
lifetime, but
none of them readily
Compile and run the tests with different version options.
On Thursday, 21 August 2014 at 05:13:34 UTC, uri wrote:
_d_arraybounds (new to 2066)
This one is very useful, I recommend to implement it. It's just
easier to live with it, than try to get rid of it.
Which linker do you plan to use?
On Saturday, 23 August 2014 at 11:07:23 UTC, ketmar via
Digitalmars-d-learn wrote:
and foo is null is nice to read. ;-)
Meh, looks like a guest from pascal or basic.
On Saturday, 23 August 2014 at 11:07:23 UTC, ketmar via
Digitalmars-d-learn wrote:
and foo is null is nice to read. ;-)
function bool init
begin
rem Initialization flag
bool success assign true;
rem Initialize SDL
if execute SDL_Init SDL_INIT_VIDEO lt 0
begin
Mybe, some fields in Size overlap. If you look at it, you may
understand, what happens.
On Sunday, 24 August 2014 at 09:29:53 UTC, Jacob Carlborg wrote:
On 2014-08-24 10:03, Bienlein wrote:
I have omitted the code for the TestClass class to save space.
Problem
is that the compiler outputs this:
Error: @nogc function 'main.nogcNew!(TestClass, ).nogcNew'
cannot call
non-@nogc
On Sunday, 31 August 2014 at 08:37:40 UTC, Jonathan M Davis via
Digitalmars-d-learn wrote:
D program should just use string unless it needs random-access,
in which case,
it should use dstring.
Except that dstring is not fool-proof either when one needs to
work at grapheme level.
You can try to create an exception and get stack trace from it.
The functionality is in druntime.
On Sunday, 24 August 2014 at 13:27:01 UTC, Jacob Carlborg wrote:
On 2014-08-24 14:18, Kagamin wrote:
Shouldn't emplace and destroy infer their attributes instead
of strictly
annotating them as nogc.
If they are templates, I guess they should. I don't know how
good the compiler is at
Maybe some module constructor wasn't run due to linking mess. So
it remains uninitialized.
https://github.com/D-Programming-Language/druntime/blob/master/src/core/stdc/stdio.d#L457
see? It's null. Hmm... where is it initialized?
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/dmain2.d#L270
well, this sucks.
It's not a module ctor, this code is executed much earlier. You
can write a function, which will initialize standard streams, and
call it from the C code before rt_init.
SEH was patented, so llvm doesn't support it.
Looks like mingw supports 3 types of exception handling. LDC
usually tightly coupled with mingw version, you shouldn't try it
blindly, but follow installation instructions instead.
cast(DWORD)v
On Sunday, 7 September 2014 at 21:06:48 UTC, zuzuleinen wrote:
The reason I post this is to ask you what other books do you
think I should try in order to become hireable in the next 2
years?
See
http://forum.dlang.org/thread/sgtnnyvmhxzexupgw...@forum.dlang.org
On Monday, 8 September 2014 at 21:17:40 UTC, ketmar via
Digitalmars-d-learn wrote:
On Mon, 08 Sep 2014 21:05:53 +
Gary Willoughby via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
I would agree but that little C book is an amazing read and
full of valuable lessons.
and
On Saturday, 6 September 2014 at 22:06:30 UTC, David Nadlinger
wrote:
On Saturday, 6 September 2014 at 16:36:38 UTC, Kagamin wrote:
Looks like mingw supports 3 types of exception handling. LDC
usually tightly coupled with mingw version, you shouldn't try
it blindly, but follow installation
Do you want to customize buffering in child or parent process?
async/await is not so much about futures/promises, but
optimization of IO-bound operations, i.e. when you wait on
network/disk, you don't consume stack, threads and similar
resources, an analog in D is vibe.d
No, vibe provides synchronous non-blocking interface similar to
async/await.
On Sunday, 14 September 2014 at 00:34:56 UTC, WhatMeWorry wrote:
So is one form (Empty strings versus null strings) considered
better than the other? Or does it depend on the context?
For all practical purposes they should be equivalent in D code. I
suppose the distinction exists because
On Friday, 12 September 2014 at 03:59:58 UTC, Cliff wrote:
...but std.parallelism.Task requires parameterization on the
function which the task would execute - that is clearly an
implementation detail of the store.
I think, you can wrap the Task in a class.
abstract class CTask
{
abstract
Doesn't this cause infinite recursion?
1 - 100 of 899 matches
Mail list logo