On Tuesday, 9 February 2021 at 12:23:52 UTC, rikki cattermole
wrote:
https://github.com/dlang-community/containers
It uses the older design for allocators (dependency).
Looks good, thank you
Normally I'm happy with the GC containers in D, they work well
and suit my use.
I have a few uses that would benefit from allocation in memory
arenas or local stack based allocation. Looks like
std.experimental has allocators for those use cases.
But I can't find any containers to make use o
On Monday, 27 July 2020 at 16:58:13 UTC, H. S. Teoh wrote:
On Mon, Jul 27, 2020 at 11:39:32AM +, John Burton via
Digitalmars-d-learn wrote: [...]
I tried looking there for information and examples of getting
glfw3 statically linked into my program using LDC and didn't
really find any
On Wednesday, 15 July 2020 at 22:18:47 UTC, H. S. Teoh wrote:
On Wed, Jul 15, 2020 at 09:27:22PM +, tastyminerals via
Digitalmars-d-learn wrote: [...]
D wiki is badly outdated. This is not a fact but a gut feeling
after reading through some of its pages. I was wondering who's
owning it myse
On Monday, 27 July 2020 at 08:53:25 UTC, Mike Parker wrote:
On Monday, 27 July 2020 at 07:30:42 UTC, John Burton wrote:
For reference I got this to work by doing the following :-
1) Installed visual studio build tools. I could not get this
to work at all with the linker etc that comes with ld
On Sunday, 26 July 2020 at 12:24:06 UTC, John Burton wrote:
On Sunday, 26 July 2020 at 10:41:27 UTC, Mike Parker wrote:
On Sunday, 26 July 2020 at 08:28:29 UTC, John Burton wrote:
And I get the following errors from the link :-
lld-link: error: undefined symbol: __GSHandlerCheck
lld-link: er
On Sunday, 26 July 2020 at 10:41:27 UTC, Mike Parker wrote:
On Sunday, 26 July 2020 at 08:28:29 UTC, John Burton wrote:
And I get the following errors from the link :-
lld-link: error: undefined symbol: __GSHandlerCheck
lld-link: error: undefined symbol: __security_check_cookie
lld-link: erro
I'm trying to replicate a program I make in C++ using D.
I am using the ldc2 compiler and want to *static* link in the
glfw library.
Following the docs I have an dub.sdl file that looks like the one
below.
The library I'm linking with is the vs2019 one from the GLFW zip
file from
their websit
On Monday, 25 May 2020 at 16:39:30 UTC, Mike Parker wrote:
On Monday, 25 May 2020 at 08:39:23 UTC, John Burton wrote:
I believe that in D *this* is a reference to the
object and not a pointer like in C++.
So I think that writing &this might be what you need?
No. A class reference is a pointer
On Sunday, 24 May 2020 at 17:40:10 UTC, bauss wrote:
On Sunday, 24 May 2020 at 17:05:16 UTC, Vinod K Chandran wrote:
[...]
I think your issue might be elsewhere because casting this
should be fine and it should not complain about that in your
given code.
At least you should be able to pass
After years of C++ I have become paranoid about any casting of
pointers being undefined behavior due to aliasing so want to see
if :-
1) This is safe to do in D.
2) If not is there anything I can do to make it safe.
3) If not, what is the best approach?
I have a void* pointing to a block of al
On Monday, 21 January 2019 at 07:57:58 UTC, Simen Kjærås wrote:
On Saturday, 19 January 2019 at 14:26:31 UTC, Zenw wrote:
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
[...]
how about this
auto With(string code,T)(T value)
{
with(value)
{
mixin(code ~";");
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
struct Config
{
string title;
int width;
}
struct Window
{
this(Config config)
It likely is a bad idea for a small struct like this but if it
was much bigger would it makes sense to write this as :-
On Wednesday, 16 January 2019 at 14:59:01 UTC, Kagamin wrote:> On
Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
auto window = Window(title = "My Window", width = 1000,
fullscreen = true);
In this particular case I would make the constructor take 3
parameters - title, width and h
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
[...]
Let me throw this idea here:
struct Config
{
string title;
int width;
}
struct Window
{
this(Config config)
{
On Wednesday, 16 January 2019 at 11:21:53 UTC, Dukc wrote:
On Tuesday, 15 January 2019 at 11:14:54 UTC, John Burton wrote:
This is ok, but I'm not so keen on separating the creation and
construction like this.
Is there a better way that's not ugly?
You can make the constructor a template that
On Tuesday, 15 January 2019 at 12:15:41 UTC, rikki cattermole
wrote:
On 16/01/2019 1:05 AM, John Burton wrote:
On Tuesday, 15 January 2019 at 11:26:50 UTC, rikki cattermole
wrote:
Longer term, you're better off with the builder.
Thanks for your reply. But what is the builder?
https://en.wiki
On Tuesday, 15 January 2019 at 11:26:50 UTC, rikki cattermole
wrote:
Longer term, you're better off with the builder.
Thanks for your reply. But what is the builder?
Creating windows is a very complex task that can balloon in
scope.
Well that was mostly just an example that I thought people
As an example let's say I have a type 'Window' that represents a
win32 window. I'd like to be able to construct an instance of the
type with some optional parameters that default to some
reasonable settings and create the underlying win32 window.
I'd ideally like some syntax like this :-
auto
On Wednesday, 5 December 2018 at 10:52:44 UTC, Guillaume Piolat
wrote:
On Wednesday, 5 December 2018 at 01:57:53 UTC, evilrat wrote:
On Tuesday, 4 December 2018 at 20:41:54 UTC, Guillaume Piolat
wrote:
[...]
I was using gl3n then switched to gfm math. Try gfm, IIRC it
should work without muc
On Wednesday, 5 December 2018 at 01:57:53 UTC, evilrat wrote:
On Tuesday, 4 December 2018 at 20:41:54 UTC, Guillaume Piolat
wrote:
On Tuesday, 4 December 2018 at 20:33:07 UTC, John Burton wrote:
What is the best alternative for D, assuming there is
anything?
(I want vector, matrix math for use
There is a directx-d library which seems to work nicely for d3d11
but it doesn't include anything like DirectXMath.h presumably
because it's all implemented as inline intrinsics and very visual
c++ specific.
What is the best alternative for D, assuming there is anything?
(I want vector, matrix
On Tuesday, 30 October 2018 at 10:46:35 UTC, Mike Parker wrote:
On Tuesday, 30 October 2018 at 10:30:48 UTC, John Burton wrote:
I want to do some graphics using direct3d11 on windows.
There are some bindings that I used once before
https://github.com/evilrat666/directx-d
However they are marke
I want to do some graphics using direct3d11 on windows.
There are some bindings that I used once before
https://github.com/evilrat666/directx-d
However they are marked as [discontinued]
While I'm sure they will continue to work so wouldn't worry about
using this I wonder if there are any other
Is there any documentation or information about the specifics of
the garbage collector?
The information I have found indicates that it runs to free
memory when the system runs out of memory to allocate. But will
this try to use all the system memory or some other amount before
trying to garba
On Sunday, 14 October 2018 at 13:07:30 UTC, Heromyth wrote:
On Monday, 8 October 2018 at 09:39:55 UTC, John Burton wrote:
My use case is sending data to a socket.
We have ported some containers from JAVA.
ByteBuffer is a basic container interface and widely used in
JAVA.
See also:
https:/
My use case is sending data to a socket.
One part of my program generates blocks of bytes, and the socket
part tries to send them to the socket and then removes from the
queue the number that got sent.
I am currently using a byte[] and using concatenation and slicing
to maintain the queue bu
On Tuesday, 25 September 2018 at 12:05:21 UTC, Jonathan M Davis
wrote:
[...]
Thanks everyone.
Is there any documentation anywhere that deals with calling D
from C? I could find plenty the other way round. I think I'll
give up on the idea though, and rewrite the whole thing in D :)
I need to write a library to statically link into a c program.
Can I write this library in D?
Will I be able to use proper D abilities like gc? Obviously the
public interface will need to be basic c callable functions...
I 'main' is a c program will this work?
On Friday, 24 August 2018 at 15:26:30 UTC, kinke wrote:
On Friday, 24 August 2018 at 13:10:40 UTC, John Burton wrote:
Is in the subject. Are there any cross compilers that will run
on a linux system but compile D code using Win32 into a
windows .exe file, preferably 64 bit? I can find hints of
Is in the subject. Are there any cross compilers that will run on
a linux system but compile D code using Win32 into a windows .exe
file, preferably 64 bit? I can find hints of cross compilers but
not really seen anything packaged up?
On Thursday, 1 March 2018 at 12:20:08 UTC, Steven Schveighoffer
wrote:
On 3/1/18 7:05 AM, Gary Willoughby wrote:
On Thursday, 1 March 2018 at 10:10:27 UTC, John Burton wrote:
My question is how do I tell if a pointer is "garbage
collected" or not?
You could try `GC.addrOf()` or `GC.query()` i
In the language spec here :-
https://dlang.org/spec/garbage.html#pointers_and_gc
It refers to a distinction between pointers to garbage collected
memory and pointers that are not. In particular it says that with
a non garbage collected pointer you can do anything that is
legal in C but with a
On Friday, 13 October 2017 at 10:35:56 UTC, Jack Applegame wrote:
If you don't want to get the great PITA, never create temporary
objects in function parameters.
I recently spent a whole day digging through my reference
counted containers library. But nasty bug was not there, but in
the compile
On Thursday, 12 October 2017 at 14:22:43 UTC, Timon Gehr wrote:
On 11.10.2017 11:27, John Burton wrote:
Yes, that's what it is saying. (The other answers, that say or
try to imply that this is not true or true but not a bad thing,
are wrong.)
...
However, in practice, I think none of the
The spec says this :-
"As a contract, an assert represents a guarantee that the code
must uphold. Any failure of this expression represents a logic
error in the code that must be fixed in the source code. A
program for which the assert contract is false is, by definition,
invalid, and therefo
If I have a int* pointer for example, that points to the start of
an int array and step through the array until I get the value
123, is it defined in D what happens if you step off the end of
the array?
What I might expect to happen is for the code to just keep
stepping through sequential mem
On Wednesday, 13 September 2017 at 09:49:46 UTC, Jonathan M Davis
wrote:
On Wednesday, September 13, 2017 07:51:19 John Burton via
Digitalmars-d- learn wrote:
[...]
You could probably do what you want with std.concurrency, since
most of what it does is deal with sending and receiving data
Is there any threadsafe queue in the standard library?
I've not been able to find anything but thought I'd check before
making my own.
I want to be able to assemble messages (Which are just streams of
bytes) in one thread into a struct and push them to the queue,
and then have a another threa
On Sunday, 10 September 2017 at 21:38:03 UTC, Cecil Ward wrote:
On Wednesday, 6 September 2017 at 15:55:35 UTC, Ali Çehreli
wrote:
[...]
Ali, I have worked on operating systems' development in r+d. My
definitions of terms are hopefully the same as yours. If we
refer to two threads, if they b
I wrote this simple program to test out my understanding of
memory allocation :-
import std.stdio;
void main()
{
int [] array = new int[250];
writeln(array.length, " elements ", array);
// Append one value to the array
array ~= 123;
writeln(
On Thursday, 31 August 2017 at 21:06:17 UTC, Ivan Kazmenko wrote:
On Thursday, 31 August 2017 at 14:43:39 UTC, Steven
Schveighoffer wrote:
Just a thought, but the "double printing" could be a
misunderstanding. It could be printing Output\nOutput2, but
not getting the 2 out there.
Just to sa
On Tuesday, 5 September 2017 at 08:39:37 UTC, Jonathan M Davis
wrote:
On Tuesday, September 05, 2017 08:15:04 John Burton via
Digitalmars-d-learn wrote:
std.string.fromStringz will create me a string from a null
terminated array of characters. But I have a zero terminated
array of "sh
std.string.fromStringz will create me a string from a null
terminated array of characters. But I have a zero terminated
array of "short"s (from a win32 api call) which I'd like to turn
into a wstring. But there doesn't seem to be a function to do
this.
Do I need to write my own, or am I missi
On Tuesday, 25 July 2017 at 13:24:36 UTC, Mike Parker wrote:
On Tuesday, 25 July 2017 at 12:40:13 UTC, John Burton wrote:
[...]
This should give you the answer:
writefln("Before: ptr = %s capacity = %s", slice.ptr,
slice.capacity);
slice ~= 1;
writefln("After: ptr = %s capacity = %s", slice
I can create a "slice" using non-gc allocated memory.
int* ptr = cast(int*)calloc(int.sizeof, 10);
int[] data = ptr[0..10];
If I don't want a memory leak I have to call free(ptr) somewhere
as it won't be GC collected when data or ptr go out of scope. I
presume there is nothing
On Wednesday, 19 July 2017 at 12:15:05 UTC, Mike Parker wrote:
On Wednesday, 19 July 2017 at 12:11:38 UTC, John Burton wrote:
On Wednesday, 19 July 2017 at 12:05:09 UTC, Kagamin wrote:
Try a newer compiler, this was fixed recently.
Hmm it turns out this machine has 2.0.65 on which is fairly
On Wednesday, 19 July 2017 at 12:05:09 UTC, Kagamin wrote:
Try a newer compiler, this was fixed recently.
Hmm it turns out this machine has 2.0.65 on which is fairly
ancient. I'd not realized this machine had not been updated.
Sorry for wasting everyones' time if that's so, and thanks for
t
On Wednesday, 19 July 2017 at 11:31:32 UTC, Jacob Carlborg wrote:
On 2017-07-19 09:22, John Burton wrote:
In C I can declare a function 'static' and it's only visible
from within that implementation file. So I can have a static
function 'test' in code1.c and another non static function
'test'
On Wednesday, 19 July 2017 at 07:51:11 UTC, Gary Willoughby wrote:
On Wednesday, 19 July 2017 at 07:22:48 UTC, John Burton wrote:
In C++ I could use static or an anonymous namespace for
implementation functions, but there doesn't seem to be
anything similar in D.
Is there any way to achieve wha
In C I can declare a function 'static' and it's only visible from
within that implementation file. So I can have a static function
'test' in code1.c and another non static function 'test' in
utils.c and assuming a suitable prototype I can use 'test' in my
program and the one in code1.c will not
On Tuesday, 27 June 2017 at 09:54:19 UTC, John Burton wrote:
I'm coming from a C++ background so I'm not too used to garbage
collection and it's implications. I have a function that
creates a std.socket.Socket using new and connects to a tcp
server, and writes some stuff to it. I then explicitl
On Tuesday, 27 June 2017 at 10:14:16 UTC, Jonathan M Davis wrote:
On Tuesday, June 27, 2017 09:54:19 John Burton via
Digitalmars-d-learn wrote:
I'm coming from a C++ background so I'm not too used to
garbage collection and it's implications. I have a function
that creates a st
I'm coming from a C++ background so I'm not too used to garbage
collection and it's implications. I have a function that creates
a std.socket.Socket using new and connects to a tcp server, and
writes some stuff to it. I then explicitly close the socket, and
the socket object goes out of scope.
Thanks again for the updates. I've experimented some more and
believe I understand.
To be honest I'm finding it very hard to find the right idioms in
D for safe and efficient programming when I'm so used to C++ /
RAII everywhere. I'll adapt though :P
Ok that's great thank you.
It's quite hard trying to get a proper understanding of memory
allocation in D after years of C++ / RAII / unique_ptr /
shared_ptr . I understand the details of course but it's going to
take a while to really know it.
Is there any way to explicitly free a dynamic a
I'm a c++ programmer trying to understand how memory allocation
works in D.
I created a struct and added a destructor to it. My understanding
is that structs have deterministic destructors - they are called
when the struct goes out of scope (unless it is allocated with
new).
Now if I put in
Ok thank you.
Seems to me that there is enough doubt that this is "supported"
that I'd be best to avoid relying on it, or at least ensure that
it's all encapsulated in something I can easily change.
This would be undefined behavior in c++ due to aliasing rules on
pointers. It appears to "work" reliably in D when I try it, but
that's obviously no guarantee that it's correct or will continue
to do so.
Is this correct code in D? And if not, what should I do instead
to cleanly and efficientl
59 matches
Mail list logo