Just to follow up, I introduced the `Volatile` struct to my
project and had to add a couple extra functions to make
everything happy:
```d
module myproj.volatile;
import core.volatile;
struct Volatile(T)
{
private T value;
public @property T read()
{
return volatileLoad(&
On Monday, 2 December 2024 at 22:44:24 UTC, Ali Çehreli wrote:
On 12/2/24 12:27 PM, Josh Holtrop wrote:
>> alias get this;
>
> If I use `alias this` I don't know how I can get
`volatileLoad()` to be
> called.
Note that alias this is used with your 'get'
On Monday, 2 December 2024 at 19:30:06 UTC, Ali Çehreli wrote:
On 12/2/24 11:10 AM, Josh Holtrop wrote:
> This works but requires that ugly .get call rather than just
accessing
> it directly.
'alias this' may help:
https://dlang.org/spec/struct.html#alias-this
All you need
I'm working on an embedded project writing some device drivers to
access peripheral control registers as MMIO addresses. Due to D's
lack of a `volatile` keyword, I'm trying to come up with a way to
define these peripheral control register structures in a way that
doesn't require the user of the
On Friday, 28 June 2024 at 22:25:40 UTC, drug007 wrote:
Both yes and no, you check the type once, but then check for
null, so a double check is performed nonetheless. But for me
it's a minor difference.
There are two common ways to handle sumtypes: using either an
explicit type tag or implici
On Friday, 28 June 2024 at 10:52:01 UTC, drug007 wrote:
What prevents you from doing:
```D
import std.sumtype;
class Foo {}
class Bar {}
alias Item = SumType!(Foo, Bar);
void main()
{
Item[] items = [Item(new Foo()), Item(new Bar()), Item(new
Foo()), Item(new Bar())];
foreach (item;
Hello all. In my application I came across a desire to store an
ordered array of handles that could point to one of several
different objects, and it seems like the tool I want for that is
SumType.
I started with something like (simplified of course):
```d
class Foo {}
class Bar {}
alias Ite
On Thursday, 29 June 2023 at 19:19:21 UTC, Adam D Ruppe wrote:
On Thursday, 29 June 2023 at 18:47:48 UTC, Josh Holtrop wrote:
$ ldc2 -of environment environment.d
Since you named the file `environment.d` and didn't use an
explicit `module name.thing;` declaration, the compiler assume
I am trying to use `std.process.environment.get()` as described
here: https://dlang.org/library/std/process/environment.get.html
I wrote this program to test it:
```d
import std.stdio;
import std.process;
int main(string[] args)
{
string home = environment.get("HOME");
writeln("home is
I am trying to use std.sumtype which seems to be just what I need
for some functions that can return various types of errors with
parameters or a success value with different parameters.
In this test I get a compilation error with ldc2:
```d
import std.stdio;
import std.sumtype;
struct Error
On Thursday, 6 April 2023 at 00:59:12 UTC, Mathias LANG wrote:
immutable ubyte[4] data = [1, 2, 3, 4];
Using a static array instead of a slice will do the trick. You
can leave the `__gshared` if you want, but it is redundant on a
global, initialized `immutable` variable.
Yes, thank you, usi
I am trying to port a small C project to D and am getting a
compilation error I don't understand.
I've simplified the situation down to the example here.
This C version compiles fine:
```c
#include
static const unsigned char data[] = {1, 2, 3, 4};
static const unsigned char * p = &data[0];
I'm trying to read in a text file that has many duplicated lines
and output a file with all the duplicates removed. By the end of
this code snippet, the memory usage is ~5x the size of the infile
(which can be multiple GB each), and when this is in a loop the
memory usage becomes unmanageable a
On Wednesday, 28 October 2020 at 07:56:35 UTC, Mike Parker wrote:
On Wednesday, 28 October 2020 at 07:50:27 UTC, Josh Dredge
wrote:
developers would love to be working with! I will give Gtk a go
too - I've never programmed with it, but I used Ubuntu alot
back in the day and never r
On Wednesday, 28 October 2020 at 06:52:35 UTC, evilrat wrote:
On Tuesday, 27 October 2020 at 11:46:02 UTC, Josh Dredge wrote:
[...]
Welcome! If by web development you also have back-end
programming then you should be like 50% know how desktop
programming works.
[...]
Fantastic, thank
Hi all, I'm completely new to D and while I'm not new to
programming in general, I mostly do web development, and what
desktop development I've done has all been with easy
drag-and-drop GUI builders - so Visual Basic, C# and J# (if that
doesn't date me). I'm trying to experiment in new language
On Monday, 20 May 2019 at 11:10:32 UTC, Boqsc wrote:
https://dlang.org/spec/float.html
I'm frozen in learning basics of D lang since I want to create
a simple game and I really would like a clean and simple code,
however to me floating points are magic.
https://wiki.dlang.org/Review_Queue
Si
Thank you, that helps big time.
This is just more curiosity, but do you happen to know why I have
to use DList.linearRemove() instead of DList.remove()?
import std.stdio;
import std.container.dlist;
import std.algorithm;
import std.range;
void main()
{
auto list = make!DList("the", "quick
Just started looking at D this weekend, coming from a
C++/Java/Go/Rust background and it's really not going well.
Trying to write something to play with the language and need a
linked list, looking in std.container you have a single or doubly
linked list...great.
Now how to I iterate over it
I have a website (say https://website.com) that I need to log in
to, it will do a few 302 redirects and then I will end up with a
unique session ID in the URL (such as
https://website.com/welcome.html?s=636853677441448706). Is there
some way of extracting this ID (I'll need it later for other
curl_easy_setopt(hnd, CURLOPT_CAINFO,
"C:\\Users\\Josh\\Downloads\\curl-7.57.0-win64-mingw\\bin\\curl-ca-bundle.crt");
curl_easy_setopt(hnd, CURLOPT_SSH_KNOWNHOSTS,
"C:\\Users\\Josh\\AppData\\Roaming/_ssh/known_hosts");
curl_easy_setopt(hnd, CURLOPT_COOKIEFILE, "cooki
ress, 1);
//http.handle.set(CurlOption.useragent, "curl/7.57.0");
http.handle.set(CurlOption.maxredirs, 50);
//http.handle.set(CurlOption.cainfo,
"C:\\Users\\Josh\\Downloads\\curl-7.57.0-win64-mingw\\bin\\curl-ca-bundle.crt");
http.handle.set(CurlO
On Friday, 22 September 2017 at 03:26:36 UTC, Mike Parker wrote:
On Friday, 22 September 2017 at 02:22:46 UTC, Josh wrote:
src\mixer.d(80,22): Error: function pointer
Mix_ChannelFinished (extern (C) void function(int channel)) is
not callable using argument types (extern (C) void
delegate
On Friday, 22 September 2017 at 02:18:34 UTC, Mike Parker wrote:
On Thursday, 21 September 2017 at 22:05:22 UTC, Matt Jones
wrote:
On Thursday, 21 September 2017 at 20:21:58 UTC, Josh wrote:
I'm trying to write a callback function for SDL_mixer through
Derelict, but this is the first time
On Thursday, 21 September 2017 at 22:05:22 UTC, Matt Jones wrote:
On Thursday, 21 September 2017 at 20:21:58 UTC, Josh wrote:
I'm trying to write a callback function for SDL_mixer through
Derelict, but this is the first time I've tried to use a
function as a parameter, and so I thin
I'm trying to write a callback function for SDL_mixer through
Derelict, but this is the first time I've tried to use a function
as a parameter, and so I think I'm just making a minor mistake
somewhere.
The C SDL docs say:
// make a channelDo
My goal with the code below is to eventually have my main
communicate with Foo and Bar classes listening for packets on a
different address/port, each in a separate thread. They would
then communicate with Foobaz and Barbaz threads respectively to
do other work. In trying to get just Foo workin
On Saturday, 23 January 2016 at 21:06:32 UTC, Adam D. Ruppe wrote:
Are you sure you correctly casted first?
Nope sorry. Thanks for the help!!
On Friday, 22 January 2016 at 23:44:34 UTC, Adam D. Ruppe wrote:
There's a .classinfo property that works on Objects.
If you have an interface, cast to Object first, and check for
null, then get .classinfo off that.
I tried this but it will return A not B
If I have:
interface A {}
class B : A {}
void printClass(A obj){
// Code here
}
Is there any way that I can find out what class obj is inside of
printClass? I know I can cast and check if(cast(B)obj) but I want
to just be able to do something along the lines of obj.class. I
can think of
On Friday, 15 January 2016 at 07:37:27 UTC, Josh Phillips wrote:
However I (of course) ran into new errors. Gl functions like
glGetString and glGetIntegerv cause the program to crash. It
appears that an opengl context is being created so I'm not sure
whats causing the problem
For anyone
I also ran into this issue because I upgraded VS and removed the
old version. A quick re-install with the dmd .exe fixed it.
On Thursday, 14 January 2016 at 09:42:50 UTC, Dav1d wrote:
On Thursday, 14 January 2016 at 09:25:50 UTC, Dav1d wrote:
On Thursday, 14 January 2016 at 02:35:28 UTC, Josh Phillips
wrote:
Welcome to D and Windows. You can use GDC or LDC or try
http://wiki.dlang.org/Installing_DMD_on_64
On Thursday, 14 January 2016 at 02:16:40 UTC, userABCabc123 wrote:
On Wednesday, 13 January 2016 at 19:05:30 UTC, Josh Phillips
wrote:
Oh wow that's easy. They should really make that more clear in
the dlang reference. They way it sounds there made me think
that if a function doesn't
On Wednesday, 13 January 2016 at 20:08:55 UTC, Dav1d wrote:
Link with opengl32.lib
How? Everywhere I looked it says this cannot be done due to
conflicting formats between the dmd compiler and the windows one.
On Wednesday, 13 January 2016 at 18:37:09 UTC, Adam D. Ruppe
wrote:
You just need to explicitly mark it nothrow in the signature.
Add `nothrow` to the end of the param list:
extern(Windows)
LRESULT WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam) nothrow
and then you'll be cool
So I started using Glad but I can't get WGL to work with it,
though I think this is more of a Win32 issue than WGL.
wndclass.lpfnWndProc = &WndProc;
Gives me an error no matter what:
Error: cannot implicitly convert expression (& WndProc) of type
int function(void* hWnd, uint message, uint w
es I should use?
Thanks
Josh
uot;)();
auto trimmed = setDifference(numbers, sequence!("n * a[0]")(2));
trimmed = setDifference(trimmed, sequence!("n * a[0]")(3));
Thanks,
Josh
On Friday, 14 February 2014 at 20:36:42 UTC, Jeremy DeHaan wrote:
Unless I am mistaken, it looks like the last time it was
updated was in 2011. You'd probably have to update a bunch of
stuff in the sources in order to get it to work properly.
I would recommend gtkD as a gui library.
I think
I recently downloaded and tried to use DGUI but I can't get it to
work. Is there any tutorials on how to build an use it? Or can
anyone help me and tel me a way on how I can get it to work?
I was wondering if people could suggest which libraries may be
best to use for building an application which would be a type of
text editor with multiple documents and branches. I need
something whereby I can create simple, custom windows and do
simple text editing, but then i need it to also hand
On Thursday, 22 August 2013 at 04:18:34 UTC, Josh wrote:
Windows 7, DMD 2.062
I was trying to use std.file.copy, and I kept getting a
FileException because it couldn't find the file, even though I
triple checked the name and that it existed in Explorer. So I
did a little test to illus
dll
16/12/2011 06:46 PM 634,880 msvcrt21.dll
msvcrt21.dll I created by copying msvcrt.dll. I also can't find
msvcrt20/40.dll inside Explorer. Is there any reason why these
don't show the same results?
Thanks,
Josh
ut(d);
foreach (n; names)
{
try
{
d = dirEntry(n);
if (d.isDir && !canFind(d.name, "Windows") &&
!canFind(d.name, "Program Files") && !canFind(d.name,
"ProgramData")
On Wednesday, 3 July 2013 at 04:51:06 UTC, Jonathan M Davis wrote:
On Wednesday, July 03, 2013 06:44:33 Josh wrote:
On Wednesday, 3 July 2013 at 04:32:15 UTC, Jonathan M Davis
wrote:
> On Wednesday, July 03, 2013 06:23:12 Josh wrote:
>> writeln(to!double("151.42499"));
On Wednesday, 3 July 2013 at 04:32:15 UTC, Jonathan M Davis wrote:
On Wednesday, July 03, 2013 06:23:12 Josh wrote:
writeln(to!double("151.42499"));//prints 151.425
Is there any way to stop this rounding?
No. double can't hold the value 151.42499. There are _tons_ of
writeln(to!double("151.42499"));//prints 151.425
Is there any way to stop this rounding?
Thanks,
Josh
On Tuesday, 18 June 2013 at 05:46:17 UTC, Aleksandar Ruzicic
wrote:
On Tuesday, 18 June 2013 at 02:02:52 UTC, Josh wrote:
I've added in wsock32.lib, the -J, and the 3 versions, and it
gives the same output. I should mention that I can compile the
examples fine with both vibe and d
x27;ve added in wsock32.lib, the -J, and the 3 versions, and it
gives the same output. I should mention that I can compile the
examples fine with both vibe and dub by themselves, but
apparently not inside Eclipse.
Thanks for your help though Aleksandar.
Josh
__ModuleInfoZ
bin\TestProg.obj(TestProg)
Error 42: Symbol Undefined _D4vibe2db5mongo5mongo12__ModuleInfoZ
--- errorlevel 20
dmd is 2.063 on Windows 7.
I know both Eclipse and dmd work, as I can compile other programs
that just use Phobos. I'm sure it's something really obvious that
I can't see, but I haven't had much luck with external libs. The
same sort of thing happened when I used GtkD...
Any help is welcomed.
Thanks,
Josh
On Saturday, 18 May 2013 at 08:26:09 UTC, Dicebot wrote:
On Saturday, 18 May 2013 at 02:09:49 UTC, Josh wrote:
Bearophile, is your findVar an AA? It looks like it is, I just
didn't think you could put refs in an AA.
Thanks
Josh
It is AA and it stores pointers, not references.
P.S.
On Friday, 17 May 2013 at 22:15:09 UTC, bearophile wrote:
Josh:
Is something like this possible in D?
void main()
{
int x, y, z;
write("Increment which variable: ");
string input = readln()[0..$ - 1];
findVar(input)++;
writeln(x, y, z);
}
The Go language and it
On Tuesday, 14 May 2013 at 04:14:27 UTC, Ali Çehreli wrote:
On 05/13/2013 08:50 PM, Josh wrote:
Is there a way in D to only accept input for a certain time,
instead of
std.stdio.readln's behaviour? Something like "Press a key in 3
seconds
to abort".
Thanks
Josh
An unlik
Is there a way in D to only accept input for a certain time,
instead of std.stdio.readln's behaviour? Something like "Press a
key in 3 seconds to abort".
Thanks
Josh
On Sunday, 14 April 2013 at 13:34:07 UTC, Mike Wey wrote:
On 04/13/2013 07:00 AM, Josh wrote:
On Wednesday, 10 April 2013 at 20:17:36 UTC, Mike Wey wrote:
On 04/10/2013 03:20 PM, Josh wrote:
After trying to compile in 64 bit and failing, I've given up
and just
used 32 bit. So now I hav
On Wednesday, 10 April 2013 at 20:17:36 UTC, Mike Wey wrote:
On 04/10/2013 03:20 PM, Josh wrote:
After trying to compile in 64 bit and failing, I've given up
and just
used 32 bit. So now I have GTK-Runtime 3.6.1 32 bit, GtkD
2.1.1 and DMD
2.062. My program is still giving the no sc
On Wednesday, 3 April 2013 at 20:41:47 UTC, Mike Wey wrote:
On 04/03/2013 05:38 AM, Josh wrote:
On Tuesday, 2 April 2013 at 20:50:16 UTC, Mike Wey wrote:
On 04/02/2013 02:38 PM, Josh wrote:
On Sunday, 31 March 2013 at 14:21:50 UTC, Mike Wey wrote:
On 03/30/2013 05:42 PM, Josh wrote:
On
How can I find out which line of code is causing a thread to
throw a LinkTerminated? Every time I catch one, it always says
std\concurrency.d(262), which is just the LinkTerminated
constructor.
Thanks,
Josh
On Tuesday, 2 April 2013 at 20:50:16 UTC, Mike Wey wrote:
On 04/02/2013 02:38 PM, Josh wrote:
On Sunday, 31 March 2013 at 14:21:50 UTC, Mike Wey wrote:
On 03/30/2013 05:42 PM, Josh wrote:
On Saturday, 30 March 2013 at 16:17:22 UTC, Mike Wey wrote:
On 03/30/2013 03:49 PM, Josh wrote:
Sorry, I
On Sunday, 31 March 2013 at 14:21:50 UTC, Mike Wey wrote:
On 03/30/2013 05:42 PM, Josh wrote:
On Saturday, 30 March 2013 at 16:17:22 UTC, Mike Wey wrote:
On 03/30/2013 03:49 PM, Josh wrote:
Sorry, I misread, I thought the xml files were the compiled
bits. When I
ran glib-compile-schemas.exe
On Saturday, 30 March 2013 at 16:17:22 UTC, Mike Wey wrote:
On 03/30/2013 03:49 PM, Josh wrote:
Sorry, I misread, I thought the xml files were the compiled
bits. When I
ran glib-compile-schemas.exe, I get the following:
warning: Schema 'org.gnome.system.proxy' has path
On Saturday, 30 March 2013 at 14:45:07 UTC, Josh wrote:
On Saturday, 30 March 2013 at 13:19:03 UTC, Mike Wey wrote:
On 03/30/2013 05:25 AM, Josh wrote:
This is the code causing the problem:
class myInputDialog : Dialog
...
this()
{
super("Please enter file location...&q
On Saturday, 30 March 2013 at 13:19:03 UTC, Mike Wey wrote:
On 03/30/2013 05:25 AM, Josh wrote:
This is the code causing the problem:
class myInputDialog : Dialog
...
this()
{
super("Please enter file location...", this,
GtkDialogFlags.MODAL |
GtkDialogFlags.DESTROY_W
GtkD 2.0
Anyone know why this is happening? If I comment out the
addOnClicked(&findFile) bit, findFile never runs and the problem
doesn't happen, except I can't browse for files.
Thanks,
Josh
(d; dirEntries("F:", SpanMode.shallow))
{
write(d.name ~ "\t");
writeln(d.isDir());
}
}
Output:
false
false
false
false
true
true
true
true
F:\folder true
F:\folder true
Is anybody able to explain why a DirEntry can't seem to detect
whether a directory is in fact a directory, whereas plain isDir
and even a DirEntry inside dirEntries can?
Thanks,
Josh
On Saturday, 2 February 2013 at 11:16:50 UTC, FG wrote:
On 2013-02-02 07:49, Josh wrote:
But main's first writeln actually outputs after f.close().
Maybe because of output buffering and you need to add flush?
How do I do that? I've never heard of flush before.
The program uses ~
50MB according to memSize. Any attempts to call the GC do
nothing, but I'm probably doing it wrong though. Is it possible
that I have a memory leak somewhere that is causing this delay,
or is this a DMD problem, or something else I haven't even
thought of?
DMD v2.060, Windows 7 x64
Thanks,
Josh
On Wednesday, 23 January 2013 at 15:00:16 UTC, bearophile wrote:
A possible solution: desugar the foreach range iteration
protocol of dirEntries and wrap the relevant method with a
try-catch.
Sorry, could you explain that a little? I'm not sure what desugar
means :/
enied." when it gets to
C:\Documents and Settings. On Windows 7 that doesn't actually
exist, which is fine. What I'd like it to do is tell me that it
doesn't exist, but continue iterating anyway. I've tried
try-catch, but that just stops the iteration.
Any help is appreciated. Thanks :)
Josh
Is there a way to do that? I've tried
getenv("PROCESSOR_ARCHITECTURE") and shell("echo
%PROCESSOR_ARCHITECTURE%"), and both of them return "x86" instead
of "AMD64" like cmd. I want to use this to run a 64 bit version
of an external program if the OS is 64 bit, and the 32 bit
version if not.
I'm trying to make an installer application in D. I've checked
with various hashes and the file it's outputting is different to
the original, and therefore Windows is saying it's not a valid
Win32 application. I'm sure it's me doing something wrong and not
DMD's fault. Any help is appreciated.
Jeez. I forgot to add my compile command, here is it:
dfl -release -gui maindialog.d
Hi,
I wanted to give D a try today and port one of my applications to it. I am
currently stuck on this problem:
I have the following 3 files:
maindialog.d - contains the main() function & form creation(using dfl and
Entice Designer)
private {
import dfl.all;
import common.Globals;
}
Globals
74 matches
Mail list logo