Re: Testing for object property supporting "<" comparison

2021-05-11 Thread Chris Piker via Digitalmars-d-learn

On Wednesday, 12 May 2021 at 00:06:52 UTC, Paul Backus wrote:

On Tuesday, 11 May 2021 at 19:42:34 UTC, Chris Piker wrote:

std.traits.isOrderingComparable

https://phobos.dpldocs.info/std.traits.isOrderingComparable.html


Well I feel sheepish, don't know how I missed that one.  Hey 
thanks for pointing it out.


Re: Testing for object property supporting "<" comparison

2021-05-11 Thread Paul Backus via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 19:42:34 UTC, Chris Piker wrote:
My problem is that I don't know how to specify that properties 
must be comparable via "<".  I took a look at the Traits 
module, but there are more things that are comparable then 
Arithmetic or Floating point types.  Also, since the compiler 
will catch objects that don't have these properties, maybe an 
enum check is not worth implementing.


std.traits.isOrderingComparable

https://phobos.dpldocs.info/std.traits.isOrderingComparable.html


Re: Shutdown signals

2021-05-11 Thread Tim via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 06:59:10 UTC, Patrick Schluter wrote:

On Tuesday, 11 May 2021 at 06:44:57 UTC, Tim wrote:

On Monday, 10 May 2021 at 23:55:18 UTC, Adam D. Ruppe wrote:

[...]


