On Sunday, 7 February 2021 at 14:13:18 UTC, vitamin wrote:
Why using 'new' is allowed in pure functions but calling
GC.addRange or GC.removeRange isn't allowed?
pure is broken. Just don't [use it]
On Sunday, 5 January 2020 at 22:39:37 UTC, Teo wrote:
On Sunday, 5 January 2020 at 13:37:58 UTC, JN wrote:
[...]
Thanks for the input.
I just realized that I was not precise enough in my
description. Apologies for that.
My intention is to use std.algorithm, if possible.
I read the documenta
Lol, you don't have to load and unload the curl dll.
std.net.curl have its own lazy libcurl loader. But i'm not sure
if it tries to find the dll in the temp directory. If it is the
case, then it simply doesn't unload the dll when you have called
some function from it.
On Tuesday, 6 February 2018 at 08:29:05 UTC, Kagamin wrote:
On Monday, 5 February 2018 at 15:33:02 UTC, Steven
Schveighoffer wrote:
Is there a more pragmatic use case why this should be possible?
Maybe for least surprise. The error message almost convinced me
that such cast is impossible, onl
On Monday, 25 December 2017 at 14:37:01 UTC, Mengu wrote:
On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote:
Does to!(string)(char[]) do any memory allocation on
conversion or is this similar to a cast or what else?
yes, it is allocating memory. you can test such cases with
@nogc [0].
On Monday, 25 December 2017 at 14:12:32 UTC, Marc wrote:
Does to!(string)(char[]) do any memory allocation on conversion
or is this similar to a cast or what else?
It is translated to idup.
So yes, it allocates memory.
On Wednesday, 20 December 2017 at 13:41:06 UTC, Vino wrote:
On Tuesday, 19 December 2017 at 18:42:01 UTC, Ali Çehreli wrote:
On 12/19/2017 02:24 AM, Vino wrote:
> Hi All,
>
>Request your help in clarifying the below. As per the
document
>
> foreach (d; taskPool.parallel(xxx)) : The total num
On Tuesday, 28 November 2017 at 06:46:18 UTC, Dmitry wrote:
On Monday, 27 November 2017 at 19:01:28 UTC, Ali Çehreli wrote:
P.S. I think you have an unnecessary 'ref' on the D version
because a slice is already a reference to elements:
Fixed, thank you.
https://pastebin.com/xJXPBh0n
Converted
On Thursday, 23 November 2017 at 14:16:25 UTC, Andrea Fontana
wrote:
On Thursday, 23 November 2017 at 13:47:37 UTC, Adam D. Ruppe
wrote:
On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:
for instance in kotlin it can be replace with this:
when {
c1 -> foo(),
c2 -> bar(),
On Monday, 13 November 2017 at 10:20:51 UTC, Aurelien Fredouelle
wrote:
Hi all,
It seems that it is not possible to use minElement on an array
of const objects:
class A
{
int val;
}
const(A) doStuff(const(A)[] v)
{
import std.algorithm.searching : minElement;
return v.minElement!"a.val
On Friday, 13 October 2017 at 11:21:48 UTC, Biotronic wrote:
On Friday, 13 October 2017 at 10:35:56 UTC, Jack Applegame
wrote:
Compiler creates struct on the stack and silently (without
postblitting and destruction old object) moves it to another
address. Is it normal? I don't think so.
It is
Sorry, messed up numbers
Expected:
3.11
3.11
3.1
3.1
Seems g outputs one digit less
import std.stdio;
void main()
{
writefln(`%.2g`, 3.11);
writefln(`%.2f`, 3.11);
writefln(`%.1g`, 3.11);
writefln(`%.1f`, 3.11);
}
3.1
3.11
3
3.1
But expected
3.1
3.11
3.1
3.11
On Saturday, 5 August 2017 at 19:19:06 UTC, Simon Bürger wrote:
On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote:
Maybe std.functional.partial can help you.
Nope.
int i = 1;
alias dg = partial!(writeln, i);
i = 2;
dg();
still prints '2' as it should beca
On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel
wrote:
Any ideas?
You can use to! in std.conv:
import std.stdio;
import std.conv;
enum Foo
{
A = "A",
B = "B"
}
void main()
{
writeln("A".to
On Thursday, 3 August 2017 at 14:03:56 UTC, Michael wrote:
So this might be a bit of a stupid question, but looking at the
DMD source code (dmodule.d in particular) I see the following
code:
if (srcfile._ref == 0)
.free(srcfile.buffer);
srcfile.buffer = null;
srcfile.len = 0;
and I was j
On Sunday, 30 July 2017 at 08:18:07 UTC, Danni Coy wrote:
The following code is not working for me
float[3] f;
f[] = abs(f)[] * -1.0f;
where abs is a function that returns a float[3];
it complains that f should be attached to some memory.
Is it a bug or am I missing something?
This is unimpl
On Friday, 28 July 2017 at 08:06:33 UTC, Eugene Wissner wrote:
On Friday, 28 July 2017 at 06:32:59 UTC, Jacob Carlborg wrote:
On 2017-07-27 16:30, Eugene Wissner wrote:
I have a multi-threaded application, whose threads normally
run forever. But I need to profile this program, so I compile
the
Also there was an issue that profiling doesn't work with
multi-threaded apps and leads to a crash.
Don't know if it is fixed.
Exit is not "normal exit" for D programs so, do not use it.
Your threads should stop at some point to make able the app exit
successfully.
There's a "join" method. You can use it with your "done" variable.
On Wednesday, 26 July 2017 at 19:06:24 UTC, Andre Pany wrote:
On Wednesday, 26 July 2017 at 17:04:59 UTC, Adam D. Ruppe wrote:
On Wednesday, 26 July 2017 at 16:50:35 UTC, Andre Pany wrote:
[...]
FYI, you shouldn't use .stringof here. Just use `T` instead of
`T.stringof`.
[...]
Thank you
Hi !
I have a dub package that doing this.
https://github.com/Temtaime/tt-utils/blob/master/source/tt/binary/tests.d
Have a look at the tests.
Currently it has no documentation, but feel free to ask questions
On Sunday, 16 April 2017 at 15:54:16 UTC, Stefan Koch wrote:
On Sunday, 16 April 2017 at 10:56:37 UTC, Era Scarecrow wrote:
On Saturday, 15 April 2017 at 11:10:01 UTC, Stefan Koch wrote:
It would requires an O(n^2) check per declaration.
Even it is never used.
which would make imports that much
On Monday, 31 October 2016 at 16:55:51 UTC, WhatMeWorry wrote:
Is there a way to turn off nothrow or work around it? Because
to me it looks like nothrow prevents me from doing anything
useful.
extern(C) void onKeyEvent(GLFWwindow* window, int key, int
scancode, int action, int modifier) not
On Friday, 28 October 2016 at 18:39:36 UTC, Ali Çehreli wrote:
On 10/28/2016 11:25 AM, Jonathan M Davis via
Digitalmars-d-learn wrote:
>> void main() {
>> @(`str`, 123) uint k;
>> foreach (a; __traits(getAttributes, k)) {
>> pragma(msg, typeof(a));
>> }
>> }
> I don't k
On Friday, 28 October 2016 at 12:44:20 UTC, Adam D. Ruppe wrote:
On Friday, 28 October 2016 at 10:52:05 UTC, Temtaime wrote:
Are there something or should I create a PR to phobos?
Why would you want that?
I have UDAs with values à la @(`str`, 123) uint k;
And i want to know a type of a
Hi !
Tried to find
alias Typeof(alias A) = typeof(A);
or something, but failed.
Are there something or should I create a PR to phobos?
Thanks
Hi !
I can't find this in specs.
If i add an element to AA:
aa[10] = 123;
Will &aa[10] be always the same (of course i don't remove that
key) ?
Thanks for a reply.
I think specs should be enhanced.
Hi !
I wonder if i can rely on this code :
http://dpaste.dzfl.pl/745cc5b1cdfb
There's two questions:
1) Is dtors always called in reverse order ?
2) Is all the dtors always called when i call destroy ?
Thanks for a reply !
Offtop: i think if number of threads > number of real cores, than
there's something wrong with your design. Maybe fibers suit
better ?
There's a problem with « dst[0 .. n] = val; ».
It should be « dst[0 .. n][] = val; »
It's because it's implemented in DMD only partly.
There's a bug report associated with it.
I'm writing a game engine in D. Try to minimize allocations and
that's will be OK.
I'm using delegates and all the phobos stuff. I allocate only in
few places at every frame.
So i can reach 1K fps on a complicated scene.
GC is not a problem. DMD optimizes so ugly that all the math is
very, ver
All types are hashable and for your own structs and classes you
can redefine opHash
Sorry, i meant it gives b == "fooo\\nbar"
I'm writing an interpreter and it should dump original string
from memory.
Also i wonder if there's a function to convert "aaa\\nbb" to
"aaa\nbb" (i.e. to unescape)
Hi ! I wonder how to escape a string in phobos ?
For example
auto a = [ "fooo\nbar" ];
auto b = format("%(%s%)", a);
gives b: "fooo\nbar"
Is there any other function to escape string? I'm looking for
something that doesn't require to make an array at first.
For example is there string escape
Setting up LLVM infrastructure is only needed when you is a LDC
developer.
I think for ordinary users it's not their business.
It's only words.
If we speak about LDC it can compile fast in debug mode with
performance average to DMD's backend but with much great
performance in release mode thanks to vectorization and other
techniques.
Also LDC thanks to LLVM supports X86, X86-64, PowerPC,
PowerPC-64, ARM, Thumb, SPARC,
align doesn't work in DMD. There's bugreport for a long time.
DWORD is an uint.
Offtop
It's better to return "this" and have return type "ref auto" i
think.
Also second question is what are better to use, current template
recursion-based code or rewrite it to CTFE ?
Hi !
http://dpaste.dzfl.pl/e21082716396
Is there a way to optimize
static if(is(typeof(__traits(getMember, T, name).offsetof)) ==
false && is(FunctionTypeOf!(__traits(getMember, T, name)) ==
function) == false && __traits(compiles, &__traits(getMember, T,
name)))
?
I think there shoult be
Hi ! Thanks for reply.
Why so ?
And why @nogc not transitive too ?
Hi, MrSmith !
Yes, i know that, but my question isn't about it.
I want to type `pure:` at module's beginning and have all
function(in classes, too) declared as pure.
I think `pure:` should do it. But it doesn't.
Hi !
http://dpaste.dzfl.pl/2fa3dd2ea834
Why S.init not pure ? Is it expected behavior or bug ?
Thanks!
Ok, with ints 2.065:
http://dpaste.dzfl.pl/5057b6ce3ff8
And git head says
Error: Array operation a[] * 10 not implemented
Too strange.
But that compiles:
http://dpaste.dzfl.pl/0e98d1110d77
Ok, if i rewrite my example in such way:
http://dpaste.dzfl.pl/f7aa6aa96821
Should i report a bug?
Thank
Hi !
http://dpaste.dzfl.pl/d5b69cfb98f4
Fails to compile. Why?
Thanks.
Thanks !
Hi !
I just wondered if this code is valid:
void main() {
auto p = my_allocate();
// ...
my_free(p);
}
extern(System):
void *my_allocate();
void my_free(void *);
Where my_allocate and my_free are in the external dll. Main
question is: is this code transparent to GC? Will not it try to
coll
I see.
Thanks for all for yours replies !
Please, don't advise to call b.destroy.
Hi !
http://dpaste.dzfl.pl/53d9a59e
How i can enforce that ~A will be called after ~B ?
I'm writing 3D engine and it's critical to me.
Thanks for yours aid !
Go to bugzilla.
I cannot use the delete/destroy. I want to call dtor at all
unreferenced objects.
Manual from Dlang size says that GC.collect triggers a full
collection. But it doesn't.
Hello for all !
I need to call all objects destructors in one place.
It's guaranted, that there is no objects instances.
I tried use GC.collect but it's produces strange results.
import std.stdio;
import core.memory;
class A {
~this() { writeln(`dtor`); };
};
void main() {
aut
Oh, i've found that that can be resolved by select().
Thanks.
Hello guys!
void connect(Address to);
Establish a connection. If the socket is blocking, connect waits
for the connection to be made. If the socket is nonblocking,
connect returns immediately and the connection attempt is still
in progress.
How can i obtain information about progress when s
Now it's clear.
Thanks very much!
Hello, guys!
I have Matrix class(that contains an array of 16 floats) and SSE
code to mult it.
It's neccessary to have an array alignment 16.
I'm figured out simple test-code:
align(16) struct S {
align(16) int a;
}
void main() {
align(16) S s;
writeln(cast(void *)&s
Sorry, not class, but struct.
I'm writing some ASM code in my function.
Does it mean that DMD saves "his" registers before my asm code
and restores after? So i can use all registers without
interaction with code that DMD backend produces?
Hello for all!
Which registers in IASM i must preserve?
http://dlang.org/iasm.html says nothing.
Regards.
No, i cannot.
struct S {
uint longnamed;
}
void main() {
S somestruct;
alias v = somestruct.longnamed;
writeln(v);
}
Error: need 'this' for 'longnamed' of type 'uint'
Is it a bug ?
I have a long named variable in a struct.
For example let's name that longnamedstruct.longnamedmember
I need to use that variable in many places of the code and i
cannot create the copy of it.
In c++ i can
auto &v = longnamedstruct.longnamedmember;
Now i can use v anywhere.
Why i cannot decl
Hello guys !
I'm found strange error when compiling following code:
http://dpaste.1azy.net/b40ce9a4
The error is:
src\phobos\std\stdio.d(1872): Error: variable _param_1 used
before set
Problem exists only when using following options: -inline -O
I'm using DMD 2.063.2 on Windows.
Can anybody
Hello, guys !
http://dpaste.1azy.net/8917c253
Thanks.
Regards.
Oh, thanks very much.
Hello guys!
http://dpaste.1azy.net/9c4c3eb8
http://dpaste.1azy.net/afd8d20b
How i can avoid this?
No. I means, that
uint a = uint.max;
uint b = a + 1;
writeln(b);
Works OK.
Why? Compiler doesn't know if a + b fits in uint, right?
Then why overflow with ints are accepted?
So your example is meaningless.
There is overflow and it can be with int too.
It's standard behavior.
ubyte k = 10;
ubyte c = k + 1;
This code fails to compile because of: Error: cannot implicitly
convert expression (cast(int)k + 1) of type int to ubyte
Why? It's pain in the ass, i think. My code contains only casts
then.
Oh, i see, thanks.
P.S. туй васю нигодяй.
Hello guys!
@("att") int t = 1;
auto b = [ __traits(getAttributes, t) ];
Works.
@("att") enum int t = 1;
auto b = [ __traits(getAttributes, t) ];
Works also.
@("att") const int t = 1;
auto b = [ __traits(getAttributes, t) ];
Doesn't work.
Error: first argument is not a symbol
Why?
Also a li
Thanks for all, it's unactual anymore.
Yes, it's strange. Using alias doesn't lead to this.
Oh, i see.
Great thanks!
Hello guys!
It seems that it is bug. And critical for me.
http://dpaste.1azy.net/b93f5776
Regards.
Oh, thanks. But then that code doesn't work:
http://dpaste.dzfl.pl/262b966c
@(3) int a;
enum tp = __traits(getAttributes, a);
enum b = tp[0];
writeln(b);
Compiler doesn't accept enum b = tp[0] and says to me:
Error: variable _tp_field_0 cannot be read at compile time
Why? And writeln(tp[0]) works as expected.
I'm writing serializer and it iterates all members of struct.
It compares fields marked as "enum" when reading from file to
check BOM, for example.
I'm using enum now because const members are deprecated in 2.063.
It's intresting.
So the only way to pass "a" to overloaded function like that ?
void foo(T)(ref T) { writeln("true"); }
void foo(T)(auto ref in T) { writeln("false"); }
enum int a = 10;
foo(a); // false
int b = 1;
foo(b); // true
Hi!
enum int a = 5;
writeln(isMutable!(typeof(a)));
Writes true. Why? How i can figure out if variable is "enum"
constant ?
Thanks.
Regards.
Why
char arr[3] = "abc";
arr[].until('b').front has type of dchar ???
Yes, i want to see 'undeclared variable' error, but the compiler
omits function declaration instead.
And why i shouldn't use __? I think it's ordinary identifier.
struct A {
int opBinary(string op)(A) { k++; return 0; }
}
struct B {
A __a;
alias __a this;
}
void main() {
B b;
auto c = b * b;
}
This code doesn't compiles with an error:
Error: 'b' is not of arithmetic type, it is a B
If i remove k++, then it's OK. It seems
Hello to all !
I'm surprised that there is no structure's inheritance.
There is a problem:
I want to make Matrix MxN class. I also want to make child
classes Square Matrix and Vector from it with additional
functions.
I don't want use "class" cause of "new" overhead. Std typecons's
Scoped - wo
And why not?
If not, then you should drop support of platform specific headers
like windows.d.
Because it's full of a drawing and many other functions. OpenGL
is part of WinAPI.
I had investigate a little more in it.
Thanks to Jack Applegame, we made a copy of gl/gl.h and
opengl32.lib for DMD.
http://acomirei.ru/u/gl.d
http://acomirei.ru/u/opengl32.lib
I hope it will be included in DMD, now it's first draft of our
work.
I'm new in D, so i'm tried to write some in that langugage.
That's story about how i tried to port OGL sample, that renders
one triangle.
I was very surprised when i found, that D doesn't have equivalent
of gl/gl.h. Any C++ compiler has it.
Okay, i'm investigate in it and found OpenGL in dei
int main() {
auto f = (bool = false) {};
f();
return 0;
}
I can't compile this code on
DMD32 D Compiler v2.062
On windows. It says to me:
Error: expected 1 function arguments, not 0
On linux it seems to work(http://ideone.com/fsKYWR).
91 matches
Mail list logo