Re: Boneheaded question regarding compilation...

2024-04-02 Thread Mike Shah via Digitalmars-d-learn

On Monday, 1 April 2024 at 21:23:50 UTC, WhatMeWorry wrote:


Huge fan of Mike Shah's YouTube videos regarding D and his 
latest for D conference:


https://mshah.io/conf/24/DConf%20%20Online%202024%20_%20The%20Case%20for%20Graphics%20Programming%20in%20Dlang.pdf

So I installed github desktop app and cloned his Talks repo. 
There is a build command commented out at the top of the main.d 
file which I've been trying to compile, via the command line:


C:\Users\kheas\Documents\Talks\2024\dconf_online\hello_triangle>dmd -g -J. main.d 
./glad/gl/*.d -L-L/usr/local/lib -L-lglfw3 -of=prog && ./prog
Error: cannot find input file `.\glad\gl\*.d`
import path[0] = C:\D\dmd2\windows\bin64\..\..\src\phobos
import path[1] = 
C:\D\dmd2\windows\bin64\..\..\src\druntime\import


I'm using a Windows 11 machine so I thought that maybe the 
syntax was for Linux environment. But replacing all the '/' 
with '\' did not work.


An easier fix may be perhaps to just use 'dub' and install the 
glfw dependency. In my talk, I did everything from scratch (my 
preferred way), though I suspect using dub with glfw-d 
(https://code.dlang.org/packages/glfw-d) may provide less 
resistance.


Re: Would you recommend TDPL today?

2024-01-15 Thread Mike Shah via Digitalmars-d-learn
On Tuesday, 16 January 2024 at 02:58:03 UTC, Jonathan M Davis 
wrote:
On Monday, January 15, 2024 7:25:32 PM MST matheus via 
Digitalmars-d-learn wrote:

[...]



[...]
that have since changed or which were never implemented (e.g. 
synchronized classes never became a thing; synchronized 
functions still exist, but TDPL talks about them being replaced 
with synchronized classes and that never happened - and likely 
will never happen). There's also an errata for it, but AFAIK, 
that just fixes some mistakes it; it doesn't update it. This 
wiki entry tries to list some of the differences, but I expect 
that it also is rather out-of-date at this point:


https://wiki.dlang.org/Differences_With_TDPL

So, TDPL is a good resource, but you have to take into account 
the fact that some of the details are wrong, which you may not 
want to do. In that respect, Ali's book would likely work 
better:


http://ddili.org/ders/d.en/index.html

It was written more recently, and I'm pretty sure that Ali has 
updated it on some basis. I fully expect that there are things 
that you'd get out of TDPL that you wouldn't get from Ali's 
book, so there's definitely something to said for reading both, 
but again, whether that makes sense largely depends on whether 
you want to deal with figuring out which parts of TDPL are 
still valid.


- Jonathan M Davis


I'll also add that Adam's Book (D Cookbook) and Mike Parkers Book 
(Learning D) are both excellent. Mike's is mostly up to date, 
minus I think the post-blit function calls. Adam's has lots of 
various samples (may be good to read alongside, or otherwise 
after Ali or Mike's book once you have a feel for the language).


Re: I Did It! Calling D Library from Objective C in XCode on OSX

2024-01-04 Thread Mike Shah via Digitalmars-d-learn

On Thursday, 4 January 2024 at 14:17:01 UTC, pizza_dox_ wrote:

On Monday, 14 December 2015 at 10:09:29 UTC, Mike McKee wrote:
I finally managed to get it working, using some help from this 
forum and stackoverflow.com, and a little bit of random luck 
with tests.


[...]


Hello dlang forum,

I tried to replicate the shown, but I failed at the dmd compile 
stage. The dmd compiler for windows only puts out .obj files 
and no .o files. Is there another flag to set that makes the 
dmd compiler behave differently? Or is there another way to 
produce .o files from dlang source code?


Best regards pizza_dox_


I haven't tried, but ldc2 may also be an option if dmd does not 
support this functionality.


Re: anonymous structs within structs

2023-12-04 Thread Mike Shah via Digitalmars-d-learn

On Monday, 4 December 2023 at 18:26:07 UTC, DLearner wrote:

Suppose we need a construct like:
```
void main() {

   struct A {
  int I1;
  int I2;
  char X;
   }

   struct B {
  A Dummy;
  int Var1;
  int Var2;
   }
}
```
But do not want to give an explicit name (like 'Dummy' above) 
to the A struct held within the B struct.


Just removing 'Dummy' does not work (Error: no identifier for 
declarator `A`).

Nor does replacing 'Dummy' with {}

Suggestions?


One possible solution is to use a 'mixin template' where you 
effectively 'copy and paste' in the 'struct' and access the 
symbols.


Is something like this what you had in mind?

```
void main() {
   import std.stdio;

   mixin template A() {
  int I1;
  int I2;
  char X;
   }

   struct B {
  mixin A;
  int Var1;
  int Var2;
   }

B someObject;
writeln(someObject.I1);
writeln(someObject.I2);
}
```


Re: At D-Conf, Mike Shah's students presented a project. Is it in GitHub? Cant find it.

2023-09-25 Thread Mike Shah via Digitalmars-d-learn

On Saturday, 23 September 2023 at 05:56:31 UTC, WhatMeWorry wrote:

Wanted to study code.

I watched the video talk. But i couldn't see any URL etc.. 
Believe it was called Draw.


https://github.com/abstewart/DRaw


Re: having troubles with D and Vulkan.

2023-07-23 Thread Mike Shah via Digitalmars-d-learn

On Friday, 21 July 2023 at 02:22:56 UTC, harakim wrote:

On Thursday, 20 July 2023 at 06:27:13 UTC, Danni Coy wrote:
ok found it, I am an idiot, (really not used to working with 
dynamic libraries).


erupted needs a call to load device level functions.

loadDeviceLevelFunctions(instance);

On Thu, Jul 20, 2023 at 4:22 PM Danni Coy 
 wrote:


https://pastebin.com/Jc9ZaFFs
Redid the code as an almost exact translation of the C code.
should be easier to test and compare. Same issue is occurring.

On Thu, Jul 20, 2023 at 5:30 AM Mike Shah via 
Digitalmars-d-learn  wrote:

> [...]


Good work! Now I can rest in peace tonight. :D


Same for me :) Great to see folks working in Vulkan with D.


Re: having troubles with D and Vulkan.

2023-07-19 Thread Mike Shah via Digitalmars-d-learn

On Wednesday, 19 July 2023 at 07:39:35 UTC, Danni Coy wrote:

https://pastebin.com/JxxJufNB


What platform are you using, and how are you trying to build?

I can try to replicate on my end.


Re: How can i find my LAN IP Address using std.socket?

2023-02-21 Thread Mike Shah via Digitalmars-d-learn

On Tuesday, 4 February 2014 at 22:31:53 UTC, Dicebot wrote:
On Tuesday, 4 February 2014 at 20:19:14 UTC, TheFlyingFiddle 
wrote:
I'm setting up a simple local network enabling me to connect 
phones to the computer through the local wi-fi. The simplest 
way i could think of to make this work without relying on an 
external server was to simply broadcast the ip and port to all 
machines in the network.(Btw by server i mean my / my project 
groups windows boxes).


So well the problem is that i need a way for the phones to 
find running servers on the LAN.


I think it is close to impossible to do in portable way. Most 
reliable approach is to get list of all configured network 
interfaces via posix functions (or via `system` call as least 
resort), filter out "lo" and broadcast message for every such 
interface. I think you can also filter only wireless interfaces 
that way relatively easily too.


Apologies that I am bumping a post that is 9 years old, but I 
recently had to do this and thought this may help beginners. In a 
way it's a hack as suggested from the second post, that you can 
connect to a known ip address (e.g. google) from a socket and 
then see the endpoints with the local and remote addresses.


```
import std.stdio;
import std.socket;

void GetIP(){
// A bit of a hack, but we'll create a connection from 
google to

// our current ip.
// Use a well known port (i.e. google) to do this
auto r = getAddress("8.8.8.8",53); // NOTE: This is 
effetively getAddressInfo

writeln(r);
// Create a socket
auto sockfd = new Socket(AddressFamily.INET,  
SocketType.STREAM);

// Connect to the google server
import std.conv;
const char[] address = r[0].toAddrString().dup;
ushort port = to!ushort(r[0].toPortString());
sockfd.connect(new InternetAddress(address,port));
// Obtain local sockets name and address
writeln(sockfd.hostName);
writeln("Our ip address: ",sockfd.localAddress);
writeln("the remote address: ",sockfd.remoteAddress);

// Close our socket
sockfd.close();
}
```