I don't know why I didn't find that. I was searching for the 
full name, maybe too specific? Thanks anyways, this is super 
helpful. I wish it was documented better though :(


So why use sigaction and not signal? From what I can tell 
signal is the C way of doing things


Use `sigaction()`, `signal()` has problems. See this 
stackoverflow [1] question explains the details


[1]: 
https://stackoverflow.com/questions/231912/what-is-the-difference-between-sigaction-and-signal


Thanks a lot!


Testing for object property supporting "<" comparison

2021-05-11 Thread Chris Piker via Digitalmars-d-learn

Hi D

I'm working on a bit of code that handles selecting one *.front 
from multiple range-ish objects.  It's a select-or-drop algorithm 
for a data streaming service, the details aren't important.


The algorithm takes a range of something I'll call 
"PriorityRange" objects.  PriorityRange objects are like input 
ranges, but have a few extra members.  The set is:


  .empty :  Returns bool
  .front :  Returns something non-void
  .popFront():  Return void

  .priority  :  Returns something comparable via "<" to other
.priority values for all input PriortyRanges

  .min   :  Returns something comparable to .max below
via "<" for all input PriorityRanges

  .max   :  Returns something comparable to .min above
via "<" for all input PriorityRanges

I noticed the isInputRange(R) enum from std/range/primitives.d 
and am wondering how to setup a similar check, call it 
"isPriorityRange(PR)".


My problem is that I don't know how to specify that properties 
must be comparable via "<".  I took a look at the Traits module, 
but there are more things that are comparable then Arithmetic or 
Floating point types.  Also, since the compiler will catch 
objects that don't have these properties, maybe an enum check is 
not worth implementing.


Thanks very much for any advice you might have,
Cheers



Re: Is ldc not dependent on an a very old version of llvm ?

2021-05-11 Thread Imperatorn via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 12:02:12 UTC, Alain De Vos wrote:

We are currently at llvm12. Should i be worried ?


Why would that make you worry? You don't like the latest release? 
🤔


Re: Is ldc not dependent on an a very old version of llvm ?

2021-05-11 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 12:02:12 UTC, Alain De Vos wrote:

We are currently at llvm12. Should i be worried ?


On the release page you'll find:


Supports LLVM 6.0 - 12.0.


Note that it doesn't say 6.0, but 6.0 to 12.0.

https://github.com/ldc-developers/ldc/releases/tag/v1.26.0


Re: Is ldc not dependent on an a very old version of llvm ?

2021-05-11 Thread cmyka via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 12:02:12 UTC, Alain De Vos wrote:

We are currently at llvm12. Should i be worried ?


https://github.com/ldc-developers/ldc/tree/master/tools/ldc-profdata

it seems they support it on master?


Is ldc not dependent on an a very old version of llvm ?

2021-05-11 Thread Alain De Vos via Digitalmars-d-learn

We are currently at llvm12. Should i be worried ?


Re: Question about property & method access scope.

2021-05-11 Thread Vinod K Chandran via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 10:48:03 UTC, Mike Parker wrote:

On Tuesday, 11 May 2021 at 09:10:02 UTC, Vinod K Chandran wrote:

So in many situations, I need to check some boolean properties 
of Window class and call some functions of Window class in 
WndProc.
But I don't want to expose those props and functions to the 
user. So if I make them private, I can't access them inside 
the WndProc function. How do solve this issue. Thanks in 
advance.


Assuming window.d and wndproc.d are in the same package (and 
not the default global package), then you can use `package` 
instead of `private`.


On Tuesday, 11 May 2021 at 10:48:03 UTC, Mike Parker wrote:
>
> Assuming window.d and wndproc.d are in the same package (and
> not the default global package), then you can use `package`
> instead of `private`.

Thanks. "package" scope worked.
this is the code now.

```d
package :
bool misBkClrChanged ;
void setBkClrInternal(HDC dcHandle)
{
RECT rct;
HBRUSH hBr = CreateSolidBrush(cast(COLORREF) 
this.mBackColor);

GetClientRect(this.mHandle, &rct) ;
FillRect(dcHandle, &rct, hBr) ;
DeleteObject(hBr) ;
}
// And this is the wndproc
case WM_ERASEBKGND :
{
if(win.misBkClrChanged)
{
 auto dch = cast(HDC) wParam ;
 win.setBkClrInternal(dch) ;
 return 1 ;
 }  }
 break ;
}

```


Re: Question about property & method access scope.

2021-05-11 Thread Vinod K Chandran via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 10:47:15 UTC, cc wrote:



The `package` protection attribute should work here if the 
modules reside in the same package (directory)?


Thanks. "package" scope worked.


Re: Question about property & method access scope.

2021-05-11 Thread Mike Parker via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 09:10:02 UTC, Vinod K Chandran wrote:

So in many situations, I need to check some boolean properties 
of Window class and call some functions of Window class in 
WndProc.
But I don't want to expose those props and functions to the 
user. So if I make them private, I can't access them inside the 
WndProc function. How do solve this issue. Thanks in advance.


Assuming window.d and wndproc.d are in the same package (and not 
the default global package), then you can use `package` instead 
of `private`.


Re: Question about property & method access scope.

2021-05-11 Thread cc via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 09:10:02 UTC, Vinod K Chandran wrote:

Hi all,
I am practising D with a win api GUI hobby project.
I have a Window class and it resides in module window.d
My WndProc function resides in another module named 
wnd_proc_module.d

Inside my WndProc, I get the Window class like this.
```d
Window win = cast(Window) (cast(void*) GetWindowLongPtrW(hWnd, 
GWLP_USERDATA)) ;

```
So in many situations, I need to check some boolean properties 
of Window class and call some functions of Window class in 
WndProc.
But I don't want to expose those props and functions to the 
user. So if I make them private, I can't access them inside the 
WndProc function. How do solve this issue. Thanks in advance.


The `package` protection attribute should work here if the 
modules reside in the same package (directory)?


```d
module mywindow.window;
import mywindow.wnd_proc_module.d
class Window {
package int x, y;
}
```

```d
module mywindow.wnd_proc_module.d
import mywindow.window;
class Proc {
Window win;
void doStuff() {
win.x = 3;
}
}
```


Re: Question about property & method access scope.

2021-05-11 Thread drug via Digitalmars-d-learn

11.05.2021 12:10, Vinod K Chandran пишет:

Hi all,
I am practising D with a win api GUI hobby project.
I have a Window class and it resides in module window.d
My WndProc function resides in another module named wnd_proc_module.d
Inside my WndProc, I get the Window class like this.
```d
Window win = cast(Window) (cast(void*) GetWindowLongPtrW(hWnd, 
GWLP_USERDATA)) ;

```
So in many situations, I need to check some boolean properties of Window 
class and call some functions of Window class in WndProc.
But I don't want to expose those props and functions to the user. So if 
I make them private, I can't access them inside the WndProc function. 
How do solve this issue. Thanks in advance.


Make them `protected`?


Question about property & method access scope.

2021-05-11 Thread Vinod K Chandran via Digitalmars-d-learn

Hi all,
I am practising D with a win api GUI hobby project.
I have a Window class and it resides in module window.d
My WndProc function resides in another module named 
wnd_proc_module.d

Inside my WndProc, I get the Window class like this.
```d
Window win = cast(Window) (cast(void*) GetWindowLongPtrW(hWnd, 
GWLP_USERDATA)) ;

```
So in many situations, I need to check some boolean properties of 
Window class and call some functions of Window class in WndProc.
But I don't want to expose those props and functions to the user. 
So if I make them private, I can't access them inside the WndProc 
function. How do solve this issue. Thanks in advance.


Re: Shutdown signals

2021-05-11 Thread Patrick Schluter via Digitalmars-d-learn

On Tuesday, 11 May 2021 at 06:44:57 UTC, Tim wrote:

On Monday, 10 May 2021 at 23:55:18 UTC, Adam D. Ruppe wrote:

[...]


I don't know why I didn't find that. I was searching for the 
full name, maybe too specific? Thanks anyways, this is super 
helpful. I wish it was documented better though :(


So why use sigaction and not signal? From what I can tell 
signal is the C way of doing things


Use `sigaction()`, `signal()` has problems. See this 
stackoverflow [1] question explains the details


[1]: 
https://stackoverflow.com/questions/231912/what-is-the-difference-between-sigaction-and-signal