On Sunday, 19 August 2018 at 12:10:08 UTC, kinke wrote:
I think the spec is pretty clear; the elements of the
right-hand-side initializer array are interpreted as
per-element initializer, i.e., `result[0] = 2, result[1] = 1`
(rest: default-init).
I can't find where in the spec it says that
I have a two dimensional static array in a game board struct and
want to explicitly set the default value for each cell. Now
typing the whole 9x9 array out would be cumbersome and I can't
change the default constructor of a struct, so I played around
with initializers and found some... strange
On Thursday, 2 August 2018 at 08:30:05 UTC, Greatsam4sure wrote:
I know D is very powerful from my little experience. What is
the idiomatic way to get prime numbers say from 1-30 without
using loops(outer and inner loop). Can map, filter, fold etc in
algorithm be use. Pls show some code with
On Thursday, 14 June 2018 at 11:31:50 UTC, Robert M. Münch wrote:
Is this possible? I read about Inputranges, took a look at the
RBTree code etc. but don't relly know/understand where to start.
You can also use opApply to iterate over a tree using foreach,
see:
On Friday, 1 June 2018 at 21:18:25 UTC, IntegratedDimensions
wrote:
If one has a switch of N case then the last cost surely does
not cost N times the cost of the first, approximately?
It depends on the compiler and optimization level. In general, no
optimization or just a handful of cases
On Monday, 21 May 2018 at 17:42:19 UTC, Jonathan M Davis wrote:
On Monday, May 21, 2018 15:00:09 Dennis via Digitalmars-d-learn
wrote:
drop is range-based, so if you give it a string, it's going to
decode because of the whole auto-decoding mess with
std.range.primitives.front and popFront
On Thursday, 17 May 2018 at 21:10:35 UTC, Dennis wrote:
It's unfortunate that Phobos tells you 'there's problems with
the encoding' without providing any means to fix it or even
diagnose it.
I have to take that back since I found out about std.encoding
which has functions like `sanitize`,
On Monday, 21 May 2018 at 11:38:12 UTC, SrMordred wrote:
what??
Here's another weird example:
```
void funWithUfcsAndPropertySyntax() {
import std.typecons : tuple;
"%s %s".writefln = ("foo".tuple = "bar").expand;
}
```
source:
On Wednesday, 16 May 2018 at 10:30:34 UTC, Jonathan M Davis wrote:
For various reasons, that doesn't always hold true like it
should, but pretty much all of Phobos is written with that
assumption and will generally throw an exception if it isn't.
It's unfortunate that Phobos tells you
On Wednesday, 16 May 2018 at 15:47:29 UTC, Jon Degenhardt wrote:
If you write it in the style of my earlier example and use
counters and if-tests it will work. byLine by itself won't try
to interpret the characters (won't auto-decode them), so it
won't trigger an exception if there are invalid
On Wednesday, 16 May 2018 at 08:20:06 UTC, drug wrote:
What is the purpose of `.drop(4)`? I'm pretty sure this is the
reason of the exception.
The file in question is a .json database dump with an array
"rows" of 10 million 8-line objects. The newlines in the string
fields are escaped, but
On Wednesday, 16 May 2018 at 08:20:06 UTC, drug wrote:
What is the purpose of `.drop(4)`? I'm pretty sure this is the
reason of the exception.
The file in question is a .json database dump with an array
"rows" of 10 million 8-line objects. The newlines in the string
fields are escaped, but
On Wednesday, 16 May 2018 at 02:47:50 UTC, Jon Degenhardt wrote:
Can you show the program you are using that throws when using
byLine?
Here's a version that only outputs the first chunk:
```
import std.stdio;
import std.range;
import std.algorithm;
import std.file;
import std.exception;
void
I have a file with two problems:
- It's too big to fit in memory (apparently, I thought 1.5 Gb
would fit but I get an out of memory error when using
std.file.read)
- It is dirty (contains invalid Unicode characters, null bytes in
the middle of lines)
I want to write a program that splits it
On Sunday, 15 April 2018 at 12:04:19 UTC, vladdeSV wrote:
How would I go on about to print all the arguments as I
expected it, using "%s"?
You can expand the template arguments into an array by putting it
into square brackets: [args]. You can format an array with the
default notation using
On Monday, 2 April 2018 at 14:51:57 UTC, Vladimirs Nordholm wrote:
Do you think I should I omit the @property tag, if the only
wanted behaviour is to set a value (`foo.bar = "baz";`) ?
You're probably fine either way, it's mostly for making your
intention clear. Jonathan M Davis made a great
On Monday, 2 April 2018 at 13:57:14 UTC, Vladimirs Nordholm wrote:
Is there any reason for me to add the @property tags for the
method?
A list of things the @property tag does can be found here:
https://dlang.org/spec/function.html#property-functions
This behavior is particularly useful for
On Thursday, 29 March 2018 at 15:16:07 UTC, Ivan Kazmenko wrote:
So, why do delegates of guns[] and huns[] all return 1, and how
to correctly reproduce the behavior of funs[] while populating
it in a loop?
A delegate is a function with a pointer to the stack frame where
it was created. It
On Wednesday, 21 March 2018 at 13:26:48 UTC, HeiHon wrote:
I added exclusions for the folder, where I installed dmd and
ldc and I added an exclusion for the folder, where I compile my
D programs. Now startup of dmd and freshly compiled programs is
fast again.
I've done this too now, thanks
On Tuesday, 20 March 2018 at 12:18:16 UTC, Adam D. Ruppe wrote:
On Tuesday, 20 March 2018 at 09:44:41 UTC, Dennis wrote:
I suspect you are seeing the Windows antivirus hitting you. D
runtime starts up in a tiny fraction of a second, you shouldn't
be noticing it.
You're totally right,
On Tuesday, 20 March 2018 at 10:20:55 UTC, Dennis wrote:
On Tuesday, 20 March 2018 at 09:51:09 UTC, bauss wrote:
Besides if it was and it took 1 second to startup, then it
wouldn't matter in practice with an actual application.
This is not concerning for large applications indeed. But say,
I
On Tuesday, 20 March 2018 at 09:51:09 UTC, bauss wrote:
Besides if it was and it took 1 second to startup, then it
wouldn't matter in practice with an actual application.
This is not concerning for large applications indeed. But say, I
want to implement my own `dir` (= `ls` on Unix) in D.
Simply running a "hello world.exe" takes, on my pc:
1.12s When compiled with dmd
0.62s When compiled with ldc
0.05s When compiled with dmc (C program) or dmd/ldc as a -betterC
program
I suppose initializing the runtime takes a lot of time. When
making a simple command line utility, half a
On Sunday, 18 March 2018 at 22:57:15 UTC, aliak wrote:
// But you get a:
// Error: Using the result of a comma expression is not
allowed
// writeln(mixin(arguments!f));
You can't mix part of a function call in: "Mixed in text must
form complete declarations, statements, or
On Friday, 9 February 2018 at 20:19:33 UTC, Dennis wrote:
I'd still like to find a nice way to generate the boilerplate
code for dynamic loading, if I come up with something I'll post
it here.
So I ended up using an import library for a while, but I then
wanted to get the handle of the DLL,
I was making a stack interface for an array:
```
struct Stack(T) {
import std.array: empty;
T[] stack;
alias stack this;
}
void main()
{
Stack!int stack;
bool x = stack.empty;
}
```
My expectation is that you can now call `empty` on a stack
instance since I imported it in
I recently tried to go to that site, and I tried `run.dlang.com`
which is the wrong URL. So I was looking through the D homepage
for the right link but couldn't find it. Even a Google search for
"online d compiler" or "run dlang online" didn't turn up anything
directly, I had to go through the
On Friday, 9 February 2018 at 18:14:06 UTC, Mike Wey wrote:
You may need to pass `/s` to implib so it will add the
underscore to the symbol in the import library. If it's
actually needed depends on what the dll uses.
That did it, now both dynamic loading and dynamic linking work.
:) Thanks
On Friday, 9 February 2018 at 14:51:30 UTC, Mike Parker wrote:
Where was the lib file located? Was it in the root project
directory? How are you compiling your project? What does your
directory tree look like?
(...)
That depends. Is that the directory where your executable is
written? Are you
I read the Derelict documentation a while ago, I didn't grasp all
of it. Reading it again, I can now make sense of it though. :)
On Friday, 9 February 2018 at 12:53:44 UTC, Mike Parker wrote:
Did you link with the library you created with implib? That
linker error suggests you didn't.
I
I want to bind to a .dll on Windows, so I looked at how Derelict
packages are doing it and found it does it like this:
```
extern(C) {
alias da_CoreGetAPIVersions = m64p_error
function(int*,int*,int*,int*);
...
}
__gshared {
da_CoreGetAPIVersions CoreGetAPIVersions;
...
}
protected
Ah, so it's about lvalues an rvalues, not the type of the range.
Makes sense now.
On Tuesday, 26 December 2017 at 22:33:54 UTC, WebFreak001 wrote:
BigEndian is default btw, you don't need to specify that but
you can if you want.
Dealing with Endianness bugs has been such a pain, I like to be
I was trying to translate this kind of C code to D:
void calc(unsigned char *buf) {
(...)
res = read_u32_be([i]);
}
So I tried this:
import std.bitmanip : read, Endian;
void calc(ubyte[] buf) {
(...)
res = read!(uint, Endian.bigEndian)(buf[i..$]);
}
But then I get this error:
template
Thanks for your reply, that clears it up.
On Monday, 11 December 2017 at 21:13:11 UTC, Steven Schveighoffer
wrote:
3. Stop using Windows ;)
Haha, if only the rest of the userbase would follow.
I'm on Windows and I recently got confused by how Phobos
functions handle newlines.
```
void main() {
import std.stdio;
import std.path : buildPath, tempDir;
auto path = buildPath(tempDir(), "test.txt");
auto file = new File(path, "w");
file.write("hello there!\n");
On Saturday, 18 November 2017 at 14:15:21 UTC, Mike Parker wrote:
The proper place to report this sort of issue is at the
DerelictGL3 issues page [1]. You'll also want to include some
minimal, reproducible sample code.
Okay, I've made an issue:
I'm trying to set up a game window with Derelict glfw and opengl.
When I perform a default (debug) build, it correctly shows a
window, but when I do this:
dub run "--build=release"
Then I get this:
object.Error@(0): Access Violation
0x00443BCF
0x00425164
0x00418545
0x00418874
thank you all! i will try
Hi,
try to build a little programm, but need to know
how to check the input.
For example: input only numbers: 0 - 9 but 1.5 for example is ok.
thanks
301 - 339 of 339 matches
Mail list logo