On Tuesday, 10 July 2018 at 20:57:02 UTC, Steven Schveighoffer
wrote:
On 7/10/18 4:02 PM, Per Nordlöw wrote:
On Tuesday, 10 July 2018 at 19:27:07 UTC, Steven Schveighoffer
wrote:
On 7/10/18 3:01 PM, Per Nordlöw wrote:
[...]
Yes, call this function on startup:
import etc.linux :
On Tuesday, 10 July 2018 at 22:53:25 UTC, kdevel wrote:
extern (C) __gshared bool rt_trapExceptions;
static this ()
{
rt_trapExceptions = false;
}
This will catch exceptions raised in main and in static
constructors that run after this one. However, if you put that
code in
On Tuesday, 10 July 2018 at 22:31:54 UTC, Adam D. Ruppe wrote:
Turn off rtTrapExceptions
though the command line switch PR is STILL NOT MERGED
https://github.com/dlang/druntime/pull/2035
extern (C) __gshared bool rt_trapExceptions;
static this ()
{
rt_trapExceptions =
On Tuesday, 10 July 2018 at 21:18:01 UTC, kdevel wrote:
but how do I force the runtime to generate a coredump for real
post-mortem analysis?
Turn off rtTrapExceptions
though the command line switch PR is STILL NOT MERGED
https://github.com/dlang/druntime/pull/2035
come on, people.
u'd have to have a special runtime, and change the
constructor for RangeError to access a null pointer.
-Steve
On Tuesday, 10 July 2018 at 19:27:07 UTC, Steven Schveighoffer
wrote:
import etc.linux : registerMemoryErrorHandler;
Needs to be:
import etc.linux.memoryerror : registerMemoryErrorHandler;
On Tuesday, 10 July 2018 at 21:09:23 UTC, Steven Schveighoffer
wrote:
[...]
As far as the OS is concerned, a[2 .. $] is within the process
memory limit.
Of course, that's an out of bounds access, so the compiler or
the bounds check *should* complain.
It complains at runtime
> ./dumpme2
On 7/10/18 5:01 PM, kdevel wrote:
On Tuesday, 10 July 2018 at 20:10:54 UTC, Adam D. Ruppe wrote:
On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote:
[...]
Run the program in a debugger, or run `ulimit -c unlimited` to enable
core dumps [...]
Works for null ptr deref but how do I
On Tuesday, 10 July 2018 at 20:10:54 UTC, Adam D. Ruppe wrote:
On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote:
[...]
Run the program in a debugger, or run `ulimit -c unlimited` to
enable core dumps [...]
Works for null ptr deref but how do I enforce core dumps in this
code
On 7/10/18 4:02 PM, Per Nordlöw wrote:
On Tuesday, 10 July 2018 at 19:27:07 UTC, Steven Schveighoffer wrote:
On 7/10/18 3:01 PM, Per Nordlöw wrote:
Is it possible to change run-time behaviour of null-class
dereferencing, on Linux, so that it gives some other diagnostics than:
Program exited
On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote:
Is it possible to change run-time behaviour of null-class
dereferencing, on Linux, so that it gives some other
diagnostics than:
Program exited with code -11
Does DMD and LDC provide different alternatives here?
On a Systemd
On Tuesday, 10 July 2018 at 19:01:22 UTC, Per Nordlöw wrote:
Is it possible to change run-time behaviour of null-class
dereferencing, on Linux, so that it gives some other
diagnostics than:
Run the program in a debugger, or run `ulimit -c unlimited` to
enable core dumps so you can run
On Tuesday, 10 July 2018 at 19:27:07 UTC, Steven Schveighoffer
wrote:
On 7/10/18 3:01 PM, Per Nordlöw wrote:
Is it possible to change run-time behaviour of null-class
dereferencing, on Linux, so that it gives some other
diagnostics than:
Program exited with code -11
Does DMD and LDC provide
On 7/10/18 3:01 PM, Per Nordlöw wrote:
Is it possible to change run-time behaviour of null-class dereferencing,
on Linux, so that it gives some other diagnostics than:
Program exited with code -11
Does DMD and LDC provide different alternatives here?
Yes, call this function on startup
Is it possible to change run-time behaviour of null-class
dereferencing, on Linux, so that it gives some other diagnostics
than:
Program exited with code -11
Does DMD and LDC provide different alternatives here?
On Monday, 9 July 2018 at 09:38:30 UTC, ag0aep6g wrote:
The `win` you're creating in `init` is a function-local
variable. It ceases to exist when `init` returns. It's not
`this.win`.
In `run`, you're accessing `this.win`. It's still null because
you never assigned anything there.
So change
On 07/09/2018 11:18 AM, Flaze07 wrote:
class Game
{
[...]
RenderWindow win;
[...]
void init()
{
[...]
auto win = new RenderWindow( VideoMode( 600, 600 ), "snake" );
[...]
}
void run()
{
[...]
writeln( w
On Monday, 9 July 2018 at 09:18:50 UTC, Flaze07 wrote:
I am using DSFML
module game;
[...]
oh, and I forgot, I had
Game myGame;
static this()
{
myGame = new Game;
}
below the Game class
e / 2, Vector2f( win.size.x,
win.size.y ) );
}
void run()
{
auto clock = new Clock;
writeln( win is null );
while( win.isOpen() )
{
writeln("lol" );
}
}
}
the problem here is, during init(), the writeln will output
false, whic
On Tuesday, 5 June 2018 at 14:52:28 UTC, Timoses wrote:
Does `int[4] nums = void` work?
Work for what?
If you avoid initialization, then the variable(s) are not
initialized.
https://dlang.org/spec/declaration.html#void_init
However, an int is not nullable and always contains a value.
On Saturday, 2 June 2018 at 18:10:38 UTC, eastanon wrote:
Does D array implementation support an array of null values?
int a[4] = null;
But I ran into a type error while checking if a[i] is null
foreach(i; 0..3){
if(i == null){
writeln("it is null");
}
}
}
How do you set
On 06/02/2018 08:35 PM, Neia Neutuladh wrote:
2. `int[4] a = null` treats the initialization as a copy from an array
whose value is null. If you run just that line of code, it will produce
an error at runtime: "object.Error@(0): Array lengths don't match for
copy: 0 != 4"
I
On Saturday, 2 June 2018 at 18:10:38 UTC, eastanon wrote:
Does D array implementation support an array of null values?
int a[4] = null;
But I ran into a type error while checking if a[i] is null
foreach(i; 0..3){
if(i == null){
writeln("it is null");
}
}
}
How do you set
Does D array implementation support an array of null values?
int a[4] = null;
But I ran into a type error while checking if a[i] is null
foreach(i; 0..3){
if(i == null){
writeln("it is null");
}
}
}
How do you set fixed size array of null values and check if they
are null?
On Saturday, 19 May 2018 at 17:33:08 UTC, Robert M. Münch wrote:
On 2018-05-18 14:42:17 +, Adam D. Ruppe said:
A value struct return is actually done via a hidden pointer
parameter (so the function can construct it in-place for the
caller, a standard optimization), so it just shifted all
On 2018-05-18 14:42:17 +, Adam D. Ruppe said:
On Friday, 18 May 2018 at 14:06:11 UTC, Robert M. Münch wrote:
So, having a wrong return-type here, resulted in the const char *text
parameter always being NULL. Not sure I understand the relation but
looks strange to me... at least not very
On Friday, 18 May 2018 at 14:06:11 UTC, Robert M. Münch wrote:
So, having a wrong return-type here, resulted in the const char
*text parameter always being NULL. Not sure I understand the
relation but looks strange to me... at least not very obvious.
A value struct return is actually done via
? That was causing the problem.
So, having a wrong return-type here, resulted in the const char *text
parameter always being NULL. Not sure I understand the relation but
looks strange to me... at least not very obvious.
--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster
it like this:
result = myfunc(0, 0, std.string.toStringz("1"), stuff, true);
The problem is, that on the DLL side *text is always NULL. I doesn't
matter what I put as third argument. And even more strange, I have an
other function with a const char* as first argument. There
, std.string.toStringz("1"), stuff, true);
The problem is, that on the DLL side *text is always NULL. I doesn't
matter what I put as third argument. And even more strange, I have an
other function with a const char* as first argument. There everything
is working...
Any idea what cause
ingz isn't necessary, string literals always are null terminated,
and implicitly cast to const char *.
The problem is, that on the DLL side *text is always NULL. I doesn't
matter what I put as third argument. And even more strange, I have an
other function with a const char* as first argument. There
I have an extern(C) function in a DLL with this signature:
result* myfunc(double x, double y, const char *text, stuff *myStuff,
bool flag);
I call it like this:
result = myfunc(0, 0, std.string.toStringz("1"), stuff, true);
The problem is, that on the DLL side *text is alwa
he problem is, that on the DLL side *text is always NULL. I doesn't
matter what I put as third argument. And even more strange, I have an
other function with a const char* as first argument. There everything is
working...
Any idea what cause this could be? This is really strange...
Please post the
On Sunday, 8 April 2018 at 15:51:05 UTC, Paul Backus wrote:
On Sunday, 8 April 2018 at 15:04:49 UTC, number wrote:
writeln(s2);// S2(0, null)
S2 is a nested struct [1], which means it has a hidden pointer
field that's used to access its enclosing scope. If you change
On Monday, April 09, 2018 00:25:08 solidstate1991 via Digitalmars-d-learn
wrote:
> Would the if(!(myFunctionPointer is null)){} work is I
> intended?
You can also do
if(myFunctionPointer !is null)
- Jonathan M Davis
On Monday, 9 April 2018 at 00:25:08 UTC, solidstate1991 wrote:
Would the if(!(myFunctionPointer is null)){} work is I
intended?
Yes, that works as you expect
https://run.dlang.io/is/ZTtm0P
Would the if(!(myFunctionPointer is null)){} work is I
intended?
On Sunday, 8 April 2018 at 15:04:49 UTC, number wrote:
the write() shows a 'null' if the struct has a function/method.
why is that?
```
import std.stdio;
void main()
{
struct S
{
int i;
}
S s;
writeln(s);// S(0
the write() shows a 'null' if the struct has a function/method.
why is that?
```
import std.stdio;
void main()
{
struct S
{
int i;
}
S s;
writeln(s);// S(0)
writeln(typeid(s).sizeof); // 8
struct S2
On Thursday, 8 March 2018 at 08:04:54 UTC, Nick Sabalausky
(Abscissa) wrote:
Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't
appear to work on run.dlang.io). But it does seem to work for
me if I use 'v0.8.3-alpha.1'.
I wonder what could have changed to result in this?
It's a
On 03/08/2018 03:04 AM, Nick Sabalausky (Abscissa) wrote:
Interesting. I was using vibe.d 'v0.8.3-rc.1' (which doesn't appear to
work on run.dlang.io). But it does seem to work for me if I use
'v0.8.3-alpha.1'.
I wonder what could have changed to result in this?
On 03/08/2018 01:13 AM, Nicholas Wilson wrote:
That does seem odd.
---
/+dub.sdl:
dependency "vibe-d" version="~>0.8.3-alpha.1"
+/
import vibe.core.net;
import std.stdio;
TCPConnection mySocket;
void main() {
auto b = mySocket is null;
writeln(b);
}
---
wor
On Thursday, 8 March 2018 at 04:48:08 UTC, Nick Sabalausky
(Abscissa) wrote:
-
import vibe.core.net;
TCPConnection mySocket;
void main() {
auto b = mySocket is null;
}
-
That's giving me:
-
Error: incompatible types for (mySocket
-
import vibe.core.net;
TCPConnection mySocket;
void main() {
auto b = mySocket is null;
}
-
That's giving me:
-
Error: incompatible types for (mySocket) is (null): TCPConnection and
typeof(null)
-
WTF
And https://github.com/Extrawurst/DerelictFmod/issues/1
*) a`
instead to print the address of the object itself.
writeln(); // null
Though why it would ever say null is weird. Maybe one of the
lengths you pass to a C function is wrong and it is writing too
far and killing one of the hidden thread local pointer
variables.
The problem isn't
.
writeln(); // null
Though why it would ever say null is weird. Maybe one of the
lengths you pass to a C function is wrong and it is writing too
far and killing one of the hidden thread local pointer variables.
I'm using the derelict fmod bindings to handle sounds in my
application and I'm running into a weird bug... If I put calls to
fmod in a function inside a class, upon calling those functions
the instance of that class will be null, or otherwise changed. I
obviously get an access violation if I
On 28-10-17 16:22, Nicholas Wilson wrote:
On Saturday, 28 October 2017 at 14:19:01 UTC, Nicholas Wilson wrote:
As Basile mentioned, this is compiler sticking checks in behind your
back.
The reason it works on new LDC is because #6982 was cherry picked to
LDC (1.3?) before it was merged into
On Saturday, 28 October 2017 at 14:19:01 UTC, Nicholas Wilson
wrote:
As Basile mentioned, this is compiler sticking checks in behind
your back.
The reason it works on new LDC is because #6982 was cherry
picked to LDC (1.3?) before it was merged into dmd (not sure
what version, I though it was
this;
}
}
void main()
{
A a = null;
B b = null;
auto c = cast(Object)a;
auto d = cast(Object)b; // Fails with:
core.exception.AssertError@test.d(8): null this
}
```
How would you write an opCast that would handle this case
correctly?
Testing if this is null
this;
}
}
void main()
{
A a = null;
B b = null;
auto c = cast(Object)a;
auto d = cast(Object)b; // Fails with:
core.exception.AssertError@test.d(8): null this
}
```
How would you write an opCast that would handle this case
correctly?
Compiler change is required
The following code runs correctly when compiled with ldc (1.4.0) but
fails with an assert error when compiled with dmd (2.076 and ldc 1.2.0)
```
class A
{
}
class B
{
T opCast(T)()
{
return this;
}
}
void main()
{
A a = null;
B b
, the in contract does actually enforce the requirement.
And adds null pointer checks even when clearly not needed.
Clearly not needed? I thought the point was to ensure the reference is
not null?
I meant code like this: `k->something(); foo(*k);` or `auto k = new
Klass(); foo(*k);`.
Anyway, the po
passing a pointer.
Come on Steven, I thought you knew I am a compiler dev.
The caller _is_ doing dereferencing. That's what the '*' means
semantically and it matters. [1]
However, the in contract does actually enforce the
requirement.
And adds null pointer checks even when clearly not needed
On 8/8/17 4:00 PM, Andre Kostur wrote:
On 2017-08-08 12:38 PM, Steven Schveighoffer wrote:
On 8/8/17 2:56 PM, ag0aep6g wrote:
On 08/08/2017 08:34 PM, Johan Engelen wrote:
How would you express the function interface intent that a
reference to a class may not be null?
For a function "
On 8/8/17 3:59 PM, Johan Engelen wrote:
On Tuesday, 8 August 2017 at 19:38:19 UTC, Steven Schveighoffer wrote:
Note that C++ also can do this, so I'm not sure the & is accomplishing
the correct goal:
void foo(Klass&);
int main()
{
Klass *k = NULL;
foo(*k);
}
In C++, it
Am Tue, 08 Aug 2017 20:48:39 +
schrieb Nordlöw :
> Has anybody written a wrapper around `std.file.readText` (or
> similar) that appends a final zero-byte terminator in order to
> realize sentinel-based search in textual parsers.
What do you mean by similar? There are
Has anybody written a wrapper around `std.file.readText` (or
similar) that appends a final zero-byte terminator in order to
realize sentinel-based search in textual parsers.
I was about to say "use NotNull" but there still isn't one in
std.typecons. ugh.
But it is just a wrapper type that checks null in the contracts
too, so you can do it at the function itself.
On 2017-08-08 12:38 PM, Steven Schveighoffer wrote:
On 8/8/17 2:56 PM, ag0aep6g wrote:
On 08/08/2017 08:34 PM, Johan Engelen wrote:
How would you express the function interface intent that a
reference to a class may not be null?
For a function "void foo(Klass)", calling "foo(
On Tuesday, 8 August 2017 at 19:38:19 UTC, Steven Schveighoffer
wrote:
Note that C++ also can do this, so I'm not sure the & is
accomplishing the correct goal:
void foo(Klass&);
int main()
{
Klass *k = NULL;
foo(*k);
}
In C++, it is clear that the _caller_ is doing the deref
On Tuesday, 8 August 2017 at 18:57:48 UTC, Steven Schveighoffer
wrote:
On 8/8/17 2:34 PM, Johan Engelen wrote:
Hi all,
How would you express the function interface intent that a
reference to a class may not be null?
For a function "void foo(Klass)", calling "foo(null)"
On 8/8/17 2:56 PM, ag0aep6g wrote:
On 08/08/2017 08:34 PM, Johan Engelen wrote:
How would you express the function interface intent that a
reference to a class may not be null?
For a function "void foo(Klass)", calling "foo(null)" is valid. How do
I express that tha
On 08/08/2017 08:34 PM, Johan Engelen wrote:
How would you express the function interface intent that a reference
to a class may not be null?
For a function "void foo(Klass)", calling "foo(null)" is valid. How do I
express that that is invalid? (let's leave erroring
On 8/8/17 2:34 PM, Johan Engelen wrote:
Hi all,
How would you express the function interface intent that a reference
to a class may not be null?
For a function "void foo(Klass)", calling "foo(null)" is valid. How do I
express that that is invalid? (let's leave erroring
Hi all,
How would you express the function interface intent that a
reference to a class may not be null?
For a function "void foo(Klass)", calling "foo(null)" is valid.
How do I express that that is invalid? (let's leave erroring with
a compile error aside for now)
the
destructor must be callable on .init so you might do like
struct Foo {
int* ptr;
~this() {
// might be called with ptr is null cuz of .init
// so wanna check
if(ptr !is null) free(ptr);
}
}
Ah, yes, exactly. The page is indeed the same one.
P.S. Though it's fine to call
Foo {
int* ptr;
~this() {
// might be called with ptr is null cuz of .init
// so wanna check
if(ptr !is null) free(ptr);
}
}
On Monday, 22 May 2017 at 00:23:26 UTC, Adam D. Ruppe wrote:
On Sunday, 21 May 2017 at 14:13:20 UTC, Stanislav Blinov wrote:
Not if you either emplace() or blit Foo.init into all of the
array elements.
You especially need to be safe calling ~this on Foo.init.
How so? .init is supposed to be
On Sunday, 21 May 2017 at 14:13:20 UTC, Stanislav Blinov wrote:
Not if you either emplace() or blit Foo.init into all of the
array elements.
You especially need to be safe calling ~this on Foo.init.
On Sunday, 21 May 2017 at 23:59:08 UTC, Guillaume Piolat wrote:
On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote:
Any struct should be able to have its destructor called
Does this rule also applies to class objects?
Yes. If your destructor does modify the state, you should expect
On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote:
Any struct should be able to have its destructor called
Does this rule also applies to class objects?
On Sunday, 21 May 2017 at 12:48:10 UTC, Adam D. Ruppe wrote:
On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote:
// Why is this._foo null here???
The others have answered why and what to do, but note that
according to the spec, that any struct should be able
On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote:
// Why is this._foo null here???
The others have answered why and what to do, but note that
according to the spec, that any struct should be able to have its
destructor called, so you should do a null check
On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote:
Looks like you would want to use emplace [0] here.
public this(int n)
{
this._data = (cast(Foo*) calloc(n, Foo.sizeof))[0 .. n];
foreach(ref element; this._data)
{
On Saturday, 20 May 2017 at 12:25:39 UTC, Stanislav Blinov wrote:
Oof. Dangerous stuff.
:)
Thanks for the heads up but I think I'm covering all cases in my
main code.
On Saturday, 20 May 2017 at 11:15:57 UTC, Moritz Maxeiner wrote:
Because `element = tmp` destroys `element`, which you allocated
filled with zeroes.
The destructor will run for each `element`.
Right, I get it because the destructors running on the struct
that is being replaced. Doh!
On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote:
In the following code, the `_foo` pointer (of the Foo struct)
is null in the first call to the destructor. Why is this? I
think it's got something to do with the foreach loop but I'm
not sure. Any ideas?
Oof. Dangerous stuff
On Saturday, 20 May 2017 at 10:48:54 UTC, Gary Willoughby wrote:
In the following code, the `_foo` pointer (of the Foo struct)
is null in the first call to the destructor. Why is this? I
think it's got something to do with the foreach loop but I'm
not sure. Any ideas?
struct Bar
In the following code, the `_foo` pointer (of the Foo struct) is
null in the first call to the destructor. Why is this? I think
it's got something to do with the foreach loop but I'm not sure.
Any ideas?
import std.stdio;
import core.stdc.stdlib : malloc, calloc, free;
struct Foo
with a null string if there
wasn't one.
I used to write:
string header;
if(auto e = document.querySelector("h1"))
header = e.innerText;
but now i can write:
string header = document.optionSelector("h1").innerText;
http://dpldocs.info/experimental-docs/arsd.dom.Element.optionS
On Tuesday, March 14, 2017 00:51:02 Jolly James via Digitalmars-d-learn
wrote:
> Does anybody know, if D has a null-safe dereference operator like
> C# does (?.) or something similar?
It does not, though if you really wanted to, you could probably create
template that did the same thing
On Monday, 21 November 2016 at 10:25:17 UTC, Satoshi wrote:
Hello,
how can calling method on local struct throw "null this"?
struct is initialized by .init and have default values.
struct Foo {
Bar bar;
static struct Bar {
float x, y, z;
}
Bar getBar() {
On 21/11/2016 11:25 PM, Satoshi wrote:
Hello,
how can calling method on local struct throw "null this"?
struct is initialized by .init and have default values.
struct Foo {
Bar bar;
static struct Bar {
float x, y, z;
}
Bar getBar() {
return bar;
}
}
then
Foo foo
cast(ulong) but is not null.
It won't work just in special cases what I cannot reproduce
easily.
Hello,
how can calling method on local struct throw "null this"?
struct is initialized by .init and have default values.
struct Foo {
Bar bar;
static struct Bar {
float x, y, z;
}
Bar getBar() {
return bar;
}
}
then
Foo foo = Foo.init;
auto b = foo.getBar(); // throw "null this"
On Thursday, 22 September 2016 at 19:51:31 UTC, Nordlöw wrote:
A known bug?
Yeah, it shows the line before instead of the line of. But it
still shows basically where you are.
p.s. that is the reason it is not turned on by default, btw.
On Thursday, 22 September 2016 at 19:51:31 UTC, Nordlöw wrote:
A known bug?
prolly. segfault handler is highly non-standard hack, it may miss
exact position or something. as is "it is not guaranteed to work,
and if it will work, it is not guaranteed to work correctly".
On Thursday, 22 September 2016 at 00:46:19 UTC, ketmar wrote:
{ import etc.linux.memoryerror; registerMemoryErrorHandler(); }
Thx! That at least triggered an exception. However the line
number for the innermost function is wrong. For instance
1 void boom()
2 {
3 int* y = null;
4
On Wednesday, 21 September 2016 at 23:36:08 UTC, Nordlöw wrote:
Doing a null deref such as
int* y = null;
*y = 42;// boom
[...]
Can you include compiler command line? I use -g -gs -debug to
get stack traces on windows.
On Wednesday, 21 September 2016 at 23:36:08 UTC, Nordlöw wrote:
Is there a way to get a stacktrace instead?
{ import etc.linux.memoryerror; registerMemoryErrorHandler(); }
warning: this is hightly system-specific, and may work or not
work depending of the moon phase, and may broke on any
Doing a null deref such as
int* y = null;
*y = 42;// boom
currently outputs
/home/per/.emacs.d/auto-builds/dmd/Debug-Unittest-Require-Full-Coverage/home/per/foo[0x406474]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x113d0)[0x7f08cf25e3d0]
/home/per/.emacs.d/auto-builds
On Sunday, 31 July 2016 at 05:41:55 UTC, AntonSotov wrote:
2 Seb
Thank you!
is (T: typeof (null)) - very comfortable
An example of Seb's warning:
What happens if you have:
string s = null;
MyFunc(s);
I'm guessing it doesn't do what you want. But it isn't clear what
you want - null
2 Seb
Thank you!
is (T: typeof (null)) - very comfortable
// WHAT HERE ?
writeln("null");
}
}
int main(string[] args)
{
myFunc("abc");
myFunc(123);
myFunc(null);
return 0;
}
//--
How to transfer as parameter type?
just have a look with pragma
import std.stdio;
void myFunc(T)(in T val) {
static if(is(T == string)) {
writeln("string: ", val);
}
static if(is(T : long)) {
writeln("long: ", val);
}
static if // WHAT HERE ?
writeln("null");
On 07/25/2016 05:47 PM, Adam D. Ruppe wrote:
> On Monday, 25 July 2016 at 13:09:22 UTC, Bahman Movaqar wrote:
>> From what I could gather, it's not possible to check for `null` at
>> runtime for reference based types. Am I right?
>
> No, it is only possible to check for nul
On Monday, 25 July 2016 at 13:09:22 UTC, Bahman Movaqar wrote:
From what I could gather, it's not possible to check for `null`
at
runtime for reference based types. Am I right?
No, it is only possible to check for null for reference based
types. But map's result is not a reference based
301 - 400 of 860 matches
Mail list logo