Re: Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread Jordan Wilson via Digitalmars-d-learn

On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote:

Hi,

I know with PyD, D can call Python, and with autowrap, Python 
can call a D .dll, I'm just wondering if someone can show an 
example that Python <==> d can call both ways? esp. show 
passing D objects to Python and then call its member function 
there, and vice versa.


Thanks.


When I did something like this, I used this as my inspiration:
https://github.com/ariovistus/pyd/tree/master/examples/testdll

So, I used PyD to supply D objects and read Python data also.

Thanks,

Jordan


Re: Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread mw via Digitalmars-d-learn

On Thursday, 23 June 2022 at 02:35:25 UTC, Tejas wrote:




IIRC the best you can do is embed a Python interpreter inside a 
D program


https://pyd.readthedocs.io/en/latest/embed.html


Thanks. I tried something like this:

https://github.com/symmetryinvestments/autowrap/issues/314


Although there were some compilation errors, I was able to built 
a dll and run.


Maybe that error message is not a real error.


Re: Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread Tejas via Digitalmars-d-learn

On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote:

Hi,

I know with PyD, D can call Python, and with autowrap, Python 
can call a D .dll, I'm just wondering if someone can show an 
example that Python <==> d can call both ways? esp. show 
passing D objects to Python and then call its member function 
there, and vice versa.


Thanks.


IIRC the best you can do is embed a Python interpreter inside a D 
program


https://pyd.readthedocs.io/en/latest/embed.html


Re: Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread Marvin via Digitalmars-d-learn

On Wednesday, 22 June 2022 at 16:02:00 UTC, mw wrote:

Hi,

I know with PyD, D can call Python, and with autowrap, Python 
can call a D .dll, I'm just wondering if someone can show an 
example that Python <==> d can call both ways? esp. show 
passing D objects to Python and then call its member function 
there, and vice versa.


Thanks.


I would also really like an example. Because it would be great to 
use Python and D together.


Python <==> d call both ways example (with PyD and autowrap)?

2022-06-22 Thread mw via Digitalmars-d-learn

Hi,

I know with PyD, D can call Python, and with autowrap, Python can 
call a D .dll, I'm just wondering if someone can show an example 
that Python <==> d can call both ways? esp. show passing D 
objects to Python and then call its member function there, and 
vice versa.


Thanks.


Re: nested function overloading

2022-06-22 Thread Steven Schveighoffer via Digitalmars-d-learn

On 6/22/22 2:05 AM, monkyyy wrote:

On Monday, 20 June 2022 at 13:20:51 UTC, Steven Schveighoffer wrote:

And you can also use an inner struct to define overloaded functions.


I believe templates make a better bandaid
```d
void main(){
 template bar(){
     void bar_(int){}
     void bar_(float){}
     alias bar=bar_;
 }
 bar(1);
 bar(3.14);
}
```


Wow, I never thought of that, it's a great idea! You don't even need to 
use the alias.


```d
void main(){
template bar(){
void bar(int){}
void bar(float){}
}
bar(1);
bar(3.14);
}
```

-Steve


Re: Static Initialization of Structs syntax

2022-06-22 Thread Mike Parker via Digitalmars-d-learn

On Wednesday, 22 June 2022 at 11:19:59 UTC, Antonio wrote:



I see now:  DIP 1033 will solve this (i.e., using named 
arguments in struct constructor...  similar to how dart/flutter 
works)


That would be DIP 1030:

https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1030.md

Max Haughton was working on an implementation of it, but ran into 
trouble with template parameters, IIRC.


Re: Static Initialization of Structs syntax

2022-06-22 Thread Antonio via Digitalmars-d-learn

On Wednesday, 22 June 2022 at 09:41:55 UTC, Antonio wrote:

I'm so sorry, I know that the above example doesn't work:

```d

main(){
  Struct PersonDTO {
string name;
string surname;
  }

  void create(PersonDTO personData){
   // ...
  }
  create( {name: "Peter", surname: "Ustinov"} );

}

```

-Is it there any alternative to initialize "inline" de struct 
(using the name:value syntax for the properties) without 
declaring an intermediate variable?


Thanks
Antonio


I see now:  DIP 1033 will solve this (i.e., using named arguments 
in struct constructor...  similar to how dart/flutter works)


Static Initialization of Structs syntax

2022-06-22 Thread Antonio via Digitalmars-d-learn

I'm so sorry, I know that the above example doesn't work:

```d

main(){
  Struct PersonDTO {
string name;
string surname;
  }

  void create(PersonDTO personData){
   // ...
  }
  create( {name: "Peter", surname: "Ustinov"} );

}

```

-Is it there any alternative to initialize "inline" de struct 
(using the name:value syntax for the properties) without 
declaring an intermediate variable?


Thanks
Antonio


get debug information for Deprecation warning

2022-06-22 Thread test123 via Digitalmars-d-learn
When I get Deprecation warning from template, I can not find the 
root cause of the problem.


```sh
 Deprecation: argument `_param_1` for format specification `"%d"` 
must be `int`, not `ulong`

```


Is there a options to turn the  Deprecation  warning into assert 
error, so I can know the template caller chain ?