```D
import std;
void main()
{
void[] a = [0, 1, 2, 3, 4, 5, 6, 7, 8, 0x12345678];
void[] b = cast(ubyte[])[0, 1, 2, 3, 4, 5, 6, 7, 8];
ubyte[] c = cast(ubyte[])(cast(void[])[0, 1, 2, 3, 4, 5, 6,
7, 8,0x12345678]);
ubyte[] d = [0, 1, 2, 3, 4, 5, 6, 7, 8];
void[] e = cast(uby
On Tuesday, 22 August 2023 at 22:38:23 UTC, dan wrote:
Hi,
I'm parsing some files, each containing (among other things) 10
bytes said to represent an IEEE 754 extended floating point
number, in SANE (Standard Apple Numerical Environment) form, as
SANE existed in the early 1990s (so, big endia
On Saturday, 1 April 2023 at 15:32:27 UTC, Dennis wrote:
On Friday, 31 March 2023 at 13:11:58 UTC, z wrote:
I've tried to search before but was only able to find articles
for 3D triangles, and documentation for OpenGL, which i don't
use.
The first function you posted takes a 3D triangle as in
On Wednesday, 5 April 2023 at 15:19:55 UTC, Cecil Ward wrote:
How much code do you thing I would need to write for this? I’m
still thinking about its feasibility. I don’t want to invent
the wheel and write a custom parser by hand, so’d rather steal
the code using sim eg called ‘a library’. :-)
On Thursday, 30 March 2023 at 12:59:31 UTC, Dennis wrote:
On Thursday, 30 March 2023 at 10:29:25 UTC, z wrote:
Is this code correct or logically sound?
You need to be exact on what 'correct' is. The comment above
`triangleFacesCamera` says:
Indicates wether a triangle faces an imaginary vi
Is this code correct or logically sound?
```D
import std;
enum {side/depth/height and side/height
x,//0
y,//1
z //2
}
/**
Indicates wether a triangle faces an imaginary view point.
*/
bool triangleFacesCamera(float[3] tA, float[3] tB, float[3] tC) {
float r1, r2;
r1 = atan2(tB[x] - tA[x], tB
On Sunday, 26 March 2023 at 18:07:03 UTC, ryuukk_ wrote:
``shared`` is even more ugly since everything must be shared
afterwards
The limitations of `shared` can be bypassed with a "function"
that removes type qualifiers. `return *cast(Unqual!T*)
&foo`(example, doesn't work as is for arrays.)
On Sunday, 26 March 2023 at 18:07:03 UTC, ryuukk_ wrote:
``shared`` is even more ugly since everything must be shared
afterwards
The limitations of `shared` can be bypassed with a "function"
that removes type qualifiers. `return *cast(Unqual!T*)
&foo`(example, doesn't work as is for arrays.)
On Sunday, 26 March 2023 at 18:07:03 UTC, ryuukk_ wrote:
``shared`` is even more ugly since everything must be shared
afterwards
The limitations of `shared` can be bypassed with a "function"
that removes type qualifiers. `return *cast(Unqual!T*)
&foo`(example, doesn't work as is for arrays.)
On Sunday, 26 March 2023 at 18:07:03 UTC, ryuukk_ wrote:
``shared`` is even more ugly since everything must be shared
afterwards
The limitations of `shared` can be bypassed with a "function"
that removes type qualifiers. `return *cast(Unqual!T*)
&foo`(example, doesn't work as is for arrays.)
On Sunday, 6 November 2022 at 20:07:47 UTC, z wrote:
whenever the counter is above `1`
I meant above or equal(`>=`), woops
On Sunday, 6 November 2022 at 16:48:24 UTC, Joel wrote:
I want my code fixed up so that works from any two points.
You can add a condition to prevent writing out of the
image/framebuffer/whatever memory so it won't do any out of
bounds write.
Another valid algorithm could be testing all pix
On Friday, 4 November 2022 at 10:57:12 UTC, Hipreme wrote:
...
What do we use instead?
I won't lie about the fact package.d forced me to workaround
elusive "bugs" in my usage(1) but what is the alternative if we
don't want to work around it?
(1)(ime : had cases of package.d requiring compil
On Wednesday, 19 October 2022 at 23:28:46 UTC, Hipreme wrote:
Hey guys, I'm going to start making a tip of the day (although
I'm pretty sure I won't be able to give every day a tip), but
those things are really interesting to newcomers to know and
may be obvious to some of the old schoolers the
On Monday, 11 July 2022 at 18:15:16 UTC, Ivan Kazmenko wrote:
Hi.
I'm looking at the compiler output of DMD (-O -release), LDC
(-O -release), and GDC (-O3) for a simple array operation:
```
void add1 (int [] a)
{
foreach (i; 0..a.length)
a[i] += 1;
}
```
Here are the outputs: htt
On Sunday, 10 July 2022 at 21:27:08 UTC, Hipreme wrote:
I'm stuck in a racing condition right now and I'm unable to run
a debugger on the code. Usually I was using Visual Studio 2019
for debugging my code, but it shows the following message:
"Your app has entered a break state, but there is no
On Saturday, 11 June 2022 at 15:01:05 UTC, Ali Çehreli wrote:
On 6/11/22 00:09, z wrote:
> I rechecked and it should be `X Y Z` for static array, but `Z
Y X` for
> indexing/dynamic array creating with `new`
How so?
i meant with the syntax in (1), the spec's documentation appears
to say they
On Saturday, 11 June 2022 at 03:56:32 UTC, Chris Katko wrote:
On Friday, 10 June 2022 at 17:26:48 UTC, Ali Çehreli wrote:
On 6/10/22 08:13, z wrote:
> arrays of arrays has different order for declaration and
addressing,
> and declaring array of arrays has different order depending
on how you
>
On Friday, 10 June 2022 at 08:08:45 UTC, Chris Katko wrote:
Is it somehow possible to use a struct as a [multidimensional]
array index:
D
struct indexedPair
{
size_t x, y;
}
bool isMapPassable[100][100];
auto p = indexedPair(50, 50);
if(isMapPassable[p]) return true;
Probably not,
Is there a quick way of obtaining the graph of D functions like
these?
```d
T f(T) if (isScalarType!T){}
```
or
```D
T[2] f(T, T)if (isScalarType!T){}
```
I know that there are graphing calculators already, but these
don't support low level black magic like int <-> float
conversions and i'm los
Is it possible to set a "position" on a union member? or is there
is a language-integrated equivalent?
For example, to get access to each byte in an unsigned integer
while still supporting the original type.
```D
///a single uint that would be accessed as two ushort, or four
separate ubyte
uni
On Wednesday, 7 July 2021 at 10:27:47 UTC, notna wrote:
On Windows:
```
::> dmd curl_get.d
::> .\curl_get.exe
object.Error@(0): Access Violation
0x0283CA66
0x0041DE8D
0x004023A2
0x00402308
0x00414D33
0x00414CAD
0x00414B48
0x0040D41F
0x00402363
0x74B96359 in BaseThreadInitThunk
0
On Tuesday, 15 June 2021 at 06:39:24 UTC, seany wrote:
...
This is the best I could do: https://run.dlang.io/is/dm8LBP
For some reason, LDC refuses to vectorize or even just unroll the
nonparallel version, and more than one `parallel` corrupts the
results.
But judging by the results you expec
On Saturday, 15 May 2021 at 14:31:08 UTC, Alain De Vos wrote:
Which parts in dlang don't you use and why ?
Auto return types i find dangerous to use.
I found `auto` and `ref`(yes just `ref`) return types very useful
for bypassing the type system, eg.:
```D
///function requires lvalue and the
I'd recommend you to use templates with alias parameters but you
mentioned that you need to retain function context(for gotos,
continue, break, etc...)
One thing you could do is mix the ugly mixin solution with the
good one:
```D
//inside the function, so that you can access locals
pragma(inlin
On Thursday, 15 April 2021 at 19:53:57 UTC, Paul Backus wrote:
They're not *exactly* the same. When you write
auto seq = AliasSeq!(a, b, c);
...you are declaring a sequence of three *new* array variables
[1] and initializing them with copies of the original arrays.
It's as though you'd wr
On Thursday, 15 April 2021 at 19:38:04 UTC, z wrote:
```D
int[] a,b,c,d,e;
void templatef(args...){/*...*/}
//...
auto seq = AliasSeq!(b,c,d);
templatef!(a,seq,e);
templatef!(a,b,c,d,e); //am i being mistaken for thinking these
two template calls should be equivalent in behavior?
```
woops, me
On Thursday, 15 April 2021 at 18:58:40 UTC, Paul Backus wrote:
Without an example that shows the actual problem you
encountered, it will be almost impossible for anyone to help
you figure out what is causing it.
Since you were not able to trigger it, it seems likely that the
problem is relate
I've tried to group together a bundle of alias template
parameters with AliasSeq, but while without it works just fine,
when the verbose parameters are grouped with multiple AliasSeqs,
the lengths of the array parameters passed through AliasSeq are
0(inside the templated function, before the ca
On Saturday, 10 April 2021 at 13:15:19 UTC, Alain De Vos wrote:
dub fetch lint
Getting a release version failed: (1): Error: Got JSON of type
null_, expected object.
Retry with ~master...
(1): Error: Got JSON of type null_, expected object.
He meant `dub lint`, with the working directory in t
On Saturday, 3 April 2021 at 10:17:14 UTC, DLearner wrote:
Does this mean D has no equivalent of C globals?
What is the D way of doing this?
With __gshared.
If the global is defined from within another language, apparently
you'd have to do [extern(C) extern __gshared
*name*](https://dlang.org
On Friday, 2 April 2021 at 12:47:35 UTC, z wrote:
```d
T processArray(T)(ref T[] p){/*...*/} //function calls .reserve
```
i meant `void` for the function return type.
```d
shared TT[] a;
T processArray(T)(ref T[] p){/*...*/} //function calls .reserve
on its parameter
a.processArray;
```
Template *name* cannot deduce function from argument types
!()(shared(T[]))...
Even if the function is changed to only accept shared parameters,
.reserve does not appear t
On Tuesday, 9 March 2021 at 20:33:01 UTC, z wrote:
On Tuesday, 9 March 2021 at 20:23:48 UTC, z wrote:
On Friday, 5 March 2021 at 12:57:43 UTC, z wrote:
...
Then it seems the only way to get AVX-compatible inline
assembly(ldc.llvmasm excluded) is to use an external assembler.
For example :
On Tuesday, 9 March 2021 at 20:23:48 UTC, z wrote:
On Friday, 5 March 2021 at 12:57:43 UTC, z wrote:
...
Then it seems the only way to get AVX-compatible inline
assembly(ldc.llvmasm excluded) is to use an external assembler.
For example :
...
But i'm not really sure how to integrate that i
On Friday, 5 March 2021 at 12:57:43 UTC, z wrote:
...
Then it seems the only way to get AVX-compatible inline
assembly(ldc.llvmasm excluded) is to use an external assembler.
For example :
import std.stdio;
extern(C) void vxorps_d(ubyte[32]*);
void main() {
ubyte[32] a = 2;
On Friday, 26 February 2021 at 03:57:12 UTC, tsbockman wrote:
static foreach(size_t i; 0 .. 3/+typeof(a).length+/){
distance += a[i].abs;//abs required by the caller
(a * a) above is always positive for real numbers. You don't
need the call to abs unless you're trying to guarantee that
On Thursday, 25 February 2021 at 14:28:40 UTC, Guillaume Piolat
wrote:
On Thursday, 25 February 2021 at 11:28:14 UTC, z wrote:
How does one optimize code to make full use of the CPU's SIMD
capabilities?
Is there any way to guarantee that "packed" versions of SIMD
instructions will be used?(e.g.
On Thursday, 25 February 2021 at 11:28:14 UTC, z wrote:
...
It seems that using static foreach with pointer parameters
exclusively is the best way to "guide" LDC into optimizing
code.(using arr1[] += arr2[] syntax resulted in worse performance
for me.)
However, AVX512 support seems limited to
On Saturday, 6 March 2021 at 22:14:26 UTC, kdevel wrote:
After replacing dmd with ldmd2 (LDC 1.25.1) I get tons of link
errors all of
the form mentioned in the subject. Any idea what can be done
about it?
(With a handcrafted single compile/link statement using ldc2
everything compiles
but id
On Friday, 5 March 2021 at 16:10:02 UTC, Rumbu wrote:
First of all, in 64 bit ABI, parameters are not passed on
stack, therefore a[RBP] is a nonsense.
void complement32(simdbytes* a, simdbytes* b)
a is in RCX, b is in RDX on Windows
a is in RDI, b is in RSI on Linux
I'm confused, with your hel
XMM registers work, but as soon as they are changed into YMM DMD
outputs "bad type/size of operands %s" and LDC outputs an "label
YMM0 is undefined" error. Are they not supported?
To illutrate : https://run.dlang.io/is/IqDHlK
By the way, how can i use instructions that are not listed in
[1]?(v
How does one optimize code to make full use of the CPU's SIMD
capabilities?
Is there any way to guarantee that "packed" versions of SIMD
instructions will be used?(e.g. vmulps, vsqrtps, etc...)
To give some context, this is a sample of one of the functions
that could benefit from better SIMD usa
So i've upgraded one of my structs to use the more flexible
delegates instead of function pointers but when the member
function tries to access the struct's members, the contents are
random and the program fails.
i've isolated the problem by adding writefln calls before calling
the delegate a
On Tuesday, 16 February 2021 at 06:03:50 UTC, H. S. Teoh wrote:
It depends on what your goal is. Do you want to permanently
remove the items from the array? Or only skip over some items
while iterating over it? For the latter, see
std.algorithm.iteration.filter.
The array itself is read only
On Tuesday, 16 February 2021 at 04:43:33 UTC, Paul Backus wrote:
On Tuesday, 16 February 2021 at 04:20:06 UTC, z wrote:
What would be the overall best manner(in ease of
implementation and speed) to arbitrarily remove an item in the
middle of an array while iterating through it?
http://phobos.
What would be the overall best manner(in ease of implementation
and speed) to arbitrarily remove an item in the middle of an
array while iterating through it?
So far i've thought about simply using D's standard [0...x] ~
[x+1..$] with an array of indexes but wouldn't that just cause
slow reallo
On Thursday, 21 January 2021 at 14:11:15 UTC, kdevel wrote:
Creating a scope
works around the issue.
Another way to work around the issue is to use «asm {jmp label;}»
(replace jmp by whatever equivalent is there on the target
architecture.)
Yes it's ugly, but it bypasses the arbitrary limita
On Wednesday, 13 January 2021 at 11:50:26 UTC, Andrey wrote:
Function "ctfeWriteln" doens't exist.
pragma(msg, ...) is used only for CT values.
Today is 2021. Dlang still doesn't have ctfe write functions?
Yes.(afaik)
It has shot me on the foot once, to the point i abandoned the
idea of eve
On Thursday, 10 December 2020 at 14:51:51 UTC, ag0aep6g wrote:
...
Thank you for the explanation on mangles.
The problem was caused by an «unittest{ void main() }»
declaration in an import's source file, and for some reason it
had both passed compilation and not resulted in the usual
"undef
When compiling with unit tests(via «dub test», or adding «dflags
"-unittest"»), i'm getting this error at link time :
lld-link: error: undefined symbol:
_D5packagename9subpackage9__mixin119type8toStringMFZAya
The same occurs with OPTLINK.
Curiously, looking at the incriminated .lib file with
On Tuesday, 1 December 2020 at 07:39:31 UTC, rikki cattermole
wrote:
That isn't right.
Thank you, this was the problem apparently. Dub ignored the
malformed dependency declaration instead of displaying a warning
or an error.(this is apparently a bug.[0][1])
[0] https://github.com/dlang/dub/
On Tuesday, 1 December 2020 at 04:50:03 UTC, rikki cattermole
wrote:
...
What puzzles me is that the dependencies are indeed declared, but
"dub describe" refuses to recognize the dependencies and "dub
build" fails.
"dub list" does recognize the root folder, but trying to get a
subpackage to
How does one set up a dub package so that it contains multiple
sublibraries that may or may not depend on these same
libraries?(but never co-dependant)
So far i've tried using add-local and add-path with subpackage
declarations in the root folder's dub.sdl but to no avail.
(dub does not complain
On Sunday, 9 June 2019 at 10:22:36 UTC, Andrey wrote:
Hello,
I have got 2 functions:
void myFunc(string name, int a)(wstring value) {}
void myFunc(string name, int a)() {}
I want to make an alias (for example for second function
without argument):
alias myAlias(int a) = myFunc!("Name", a);
55 matches
Mail list logo