On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer
wrote:
I currently have a situation where I want to have a function
that accepts a parameter optionally.
I thought maybe Nullable!int might work:
void foo(Nullable!int) {}
void main()
{
foo(1); // error
int x;
foo(x); // e
On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer
wrote:
I currently have a situation where I want to have a function
that accepts a parameter optionally.
why not simply use function overloading?
On Sunday, 1 April 2018 at 22:44:45 UTC, Jonathan M Davis wrote:
Which doesn't work in @safe code and doesn't work when you have
an rvalue as you would when passing 42. Ultimately, using
pointers ultimately either requires explicitly allocating stuff
on the heap to be able to pass rvalues, or i
On Sunday, April 01, 2018 22:34:16 Seb via Digitalmars-d-learn wrote:
> On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer
>
> wrote:
> > I currently have a situation where I want to have a function
> > that accepts a parameter optionally.
> >
> > I thought maybe Nullable!int might work:
On Sunday, April 01, 2018 22:37:17 Boris-Barboris via Digitalmars-d-learn
wrote:
> On Sunday, 1 April 2018 at 22:25:45 UTC, Jonathan M Davis wrote:
> > How would a pointer help? Instead of doing
> >
> > foo(nullable(42))
> >
> > he'd have to do
> >
> > foo(new int(42))
> >
> > which is just one ch
On Sunday, 1 April 2018 at 22:25:45 UTC, Jonathan M Davis wrote:
How would a pointer help? Instead of doing
foo(nullable(42))
he'd have to do
foo(new int(42))
which is just one character shorter and ends up allocating on
the heap, unlike with Nullable.
- Jonathan M Davis
foo(&x);
On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer
wrote:
I currently have a situation where I want to have a function
that accepts a parameter optionally.
I thought maybe Nullable!int might work:
void foo(Nullable!int) {}
void main()
{
foo(1); // error
int x;
foo(x); // e
On Sunday, April 01, 2018 22:06:57 Boris-Barboris via Digitalmars-d-learn
wrote:
> On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer
>
> wrote:
> > I currently have a situation where I want to have a function
> > that accepts a parameter optionally.
>
> I would simply use a pointer for
On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer
wrote:
I currently have a situation where I want to have a function
that accepts a parameter optionally.
I would simply use a pointer for this. Fighting D grammar seems
too much of a hassle for such simple task.
On Sunday, April 01, 2018 11:54:16 Steven Schveighoffer via Digitalmars-d-
learn wrote:
> I currently have a situation where I want to have a function that
> accepts a parameter optionally.
>
> I thought maybe Nullable!int might work:
>
> void foo(Nullable!int) {}
>
> void main()
> {
> foo(1);
On Sunday, 1 April 2018 at 15:54:16 UTC, Steven Schveighoffer
wrote:
void main()
{
foo(1); // error
int x;
foo(x); // error
}
For the first line, I had the same problem a while ago...
https://issues.dlang.org/show_bug.cgi?id=15792
On Sunday, 1 April 2018 at 10:59:55 UTC, Alexandru jercaianu
wrote:
On Saturday, 31 March 2018 at 20:17:26 UTC, Per Nordlöw wrote:
On Friday, 30 March 2018 at 23:09:33 UTC, Alexandru Jercaianu
wrote:
Hello,
You can try the following:
struct Node
{
char[64] arr;
}
enum
Hello! I implement a GTK-D based application for Windows and
Linux. In case of Linux there isn't any problem, I use binding[1]
for libkeybinder. In case of Windows I can't find convinient way
to implement global shortcuts. There is a way to get it done is
use of WinAPI but it's not convinient b
On 2018-04-01 17:54, Steven Schveighoffer wrote:
I currently have a situation where I want to have a function that
accepts a parameter optionally.
I thought maybe Nullable!int might work:
void foo(Nullable!int) {}
void main()
{
foo(1); // error
int x;
foo(x); // error
}
Apparentl
I currently have a situation where I want to have a function that
accepts a parameter optionally.
I thought maybe Nullable!int might work:
void foo(Nullable!int) {}
void main()
{
foo(1); // error
int x;
foo(x); // error
}
Apparently, I have to manually wrap an int to get it to pass.
On Saturday, 31 March 2018 at 20:17:26 UTC, Per Nordlöw wrote:
On Friday, 30 March 2018 at 23:09:33 UTC, Alexandru Jercaianu
wrote:
Hello,
You can try the following:
struct Node
{
char[64] arr;
}
enum numNodes = 100_000_000;
void[] buf = GCAllocator.instance.alloc
On Sunday, 1 April 2018 at 02:44:32 UTC, Uknown wrote:
If you want to stop auto-decoding, you can use
std.string.representation like this:
import std.string : representation;
auto no_decode = some_string.representation;
Now no_decode wont be auto-decoded, and you can use it in place
of some_s
17 matches
Mail list logo