Re: How to test that the IP port is reachable?

2019-04-05 Thread FrankLike via Digitalmars-d-learn
On Saturday, 6 April 2019 at 03:24:04 UTC, FrankLike wrote: Hi,everyone,... Do you have some better code than this? import std.stdio; import std.socket; void main() { testIPPort(); } bool testIPPort() { try

Re: Block statements and memory management

2019-04-05 Thread Murilo via Digitalmars-d-learn
On Saturday, 16 March 2019 at 15:53:26 UTC, Johan Engelen wrote: On Saturday, 16 March 2019 at 03:47:43 UTC, Murilo wrote: Does anyone know if when I create a variable inside a scope as in {int a = 10;} it disappears complete from the memory when the scope finishes? Or does it remain in some p

How to test that the IP port is reachable?

2019-04-05 Thread FrankLike via Digitalmars-d-learn
Hi,everyone, How to test that the IP port is reachable? In C,you can do this like that, what should I do in D? /* C Code*/ https://blog.csdn.net/zhangyingchuang/article/details/51957552 #include #include #include #include #include     /* inet(3) functions */ #define bool int #define false

Re: Undescriptive linker error. (bug?)

2019-04-05 Thread Sjoerd Nijboer via Digitalmars-d-learn
On Friday, 5 April 2019 at 22:08:50 UTC, Adam D. Ruppe wrote: Weird combination of cases that maybe should be illegal. It errors with the highly descriptive errormessage: app.obj(app) Error 42: Symbol Undefined __D8mymodule3BarFZ3fooMFZCQx3Foo Error: linker exited with status 1

Re: Undescriptive linker error. (bug?)

2019-04-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 April 2019 at 21:59:35 UTC, Sjoerd Nijboer wrote: Foo Bar() { Foo foo(); It looks like the compiler is treating that as a function prototype without a body (that just happens to be nested in another function). return foo; And then, this foo is given the optio

Undescriptive linker error. (bug?)

2019-04-05 Thread Sjoerd Nijboer via Digitalmars-d-learn
module mymodule; class Foo{} Foo Bar() { Foo foo(); return foo; } int main() { auto foo = Bar(); return 0; } This code doesn't compile with a linker error that there's a missing symbol for `Foo Bar()` on windows. After all, `Foo foo();` isn't legitimate

Re: Using opOpAssign, cannot assign sequence

2019-04-05 Thread Paul Backus via Digitalmars-d-learn
On Friday, 5 April 2019 at 13:59:27 UTC, Alex wrote: class X(T) void opOpAssign(string op)(T d) If T has more than length of one then x += We can work around this but it seems to me that we should be able to get it to work in some way x += Alias!(a,b,c) fails to package it up

Re: Using opOpAssign, cannot assign sequence

2019-04-05 Thread ag0aep6g via Digitalmars-d-learn
On 05.04.19 16:00, Alex wrote: I was thinking using tuple would work(of course is longer than Add but would allow for a more general approach, it would require automatic unpacking though and so doesn't work. `tuple` works for me: import std.typecons: tuple; class X(T ...) { void opO

== comparison of string literals, and their usage

2019-04-05 Thread diniz via Digitalmars-d-learn
Hello, Since literal strings are interned (and immutable), can I count on the fact that they are compared (==) by pointer? Context: The use case is a custom lexer for a custom language. I initially wanted to represent lexeme classes by a big enum 'LexClass'. However, this makes me write 3 ti

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-05 Thread Adam D. Ruppe via Digitalmars-d-learn
BTW `T.stringof` is usually a bug waiting to happen. You are using mixin in a lot of places where you shouldn't be and this is going to lead to name conflicts, import problems, and more. Just use `T`. If you need a member, use __traits(getMember, T, "name").

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-05 Thread Adam D. Ruppe via Digitalmars-d-learn
On Friday, 5 April 2019 at 14:38:21 UTC, Alex wrote: No one has a clue about this? Your code has a lot of layers to unfold, but instead let me just show you a working example and then maybe you can fix your own code: --- class A { void foo(int a) {} void foo(int b, int c) {}

Re: gtkDcoding Blog: Post #0024 - Switch and LightSwitch

2019-04-05 Thread Ron Tarrant via Digitalmars-d-learn
On Friday, 5 April 2019 at 14:05:55 UTC, Russel Winder wrote: I get the feeling this blog is going to become an important tutorial resource for people wanting to do GtkD stuff with D. Given D and GtkD is currently the best way of writing Gtk+ applications, this blog is a great resource. Thank

Re: template with enum parameter doesn't compile

2019-04-05 Thread Sjoerd Nijboer via Digitalmars-d-learn
On Friday, 5 April 2019 at 14:52:05 UTC, lithium iodate wrote: You are just having a little issue with operator precedence there. Your code attempts to get the member `A` from `MyClass!MyEnum`, if you add braces around it, it'll work just fine `MyClass!(MyEnum.A)`. That's really funny acutal

Re: template with enum parameter doesn't compile

2019-04-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 5 April 2019 at 14:47:42 UTC, Sjoerd Nijboer wrote: So the following code doesn't compile for some reason, and I can't figure out why. enum MyEnum { A, B, C } class MyClass(MyEnum myEnum) { /*...*/ } int main() { MyClass!MyEnum.A a; } The error: Error: template instan

Re: template with enum parameter doesn't compile

2019-04-05 Thread lithium iodate via Digitalmars-d-learn
On Friday, 5 April 2019 at 14:47:42 UTC, Sjoerd Nijboer wrote: So the following code doesn't compile for some reason, and I can't figure out why. The error: Error: template instance `MyClass!(MyEnum)` does not match template declaration `MyClass(MyEnum myEnum)` pops up, no matter what I do.

template with enum parameter doesn't compile

2019-04-05 Thread Sjoerd Nijboer via Digitalmars-d-learn
So the following code doesn't compile for some reason, and I can't figure out why. enum MyEnum { A, B, C } class MyClass(MyEnum myEnum) { /*...*/ } int main() { MyClass!MyEnum.A a; } The error: Error: template instance `MyClass!(MyEnum)` does not match template declaration `MyCl

Re: Overloads not returning appropriate info. [Field reflunkory]

2019-04-05 Thread Alex via Digitalmars-d-learn
No one has a clue about this?

Re: gtkDcoding Blog: Post #0024 - Switch and LightSwitch

2019-04-05 Thread Russel Winder via Digitalmars-d-learn
I get the feeling this blog is going to become an important tutorial resource for people wanting to do GtkD stuff with D. Given D and GtkD is currently the best way of writing Gtk+ applications, this blog is a great resource. On Fri, 2019-04-05 at 13:44 +, Ron Tarrant via Digitalmars-d-learn w

Re: Using opOpAssign, cannot assign sequence

2019-04-05 Thread Alex via Digitalmars-d-learn
On Friday, 5 April 2019 at 13:59:27 UTC, Alex wrote: class X(T) void opOpAssign(string op)(T d) If T has more than length of one then x += We can work around this but it seems to me that we should be able to get it to work in some way x += Alias!(a,b,c) fails to package it up

Using opOpAssign, cannot assign sequence

2019-04-05 Thread Alex via Digitalmars-d-learn
class X(T) void opOpAssign(string op)(T d) If T has more than length of one then x += We can work around this but it seems to me that we should be able to get it to work in some way x += Alias!(a,b,c) fails to package it up as do all other things I have tried. void Add(Ts d) {

Re: gtkDcoding Blog: Post #0024 - Switch and LightSwitch

2019-04-05 Thread Ron Tarrant via Digitalmars-d-learn
On Friday, 5 April 2019 at 13:44:35 UTC, Ron Tarrant wrote: Since the forum seems to have trouble with replies to existing posts, for now I'll be doing a separate post for each. Hope that doesn't get anyone's nose out of joint. Anyway... Today we explore the GTK Switch widget with two example

gtkDcoding Blog: Post #0024 - Switch and LightSwitch

2019-04-05 Thread Ron Tarrant via Digitalmars-d-learn
Since the forum seems to have trouble with replies to existing posts, for now I'll be doing a separate post for each. Hope that doesn't get anyone's nose out of joint. Anyway... Today we explore the GTK Switch widget with two examples, a simple one and a complex one. Enjoy.