On Thursday, 27 October 2022 at 01:57:15 UTC, Salih Dincer wrote:
You should help the compiler with return type:
I love D, enjoys it when I code...:)
I played a little on the code, and the following is possible and
beautiful:
```d
// If you type auto instead of ubyte as return type, the re
On Wednesday, 26 October 2022 at 21:10:54 UTC, 0xEAB wrote:
I know this is advanced stuff, but the compiler *could* even
prove that the calculation(s) won’t go beyond `ubyte.max`.
```d
//... => char?
return (decimal - ubyte(10) + ubyte('A'));
return '\xFF';
}
```
You should help t
On Wednesday, 26 October 2022 at 22:51:53 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 18:53:58 UTC, Hipreme wrote:
On Wednesday, 26 October 2022 at 18:37:00 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh
wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +,
On Wednesday, 26 October 2022 at 18:53:58 UTC, Hipreme wrote:
On Wednesday, 26 October 2022 at 18:37:00 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh
wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via
Digitalmars-d-learn wrote:
[...]
Maybe try inst
On 10/26/22 14:19, Ali Çehreli wrote:
>https://dlang.org/spec/type.html#integer-promotions
Reading "Value Range Propagation" further down that link, I learned that
e.g. masking 'decimal' with 0xf makes the code compile:
return ((decimal & 0xf) + ubyte('0'));
return ((deci
On 10/26/22 14:10, 0xEAB wrote:
> I guess, this fancy behavior is inherited from C.
Yes. It is called integer promotions:
https://dlang.org/spec/type.html#integer-promotions
(The next section is related as well.)
> I know this is advanced stuff, but the compiler *could* even prove that
> th
```d
@safe:
void main()
{
import std.stdio : writeln;
writeln(ubyte(4).toHexDigit);
}
ubyte toHexDigit(ubyte decimal) pure nothrow @nogc
{
if (decimal < 10)
return (decimal + ubyte('0'));
if (decimal < 16)
return (decimal - ubyte(10) + ubyte('A'));
return '\
The workaround is to compile without --release mode, but using
the "O3" ldc flag instead does the job - the binary is fast, yet
the try - catch block executes properly.
On Wednesday, 26 October 2022 at 20:13:37 UTC, Yura wrote:
OK, got the problem solved by adding the following lines in my
dub
OK, got the problem solved by adding the following lines in my
dub.sdl file:
lflags "-lopenblas" "-lgfortran"
dflags "--static"
However, one problem still remains. Apparently, when compiled
with dub --release mode I got segfault in my try - catch block.
Any solution to this?
On Wednesday,
On Wednesday, 26 October 2022 at 18:37:00 UTC, DLearner wrote:
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via
Digitalmars-d-learn wrote:
Hi
Never used DUB before.
Wanted to use a function stored in a module outside the ma
On Wednesday, 26 October 2022 at 16:58:08 UTC, H. S. Teoh wrote:
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via
Digitalmars-d-learn wrote:
Hi
Never used DUB before.
Wanted to use a function stored in a module outside the main
source.
Main source has `import ;`
Put a line into the JS
On Wed, Oct 26, 2022 at 04:20:01PM +, DLearner via Digitalmars-d-learn
wrote:
> Hi
>
> Never used DUB before.
> Wanted to use a function stored in a module outside the main source.
>
> Main source has `import ;`
>
> Put a line into the JSON: `"importPaths": "C:\\Users\\..."` pointing
> to t
On Tuesday, 25 October 2022 at 12:29:50 UTC, Andrey Zherikov
wrote:
On Sunday, 23 October 2022 at 20:12:46 UTC, Hipreme wrote:
This will greatly reduce the number of import and dependencies
you need if you ever need to distribute a library.
Could you elaborate more on the benefit? Does it redu
Looks like explicitly initialized variable in this case allocates
array literal. Uninitialized variable is initialized with init
pattern. This may be correct as uninitialized variable isn't
guaranteed to hold a value most useful for you, it's only
guaranteed to hold a defined value.
I am now trying to compile the code statically using the dub
manager via the following command line:
dub build --force --build=release --compiler=path_to_ldc2/ldc2
and having these lines in my dub.sdl file:
dependency "mir" version="~>3.2.3"
dependency "lubeck" version="~>1.5.1"
dflags "-stati
On Wednesday, 26 October 2022 at 04:40:17 UTC, Salih Dincer wrote:
On Tuesday, 25 October 2022 at 13:51:30 UTC, Andrey Zherikov
wrote:
Does the second piece of code shows a bug or my expectation is
not correct (and why if so)?
As a result, if this is a bug, Andrey has the right to report
it.
16 matches
Mail list logo