On Sunday, 17 April 2022 at 17:04:57 UTC, Bastiaan Veelo wrote:
On Sunday, 17 April 2022 at 11:16:25 UTC, HuskyNator wrote:
I recently found out there is [support for vector
extensions](https://dlang.org/spec/simd.html)
But I have found I don't really understand how to use it, not
even
On Friday, 23 July 2021 at 13:53:27 UTC, Rekel wrote:
As one can see, implicitly casting array literals in templates
works fine in the case of bar, as does explicit use of
templates in the case of foo, but for some reason foo does not
manage to deduce its arguments like bar does.
On Thursday, 21 April 2022 at 03:59:26 UTC, Steven Schveighoffer
wrote:
OK, so reviewing with that in mind, it looks like you're trying
to import `myPackage.modules.mymodule`, but the file
`../myPackageName/source/myPackageName/modules/mymodule.d`
doesn't exist.
Is there one too many
Hi,
Could someone possibly help me to understand why the commented
line doesn't compile?
```d
import std;
struct MapResult(R,F)
{
R r;
const F f;
auto empty() { return r.empty; }
auto front() { return f(r.front); }
void popFront() { r.popFront; }
auto save() { return
On Thu, Apr 21, 2022 at 09:02:47PM +, JG via Digitalmars-d-learn wrote:
> Hi,
>
> Could someone possibly help me to understand why the commented line
> doesn't compile?
>
>
> ```d
> import std;
>
> struct MapResult(R,F)
> {
> R r;
> const F f;
> auto empty() { return r.empty; }
I don't know when to use a static assert and when to use a unit
test ?
On Thursday, 21 April 2022 at 15:31:04 UTC, HuskyNator wrote:
On Sunday, 17 April 2022 at 17:04:57 UTC, Bastiaan Veelo wrote:
You might want to have a look at
https://code.dlang.org/packages/intel-intrinsics
— Bastiaan.
This does not discuss core.simd or __vector type, or did I
On Thursday, 21 April 2022 at 21:02:47 UTC, JG wrote:
Hi,
Could someone possibly help me to understand why the commented
line doesn't compile?
```d
import std;
struct MapResult(R,F)
{
R r;
const F f;
auto empty() { return r.empty; }
auto front() { return f(r.front); }
On Thursday, 21 April 2022 at 21:38:14 UTC, Ali Çehreli wrote:
```d
auto myMap(alias f, R)(R r) {
pragma(msg, typeof(f));
return MapResult!(R, f)(r);
}
```
It looks delicious when the convenience function works magic with
Voldemort:
```d
import std.range, std.stdio;
auto myMap(alias
On Sunday, 17 April 2022 at 11:16:25 UTC, HuskyNator wrote:
As a small disclaimer; I don't know to what extent the compiler
already automates these kind of operations, and mostly want to
use this as a learning experience.
For your particular case, it is very likely LDC and GDC will be
able
On 4/21/22 14:02, JG wrote:
> Could someone possibly help me to understand why the commented line
> doesn't compile?
iota(10).myMap!(x=>2*x).writeln;
It is because x=>2*x is just a template. I don't know why the compiler
chooses 'void' for typeof(f) but apparently that's how it represents
On Thursday, 21 April 2022 at 22:26:57 UTC, Alain De Vos wrote:
I don't know when to use a static assert and when to use a unit
test ?
There is `assert()`, `static assert()` and `unittest`.
`static assert()` is used while compiling, to find errors or
circumstances that can lead to errors in
On 4/21/22 6:26 PM, Alain De Vos wrote:
I don't know when to use a static assert and when to use a unit test ?
An assert in general is something that must be true for the program to
be valid.
A normal assert is some runtime condition that must be true or the
program will be terminated.
A
On Thursday, 21 April 2022 at 04:36:13 UTC, Salih Dincer wrote:
My favorite is the struct range. Because it is more
understandable and personalized. Moreover, you can limit it
without using ```take()```.
And it's inherently lazy, so no extra processing/calculation
other than what's
On Thursday, 21 April 2022 at 07:38:04 UTC, Alexander Zhirov
wrote:
On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote:
On Thursday, 21 April 2022 at 07:04:18 UTC, Alexander Zhirov
wrote:
I want to get the IP address of the network interface. There
is both a wireless interface and a
On Friday, 22 April 2022 at 05:28:52 UTC, dangbinghoo wrote:
On Thursday, 21 April 2022 at 07:38:04 UTC, Alexander Zhirov
wrote:
[...]
```d
struct ifreq {
private union ifr_ifrn_ {
char[IFNAMSIZ] ifrn_name; /* if name, e.g. "en0" */
}
On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote:
On Thursday, 21 April 2022 at 07:04:18 UTC, Alexander Zhirov
wrote:
I want to get the IP address of the network interface. There
is both a wireless interface and a wired one. Is it possible,
knowing the name of the network
On Thursday, 21 April 2022 at 05:49:12 UTC, Alain De Vos wrote:
Following program:
```
import std.stdio;
void main() @trusted
{
int *p=null;
void myfun(){
int x=2;
p=
writeln(p);
writeln(x);
}
myfun();
*p=16;
writeln(p);
writeln(*p);
}
```
outputs :
I want to get the IP address of the network interface. There is
both a wireless interface and a wired one. Is it possible,
knowing the name of the network interface, to get its IP address?
On Thursday, 21 April 2022 at 07:04:18 UTC, Alexander Zhirov
wrote:
I want to get the IP address of the network interface. There is
both a wireless interface and a wired one. Is it possible,
knowing the name of the network interface, to get its IP
address?
```d
import
On 21.04.22 07:49, Alain De Vos wrote:
int *p=null;
void myfun(){
int x=2;
p=
writeln(p);
writeln(x);
}
myfun();
*p=16;
writeln(p);
writeln(*p);
`p` is no longer valid after `myfun` returns. Dereferencing it is an error.
The two `writeln` calls in `main` re-use the memory
On Thursday, 21 April 2022 at 07:20:30 UTC, dangbinghoo wrote:
On Thursday, 21 April 2022 at 07:04:18 UTC, Alexander Zhirov
wrote:
I want to get the IP address of the network interface. There
is both a wireless interface and a wired one. Is it possible,
knowing the name of the network
On Thursday, 21 April 2022 at 05:49:12 UTC, Alain De Vos wrote:
Following program:
```
import std.stdio;
void main() @trusted
{
int *p=null;
void myfun(){
int x=2;
p=
writeln(p);
writeln(x);
}
myfun();
*p=16;
writeln(p);
writeln(*p);
}
```
outputs :
On Thursday, 21 April 2022 at 05:00:53 UTC, Alain De Vos wrote:
This example limits the maximum value returned by the fibonacci
function. f(n) < limit
But it does not allow to return the n-th element of a fibonacci
function.
You are free to use ```take():```
```d
struct FibonacciRange(long
On Thursday, 21 April 2022 at 06:57:41 UTC, drug wrote:
On 21.04.2022 08:49, Alain De Vos wrote:
Following program:
```
import std.stdio;
void main() @trusted
{
int *p=null;
void myfun(){
int x=2;
p=
writeln(p);
writeln(x);
}
myfun();
*p=16;
writeln(p);
writeln(*p);
}
```
On 21.04.22 13:25, Alain De Vos wrote:
How can i force an error to be thrown when doing something "bad" ?
Use @safe.
What would you expect for this code?
```d
struct Something(Types...) {}
enum isSomethingExact(T) = is(T == Something!Types, Types...);
enum isSomething(T) = is(T : Something!Types, Types...);
pragma(msg, isSomethingExact!noreturn);
pragma(msg, isSomething!noreturn);
```
This currently outputs
noreturn is the bottom type which can implicitly convert to any type,
including void. A value of type noreturn will never be produced and the
compiler can optimize such code accordingly.
https://dlang.org/spec/type.html#noreturn
On Thursday, 21 April 2022 at 12:28:37 UTC, rikki cattermole
wrote:
noreturn is the bottom type which can implicitly convert to any
type, including void. A value of type noreturn will never be
produced and the compiler can optimize such code accordingly.
Could we add a check for this in DScanner?
Otherwise I'm not sure how else we are going to find all of these
instances and fix them.
On Thursday, 21 April 2022 at 12:41:08 UTC, WebFreak001 wrote:
which I think is a little bug-prone, but at least that would
solve my issues.
What issue do you have with it returning `true`? Note that this
compiles:
```D
@safe:
import std.sumtype;
void main()
{
SumType!(int, string) s =
On Thursday, 21 April 2022 at 12:54:12 UTC, Dennis wrote:
On Thursday, 21 April 2022 at 12:41:08 UTC, WebFreak001 wrote:
which I think is a little bug-prone, but at least that would
solve my issues.
What issue do you have with it returning `true`?
Presumably the problem is that if you write
On Thu, Apr 21, 2022 at 11:25:29AM +, Alain De Vos via Digitalmars-d-learn
wrote:
> On Thursday, 21 April 2022 at 06:57:41 UTC, drug wrote:
> > On 21.04.2022 08:49, Alain De Vos wrote:
> > > Following program:
> > > ```
> > > import std.stdio;
> > >
> > > void main() @trusted
> > > {
[...]
>
On Thu, Apr 21, 2022 at 02:11:03AM +, Alain De Vos via Digitalmars-d-learn
wrote:
> Following java program creates an infinite fibonacci sequence (stream)
> an takes the first 42 values of it.
[...]
> How would this program look converted to dlang ?
> Maybe there are multiple solutions ?
34 matches
Mail list logo