Hello. Dlang newbie here.
Does D support run-time loading of D modules?
Basically, I'm looking to create an application with a plugin
interface.
I've seen a few posts, but they're dated and it's hard to keep up
with "What is the proper way to do X" when things change rapidly.
Last thing I
On Monday, 29 February 2016 at 22:12:37 UTC, jmh530 wrote:
On Monday, 29 February 2016 at 19:02:27 UTC, Chris Katko wrote:
Hello. Dlang newbie here.
Does D support run-time loading of D modules?
Basically, I'm looking to create an application with a plugin
interface.
I've seen a few posts,
Hello. I'm almost brand-new to the D language and still absorbing
things.
I'm wondering if it's possible to fire off a compile-time (or
worst case, a run-time) warning or error if a function is called,
but the return value is not checked.
I'm not trying to enforce whether someone actually
On Thursday, 18 February 2016 at 10:46:03 UTC, Marc Schütz wrote:
On Thursday, 18 February 2016 at 07:21:05 UTC, Chris Katko
wrote:
[...]
As Jonathan said, there's no such built-in feature, and
exception are preferred over return codes. However, you can
implement such a check at run time:
I have an idea for something. I know I can't be the only one to
think this way but I can't find very much information on it.
Basically, I want compile-time enforcement of semantic rules.
For one example--I asked previously here--if it was possible to
generate a compile-time warning or error
Can I pass a type, instead of a variable of a type, to a template
function in order to decide the datatype of T in a function?
void function(T)(T x) //works
{
T data;
//do stuff with T, ignoring x.
}
void function2(T)() //hypothetical, specify the type... somehow?
{
T
Addendum:
Writing the following:
writeln(mixin(sizer2D!()));
simply dumps 64 to stdout.
What's going on here? Have I run into a compiler bug?
Thank you!
So:
1 - Is there any way TO get the output 64,64? It seems like being
able to get a comma out of a mixin is a useful feature.
2 - Is this very non-standard / unrecommended practice and
there's a much better way to do this?
For example, in my actual code, I have an enumerator:
I've tried to narrow this down to the minimum code that exhibits
the problem.
When I use a mixin, to supply the parameters for a template, it
works with ONE argument, but NOT TWO.
template sizer2D() // no params here for simplicity
{
const char [] sizer2D = "64,64";
Is there any way to get a warning anytime an implicit super
constructor is called in a sub-class/child-class?
I have game objects with defaults. I specialize them with
specifics. The problem is, if I forget to add an explicit super
call and have it _before_ my code, my code runs, then the
On Thursday, 21 December 2017 at 06:47:25 UTC, Ali Çehreli wrote:
On 12/20/2017 10:36 PM, Chris Katko wrote:
[...]
There can be a number of solutions but can you please
demonstrate the issue with compilable code? My attempt does not
agree with your description: super() is called *before*
I'm having a strange stuttering issue in my game prototype. I use
GC allocations wildly for the heck of it at the moment--with
eventual plans to remove them.
However, I'm not positive it's the GC that's the problem, and if
so, I want to know exact lengths of time and frequency.
Currently,
On Saturday, 23 December 2017 at 12:23:33 UTC, Johan Engelen
wrote:
On Friday, 22 December 2017 at 09:52:26 UTC, Chris Katko wrote:
DMD can use -profile and -profile=gc. But I tried for HOURS to
find the equivalent for LDC and came up with only
profile-guided optimization--which I don't
On Thursday, 21 December 2017 at 10:49:46 UTC, Dan Partelly wrote:
I started to look into D very recently. I would like to know
the following, if you guys are so nice to help me:
1. What is the performance of D's GC, what trade-offs where
done in design , and if a in-deep primer on
On Thursday, 21 December 2017 at 10:13:47 UTC, bauss wrote:
On Thursday, 21 December 2017 at 06:47:25 UTC, Ali Çehreli
wrote:
[...]
This is what I would believe __IS__ and __SHOULD__ be the
default behavior too, because that's how it generally is in
other languages.
It doesn't make much
DMD can use -profile and -profile=gc. But I tried for HOURS to
find the equivalent for LDC and came up with only profile-guided
optimization--which I don't believe I want. Yet, if we can get
PGO... where's the PROFILE itself it's using to make those
decisions! :)
Thanks.
I googled but couldn't find any clear solution.
I've got a 2-D array of strings read from a text file I parsed.
So it's like
0 1 15 0 0
2 12 1 0 0
...
0 1 0 10 0
They come in with spaces, so I join into an array between them.
But then the last ones have a newline \n on the end, which
On Thursday, 12 April 2018 at 15:47:14 UTC, Uknown wrote:
On Thursday, 12 April 2018 at 15:38:34 UTC, Chris Katko wrote:
I googled but couldn't find any clear solution.
I've got a 2-D array of strings read from a text file I
parsed. So it's like
0 1 15 0 0
2 12 1 0 0
...
0 1 0 10 0
They
On Thursday, 12 April 2018 at 21:17:30 UTC, Paul Backus wrote:
On Thursday, 12 April 2018 at 20:34:40 UTC, Chris Katko wrote:
But each doesn't return anything, it mutates, right? I think
that's the problem I ran into with my attempt. With your code,
I get an error about void:
string []x
Wait, that might not be the error.
On Thursday, 12 April 2018 at 20:37:49 UTC, Chris Katko wrote:
Wait, that might not be the error.
Just the top one. This one:
extra.d(2493): Error: template std.algorithm.iteration.each
cannot deduce function from argument types !()(string[], void),
candidates are:
On Monday, 9 April 2018 at 00:25:21 UTC, solidstate1991 wrote:
On Saturday, 24 February 2018 at 07:12:21 UTC, Guillaume Piolat
wrote:
From my experience a combination of the following is necessary:
- not having the audio thread registered
- using pools aggressively for game entities
Also you
I need to rotate an array by 90 degrees, or have writefln figure
that out.
I need, say:
0 4 5 6
0 0 0 0
0 0 0 0
0 0 0 0
But it's outputting:
0 0 0 0
4 0 0 0
5 0 0 0
6 0 0 0
int [4][4] data;
file.writeln(format("%(%-(%d %)\n%)", data));
On Wednesday, 18 April 2018 at 07:15:47 UTC, Simen Kjærås wrote:
On Wednesday, 18 April 2018 at 06:54:29 UTC, Chris Katko wrote:
I need to rotate an array by 90 degrees, or have writefln
figure that out.
I need, say:
0 4 5 6
0 0 0 0
0 0 0 0
0 0 0 0
But it's outputting:
0 0 0 0
4 0 0 0
5 0
I'm a complete doxygen newbie. But my first thought when writing
comments is... why not use Markdown? (Which has become almost
universal online these days.)
So I google it and Moxygen comes up. Which seems pretty good.
Oh goodness. I thought D was using Doxygen!
Thanks.
What I want:
class viewport_t
{
int x,y,w,h;
}
class dialog_t
{
int x,y;
this( int x, int y, delegate void (viewport_t) on_draw )
{
this.x = x;
this.y = y;
this.execute = execute;
}
void draw_text(string text)
{
}
delegate void (viewport_t)
Some typos in there.
execute == on_draw.
Basically, I'm just sending a delegate/lambda "custom function"
at initialization time. But I'd like that delegate to somehow
access the holding classes functions. Or figure out how to do
that.
Maybe the class somehow sends the delegate a this
I'm having trouble conceptualizing this issue at the moment. But
it seems if I pass to the delegate my object, then I can ONLY use
one class type.
Say, the delegate takes a "this" from... some class that wants to
have a dialog. A window. Now the delegate NEEDS a this from a
window, and only
That was all pseudo-code typed by hand.
I got my code to work today. I don't know if it's the prettiest
it can be, but it works:
// TESTING ACCESS TO the OWNING function
//---
class test_window
{
float x;
float y;
I'm trying this idea for an API style it's... not quite working.
The part I'm failing at currently is actually classifying types
passed in.
I want this to occur at compile time.
void funct(A...)(A a)
{
static if (a.length)
{
writeln(a[0]);
On Wednesday, 28 March 2018 at 06:20:56 UTC, Ali Çehreli wrote:
On 03/27/2018 11:11 PM, Chris Katko wrote:
> writeln(a[0]); //first is "pos(100,100)"
> static if(
> is(a[0] == pos) //<---never matches
It's because not a[0] but its *type* is pos:
I have a static foreach that goes through the parameter list and
if it sees a class like "rotate", ideally, I want it to mark a
boolean "has_rotate=true"
Then simply later on, once I've parsed the list, I pick an output
path:
static if(has_rotate && has_position && has_scale)
{
On Wednesday, 28 March 2018 at 17:08:39 UTC, Chris Katko wrote:
On Wednesday, 28 March 2018 at 15:49:39 UTC, Chris Katko wrote:
On Wednesday, 28 March 2018 at 15:46:42 UTC, Chris Katko wrote:
[...]
Whoops! Wrong error message. That's if I replace isa(pos) with
IsIntegral.
[...]
Okay,
On Wednesday, 28 March 2018 at 15:49:39 UTC, Chris Katko wrote:
On Wednesday, 28 March 2018 at 15:46:42 UTC, Chris Katko wrote:
[...]
Whoops! Wrong error message. That's if I replace isa(pos) with
IsIntegral.
[...]
Okay, the key appears to be here:
funct2(123); //a function call
void
On Wednesday, 28 March 2018 at 23:42:26 UTC, Simen Kjærås wrote:
On Wednesday, 28 March 2018 at 23:02:53 UTC, Chris Katko wrote:
There's many things that can be done to make the code easier to
follow. These lines:
[...]
[...]
WOW. Thank you. That's the kind of tricks for (or more
On Wednesday, 28 March 2018 at 17:42:45 UTC, Steven Schveighoffer
wrote:
On 3/28/18 11:46 AM, Chris Katko wrote:
enum hasRotate = anySatisfy!( isa(pos), a); //if of type
"pos"
anySatisfy!(isa!pos, a)
anySatisfy takes a template alias (in this case, an
instantiation of isa with a
void start_draw_calls(BITMAP target_bitmap); //locks onto a
resource
void end_draw_calls(); //frees previous resource lock
void my_function()
{
//...
start_draw_calls(target_bitmap) //whether this is a function,
or class, lambda, or a "using"?
{
draw_call1();
On Friday, 30 March 2018 at 03:14:42 UTC, Mike Parker wrote:
On Friday, 30 March 2018 at 02:30:01 UTC, Chris Katko wrote:
[...]
Something like this?
=
import std.stdio;
[...]
This is beautiful. I mean, the struct stuff looks
complicated/non-intuitive at first, but it's all
On Wednesday, 28 March 2018 at 15:46:42 UTC, Chris Katko wrote:
On Wednesday, 28 March 2018 at 08:05:55 UTC, Simen Kjærås wrote:
On Wednesday, 28 March 2018 at 07:45:59 UTC, Chris Katko wrote:
I have a static foreach that goes through the parameter list
and if it sees a class like "rotate",
On Wednesday, 28 March 2018 at 08:05:55 UTC, Simen Kjærås wrote:
On Wednesday, 28 March 2018 at 07:45:59 UTC, Chris Katko wrote:
I have a static foreach that goes through the parameter list
and if it sees a class like "rotate", ideally, I want it to
mark a boolean "has_rotate=true"
Then
On Sunday, 14 October 2018 at 03:26:33 UTC, Adam D. Ruppe wrote:
On Sunday, 14 October 2018 at 03:07:59 UTC, Chris Katko wrote:
For comparison, I just tested and grep uses about 4 MB of RAM
to run.
Running and compiling are two entirely different things.
Running the D regex code should be
int [50]data;
foreach(i, datum; data){} // works
File file("gasdgasd");
foreach(i, line; file.byLine){} //NOPE.
foreach(line; file.byLine){} //works.
I finally noticed in the docs it says "for arrays only." The
question is, why?
Every language that I used previously (as far as I can
On Wednesday, 17 October 2018 at 07:32:37 UTC, aliak wrote:
Hi,
Is there any notion of lazy vars in D (i see that there're
parameters)?
i.e:
struct S {
//...
int y;
//...
}
lazy S x = () {
// do some heavy stuff
}();
if (condition) {
func(x.y); // heavy stuff evaluated here
}
On Friday, 12 October 2018 at 13:42:34 UTC, Alex wrote:
On Friday, 12 October 2018 at 13:25:33 UTC, Chris Katko wrote:
Like, insanely fat.
All I wanted was a simple regex. The second include a regex
function, my program would no longer compile "out of memory
for fork".
/usr/bin/time -v
Like, insanely fat.
All I wanted was a simple regex. The second include a regex
function, my program would no longer compile "out of memory for
fork".
/usr/bin/time -v reports it went from 150MB of RAM for D,
DAllegro, and Allegro5.
To over 650MB of RAM, and from 1.5 seconds to >5.5
On Sunday, 14 October 2018 at 02:44:55 UTC, Chris Katko wrote:
On Friday, 12 October 2018 at 13:42:34 UTC, Alex wrote:
[...]
So wait, if their solution was to simply REMOVE std.regex from
isEmail. That doesn't solve the regex problem at all. And from
what I read in that thread, this penalty
Simple curious question.
Why isn't :
import std.stdio;
instead:
import std.io;
(Also, while we're at it. Why doesn't this form have code
highlighting? It would much improve readibility. Doesn't that
seem almost essential for a programming forum?)
I mean, I get it. stdio is the c header
On Saturday, 10 November 2018 at 13:53:14 UTC, Kagamin wrote:
On Friday, 9 November 2018 at 09:11:37 UTC, Jonathan M Davis
wrote:
No, I didn't. I just used underscores, which has been used
with plain text for emphasis for decades. Supporting markdown,
would involve stuff like backticks for
On Friday, 9 November 2018 at 09:11:37 UTC, Jonathan M Davis
wrote:
On Friday, November 9, 2018 1:27:44 AM MST Kagamin via
Digitalmars-d-learn wrote:
On Friday, 9 November 2018 at 06:42:37 UTC, Jonathan M Davis
wrote:
> [...]
You used markdown three times in your message.
No, I didn't. I
I've got this simple task but I'm trying to perfect it as best I
can to learn something in the process.
I have Linux terminal ASCII codes for coloring terminal output.
string red(string) { /* ... */ }
"Hello world".red => "\033[31mHello World\033[0m"
which translates to "[red]Hello
I have a 2-D array:
int[5][5] data =
[
[1, 0, 1, 0, 0],
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 0, 0, 1, 0],
[1, 1, 1, 1, 0]
];
1 - Is there a way to foreach vertically through that? (that is,
On Tuesday, 9 October 2018 at 10:52:47 UTC, Chris Katko wrote:
I have a 2-D array:
int[5][5] data =
[
[1, 0, 1, 0, 0],
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 0, 0, 1, 0],
[1, 1, 1, 1, 0]
];
1 - Is
On Wednesday, 3 October 2018 at 00:34:33 UTC, Adam D. Ruppe wrote:
On Wednesday, 3 October 2018 at 00:14:03 UTC, Chris Katko wrote:
Except it doesn't work and tries to decode col.width-1 into a
hexadecimal number and only prints that. ("4D6EF6")
That number certainly isn't col.width (unless
- First, I'm confused. The docs say 's' is "whatever it needs to
be". ("he corresponding argument is formatted in a manner
consistent with its type:") But what if I specifically want a
STRING. Because I only see floats, ints, etc. No forced string
types.
- Second,
This works fine in D:
int[][] data =
[
[1, 0, 1, 0, 0],
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 0, 0, 1, 0],
[5, 1, 1, 1, 0]
];
when drawn with data[i][j], prints the transpose of "data":
[1, 1, 1, 1, 5]
[0, 0, 0, 0, 1]
[1,
On Wednesday, 10 October 2018 at 16:00:42 UTC, Steven
Schveighoffer wrote:
On 10/10/18 9:22 AM, Chris Katko wrote:
int[][] data =
[
[1, 0, 1, 0, 0],
[1, 0, 1, 0, 0],
[1, 0, 1, 1, 1],
[1, 0, 0, 1, 0],
[5, 1, 1, 1, 0]
];
when drawn with
On Wednesday, 3 October 2018 at 11:51:01 UTC, Sebastiaan Koppe
wrote:
On Wednesday, 3 October 2018 at 11:01:53 UTC, Chris Katko wrote:
[...]
A combination of static introspection with string mixins does
the trick:
---
enum colors {
reset = "\033[0m",
red = "\033[31m"
}
auto
On Thursday, 4 October 2018 at 08:52:28 UTC, Andrea Fontana wrote:
On Thursday, 4 October 2018 at 08:32:13 UTC, Chris Katko wrote:
I've been Google'ing and there's like... nothing out there.
One of the top results for "std.socket dlang examples"... is
for TANGO. That's how old it is.
Socket
I've been Google'ing and there's like... nothing out there.
One of the top results for "std.socket dlang examples"... is for
TANGO. That's how old it is.
On Wednesday, 23 November 2016 at 08:47:56 UTC, Christian Köstlin
wrote:
On 03/03/2012 18:35, Timon Gehr wrote:
On 03/03/2012 12:09 PM, Nicolas Silva wrote:
[...]
Yes, this seems to be a bug.
Workaround:
struct Foo{
string s;
Tid id;
}
void foo(){
Foo foo;
On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh wrote:
On Monday, 3 September 2018 at 03:04:57 UTC, Chris Katko wrote:
This should be simple? All I want to do is load an entire
file, and access individual bytes. The entire thing. I don't
want to have know the file size before hand,
On Monday, 3 September 2018 at 06:28:38 UTC, bauss wrote:
On Monday, 3 September 2018 at 06:25:23 UTC, bauss wrote:
On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh
wrote:
On Monday, 3 September 2018 at 03:04:57 UTC, Chris Katko
wrote:
This should be simple? All I want to do is load
On Monday, 3 September 2018 at 07:38:51 UTC, Chris Katko wrote:
On Monday, 3 September 2018 at 06:28:38 UTC, bauss wrote:
On Monday, 3 September 2018 at 06:25:23 UTC, bauss wrote:
On Monday, 3 September 2018 at 03:19:39 UTC, Neia Neutuladh
wrote:
On Monday, 3 September 2018 at 03:04:57 UTC,
This should be simple? All I want to do is load an entire file,
and access individual bytes. The entire thing. I don't want to
have know the file size before hand, or "guess" and have a
"maximum size" buffer.
So far, all google searches for "dlang binary file read" end up
not working for me.
On Thursday, 20 September 2018 at 05:51:17 UTC, Neia Neutuladh
wrote:
On Thursday, 20 September 2018 at 05:34:42 UTC, Chris Katko
wrote:
All I want to do is loop from 0 to [constant] with a for or
foreach, and have it split up across however many cores I have.
You're looking at
All I want to do is loop from 0 to [constant] with a for or
foreach, and have it split up across however many cores I have.
ulong sum;
foreach(i; [0 to 1 trillion])
{
//flip some dice using
float die_value = uniform(0F,12F);
if(die_value > [constant]) sum++;
On Saturday, 22 September 2018 at 02:26:41 UTC, Chris Katko wrote:
On Saturday, 22 September 2018 at 02:13:58 UTC, Chris Katko
wrote:
On Friday, 21 September 2018 at 12:15:59 UTC, Ali Çehreli
wrote:
On 09/21/2018 12:25 AM, Chris Katko wrote:
[...]
You can use a free-standing function as a
On Monday, 24 September 2018 at 07:13:24 UTC, Chris Katko wrote:
On Monday, 24 September 2018 at 05:59:20 UTC, Chris Katko wrote:
[...]
Actually, I just realized/remembered that the error occurs
inside parallelism itself, and MANY times at that:
[...]
This JUST occurred to me.
On Monday, 24 September 2018 at 05:59:20 UTC, Chris Katko wrote:
On Saturday, 22 September 2018 at 02:26:41 UTC, Chris Katko
wrote:
On Saturday, 22 September 2018 at 02:13:58 UTC, Chris Katko
wrote:
On Friday, 21 September 2018 at 12:15:59 UTC, Ali Çehreli
wrote:
On 09/21/2018 12:25 AM, Chris
On Saturday, 22 September 2018 at 02:13:58 UTC, Chris Katko wrote:
On Friday, 21 September 2018 at 12:15:59 UTC, Ali Çehreli wrote:
On 09/21/2018 12:25 AM, Chris Katko wrote:
[...]
You can use a free-standing function as a workaround, which is
included in the following chapter that explains
On Friday, 21 September 2018 at 12:15:59 UTC, Ali Çehreli wrote:
On 09/21/2018 12:25 AM, Chris Katko wrote:
On Thursday, 20 September 2018 at 05:51:17 UTC, Neia Neutuladh
wrote:
On Thursday, 20 September 2018 at 05:34:42 UTC, Chris Katko
wrote:
All I want to do is loop from 0 to [constant]
Any time I see people mention the benefits of D, I see "compile
times" "compile times" "compile times" over and over.
I'm using very modest amounts of templates, for a fairly small
sized program (very early work toward a game), and I'm hitting
~15 seconds compile time in LDC and ~7 seconds in
On Friday, 23 November 2018 at 10:00:17 UTC, Nicholas Wilson
wrote:
If you pass all the files on the command line then they all get
(re)compiled.
How are you supposed include files if not passing them to the
compiler?
I'm only using std.regex in one file, IIRC, so whatever the
"proper"
Try to learn D.
Put writeln in deconstructor to prove it works as expected
Make random changes, program never runs again.
Takes 30+ minutes to realize that writeln("my string") is fine,
but writeln("my string " ~ value) is an allocation / garbage
collection which crashes the program without a
On Saturday, 24 November 2018 at 20:44:57 UTC, welkam wrote:
On Friday, 23 November 2018 at 08:57:57 UTC, Chris Katko wrote:
D is supposed to compile fast.
You didnt read the fine print. It compiles simple code fast.
Also compilation is separate step from linking and your program
might
What's the easiest way to use POSIX and Linux-specific C include
files?
I know you can write a wrapper but it seems like half the time
these files include 20 files which include 20 files which use
strange enums, arrays, etc that don't clearly have answers on how
to wrap them.
Is there
You can drop this straight into run.dlang.io:
import std.stdio;
class base{ float x=1;}
class child : base {float x=2;} //shadows base variable!
void main()
{
base []array;
child c = new child;
array ~= c;
writeln(c.x); //=2
writeln(array[0].x); //=1 //uses BASE's
On Sunday, 12 January 2020 at 13:58:18 UTC, Per Nordlöw wrote:
Is there a druntime/phobos function for getting the amount of
memory (both, stack, malloc, and GC) being used by the current
process?
Valgrind will tell you the exact usage (except no delineation for
GC) per here:
When I program, it's usually videogame ideas. That implies a
soft, real-time requirement. In general, that requires the mantra
"allocations are evil, use object pools whenever possible."
[storing data in static arrays and 'deleting' is usually just
marking an entry as is_deleted=true and
Thanks everyone, looks like i'll have to benchmark myself (which
is fine) but I'm always afraid because I know "proper
benchmarking is hard. (TM)"
Feel free to throw any other side advice in. I'm looking to get a
broad perspective on this.
Straight up shutting off the garbage collector in
On Wednesday, 8 January 2020 at 06:51:57 UTC, H. S. Teoh wrote:
On Wed, Jan 08, 2020 at 04:40:02AM +, Guillaume Lathoud via
Digitalmars-d-learn wrote:
[...]
[...]
Generally, the recommendation is to separately compile each
package. E.g., if you have a source tree of the form:
I'm making anagrams. According to the nextPermutation() docs, I
need to 'sort by less' to get all permutations. ... Except the
doc page doesn't mention how to do that, nor does
std.algorithm.sort show how to sort a string. ... and the google
results on the dlang forums from 2017 don't work.
On Friday, 1 May 2020 at 08:17:33 UTC, norm wrote:
On Friday, 1 May 2020 at 07:38:53 UTC, Chris Katko wrote:
[...]
You need to convert the sort output to dchar[], e.g.
---
dchar[] line3 = sort(line2.to!(dchar[])).to!(dchar[]);
---
Cheers,
Norm
That works, thanks!
I'm debugging some code I wrote back in 2017 and a bounding box
collision detection kept giving spurious answers till I resorted
to assuming nothing and dumped every variable and alias.
I kept getting results like it was checking against itself, and
of course, that would result in finding a
Is there any automatic compiler-based or library methods for
detecting NaNs? I mean, if the compiler is outputting code that
it knows is going to be set in memory to NaN, why isn't it giving
me at least a compiler warning? Is that some sort of "NP
complete" can't-fix issue or something?
I
On Friday, 17 September 2021 at 10:29:12 UTC, bauss wrote:
On Friday, 17 September 2021 at 09:44:53 UTC, Chris Katko wrote:
[...]
It's not a bug because "obj.x" referes to the same symbol that
is "this.x"
Alias will create an alias for a symbol, not an expression or
the like.
So
obj.x
there's:
```d
import core.thread;
Thread.sleep( dur!("msecs")(10) );
```
but what if you want to simply yield all remaining time back to
the time scheduler?
Is there a D std.library accessible version of POSIX sched_yield:
https://man7.org/linux/man-pages/man2/sched_yield.2.html
It
All I want:
```d
string ip_address = "192.168.1.1";
auto x = new InternetAddress( ip_string, "8008");
```
```d
source/app.d(161,16): Error: none of the overloads of `this` are
callable using argument types `(string, int)`
/usr/include/dmd/phobos/std/socket.d(1472,5):Candidates
are:
On Sunday, 5 December 2021 at 16:32:16 UTC, rikki cattermole
wrote:
The string is not the problem.
```d
string ip_address = "192.168.1.1";
auto x = new InternetAddress(ip_address, 8008);
```
That works.
A string in D is an alias for immutable(char)[]. This is
defined in druntime (object.d).
Running 64-bit Linux
```
dmd --version
DMD64 D Compiler v2.098.0-beta.2
dub --version
DUB version 1.27.0-beta.2, built on Sep 7 2021
```
the following code 'compiles' in one project.
```d
unittest
{
gasdindgaslkdgansklnasgdlknaglkgansklsdg;
}
void main(){} // compiles, links, and 'runs unit
Using DMD. v2.098-beta-2
Not sure if right terminology. But I just wrote a nested function
that uses a variable outside its body. The capture (right term?)
is obvious where the invocation is. However, I have to move the
declaration of the variable to above the nested function for it
to
D
struct map_t{
int data[50][50];
} map;
//save
std.file.write("save.map", map.data); // compiles
//load
map.data = std.file.read("save.map", map.data.sizeof); // error
main.d(536): Error: cannot implicitly convert expression
`read("save.map", 2500LU)` of type `void[]` to `ubyte[50][]`
D
struct pair
{
float x,y;
}
alias sPair = Typedef!pair; // pair of xy in screen space
coordinates
alias vPair = Typedef!pair; // pair of xy in viewport space
coordinates
//etc
void test()
{
pair v0 = pair(1f, 2f); // works fine, but what about the
typedefs?
vPair v1 = vPair(1f, 2f);
On Monday, 25 April 2022 at 12:53:14 UTC, Mike Parker wrote:
On Monday, 25 April 2022 at 08:54:52 UTC, Chris Katko wrote:
D
struct pair
{
float x,y;
}
alias sPair = Typedef!pair; // pair of xy in screen space
coordinates
alias vPair = Typedef!pair; // pair of xy in viewport space
I swear I asked something like this before years ago but it
doesn't show up in my previous forum posts.
I'm looking for a construct that mimics using(var)/with(var)
D
bitmap* b;
draw_with(b)
{
draw_pixel(red, 16, 16); //draw red pixel to bitmap b (b is
implied above)
}
But
I have an intrinsicGraph(T) class that is given a pointer to a T
dataSource and automatically polls that variable every frame to
add it to the graph, whether it's a float, double, integer, and
maybe bool.
This all works fine if you have a single template type. But what
if I want ... multiple
On Friday, 13 May 2022 at 07:05:36 UTC, vit wrote:
On Friday, 13 May 2022 at 06:43:39 UTC, Chris Katko wrote:
I have an intrinsicGraph(T) class that is given a pointer to a
T dataSource and automatically polls that variable every frame
to add it to the graph, whether it's a float, double,
given
```D
struct COLOR
{
float r, g, b, a; // a is alpha (opposite of transparency)
}
auto red = COLOR(1,0,0,1);
auto green = COLOR(0,1,0,1);
auto blue = COLOR(0,0,1,1);
auto white = COLOR(1,1,1,1);
//etc
```
is there a way to do:
```D
auto myColor = GREY!(0.5);
// where GREY!(0.5) becomes
D
struct pair
{
float x,y;
}
myFunction(float taco, float x, float y, float burrito)
{
// stuff
}
myfunction(_taco, _x, _y, _burrito); // call function
// But can we do this?
pair p;
myfunction(_taco, p; _burrito); // p becomes (x,y) and satisfies
the two floats in the signature
1 - 100 of 135 matches
Mail list logo