Re: Rhyme and reason for function annotations?

2024-11-03 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, November 3, 2024 5:01:20 PM MST Andy Valencia via Digitalmars-d- learn wrote: > A function can be described as, say, private, or pure, or @nogc. > When does an annotation have an '@'? Also, a function can be > annotated > > int myfunc(char *arg) pure { > } > > Although I find: > > pure

Rhyme and reason for function annotations?

2024-11-03 Thread Andy Valencia via Digitalmars-d-learn
A function can be described as, say, private, or pure, or @nogc. When does an annotation have an '@'? Also, a function can be annotated int myfunc(char *arg) pure { } Although I find: pure int myfunc(char *arg) { } Also works. So what annotations have @'s, and when do they go with the fu

Re: Unexpected result with -betterC

2024-11-03 Thread monkyyy via Digitalmars-d-learn
On Sunday, 3 November 2024 at 20:04:19 UTC, DLearner wrote: Surely the line: ``` string Scrn = "OPO NAM='DspVar1' POS='1,1' VAR=('IntVar1','I');E"; ``` creates, by the definition of 'string', a dynamic array? I believe thats stored in the binary

Re: Unexpected result with -betterC

2024-11-03 Thread Paul Backus via Digitalmars-d-learn
On Sunday, 3 November 2024 at 19:00:33 UTC, DLearner wrote: However, the docs say dynamic arrays are not allowed with betterC, and 'string' implies a dynamic array. So I expected DMD to complain that my code was invalid. Any ideas? The docs are wrong. Dynamic arrays themselves are allowed; yo

Re: Unexpected result with -betterC

2024-11-03 Thread Juraj via Digitalmars-d-learn
On Sunday, 3 November 2024 at 20:04:19 UTC, DLearner wrote: On Sunday, 3 November 2024 at 19:47:31 UTC, monkyyy wrote: [...] Id expect this to fail, but nothing I see in yours ```d string foo="foo"; foo~="bar"; ``` []'s are both slices and dynamic arrays depending on use, theres a debate abo

Re: Unexpected result with -betterC

2024-11-03 Thread DLearner via Digitalmars-d-learn
On Sunday, 3 November 2024 at 19:47:31 UTC, monkyyy wrote: [...] Id expect this to fail, but nothing I see in yours ```d string foo="foo"; foo~="bar"; ``` []'s are both slices and dynamic arrays depending on use, theres a debate about that decision(im of the opinion a `[?]` should be a dynam

Re: Unexpected result with -betterC

2024-11-03 Thread monkyyy via Digitalmars-d-learn
On Sunday, 3 November 2024 at 19:00:33 UTC, DLearner wrote: The two fragments below compiled and ran as expected using dmd -betterC under Windows. ``` string Scrn = "OPO NAM='DspVar1' POS='1,1' VAR=('IntVar1','I');E"; printf("\nWR_Createtest entered.\n"); OpStructFstPtr = WR_Crea

Unexpected result with -betterC

2024-11-03 Thread DLearner via Digitalmars-d-learn
The two fragments below compiled and ran as expected using dmd -betterC under Windows. ``` string Scrn = "OPO NAM='DspVar1' POS='1,1' VAR=('IntVar1','I');E"; printf("\nWR_Createtest entered.\n"); OpStructFstPtr = WR_CreateFormatFile(Scrn); ``` ``` OpStruct* WR_CreateFormatFile(s