Re: Operator "+=" overloading for class?

2023-12-17 Thread novice2 via Digitalmars-d-learn

On Monday, 18 December 2023 at 03:39:16 UTC, Ki Rill wrote:
On Sunday, 17 December 2023 at 07:05:12 UTC, Adam D. Ruppe 
wrote:

On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote:

[...]


check what `op` is. pretty sure it is "+" not "+=" so your 
element isnt' saved anywhere. also a bit iffy there isn't a 
member here to work on


Yes, op is '+'. What do you mean by it isn't saved anywhere?


your code just return result value,
but it should not return but save result to "this"
see example at 
https://dlang.org/spec/operatoroverloading.html#index_op_assignment





Re: Operator "+=" overloading for class?

2023-12-17 Thread Ki Rill via Digitalmars-d-learn

On Sunday, 17 December 2023 at 07:05:12 UTC, Adam D. Ruppe wrote:

On Sunday, 17 December 2023 at 04:13:20 UTC, Ki Rill wrote:

[...]


check what `op` is. pretty sure it is "+" not "+=" so your 
element isnt' saved anywhere. also a bit iffy there isn't a 
member here to work on


Yes, op is '+'. What do you mean by it isn't saved anywhere? I 
tried reassigning to `this` and returning it, but it fails.


I want to achieve this, but with '+=':
```d
auto g = value(0);
g = g + value(3);

// here it should just create a new instance 'g + value(3)' and 
save it into 'g'

g += value(3);
```

Do you have an advice on how to achieve it?


Re: Checking path name

2023-12-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, December 14, 2023 12:33:36 PM MST cc via Digitalmars-d-learn 
wrote:
> On Thursday, 14 December 2023 at 09:38:30 UTC, Joel wrote:
> > On Thursday, 14 December 2023 at 08:47:49 UTC, Anonymouse wrote:
> >> On Thursday, 14 December 2023 at 03:58:37 UTC, Joel wrote:
> >> https://dlang.org/phobos/std_path.html#isValidPath
> >>
> >> https://dlang.org/phobos/std_path.html#.isValidFilename
> >
> > Oh, forgot about std.path
> >
> > But what's the difference between path and file name?
>
> File name can't contain path separators.

While that's true to a point, most code, documentation, and programmers
really aren't going to distinguish between the two.

When anything talks about a file path, it's pretty clear that it's talking
about relative and/or absolute file paths, and thus, file / path separators
will often be involved. However, when talking about a file name, it could be
just the file's name without any preceding path, or it could be its entire
file path (absolute or relative). It really depends on who's talking and
what the context is. And it's not uncommon for documentation on functions to
use the term path and filename interchangeably.

Ultimately though, with regards to Phobos, std.path is for functions that
have to do with manipulating file paths without actually doing anything to
files on disk. They're basically a bunch of file-specific string
manipulation functions. That then mostly relates to stuff like separators,
but it also involves stuff like file extensions.

On the other hand, std.file is for actually manipulating files rather than
the paths to files. So, it has stuff for checking whether a file on disk is
a file or a directory, whether it exists, etc. - and of course, it has
functions for reading in and writing to files.

std.stdio also has some functions for reading from and writing to files, but
the difference there is that it does it in pieces, whereas std.file reads
and writes files as single units (e.g. std.stdio might read in a file 4096
bytes at a time, whereas std.file would read it all in at once as a single
array).

- Jonathan M Davis





Re: vibe-d REST API: POSTing a struct

2023-12-17 Thread bomat via Digitalmars-d-learn

On Friday, 15 December 2023 at 07:36:04 UTC, aj_dlang wrote:

does it active?


If you mean if that vibe-d forum is still active, I don't know. I 
tried to register, but I never got a confirmation mail... so 
probably not.
On the other hand, there wasn't a response to my question on this 
board either, so don't really know what's the best place to get 
vibe-d support...


Re: macOS Sonoma Linker Issue

2023-12-17 Thread Johan via Digitalmars-d-learn

On Wednesday, 13 December 2023 at 18:32:50 UTC, Renato wrote:

On Wednesday, 4 October 2023 at 11:01:08 UTC, Johan wrote:

On Tuesday, 3 October 2023 at 23:55:05 UTC, confuzzled wrote:
Any known workaround for this most recent issue on macOS 
Sonoma? The file I'm compiling contains a blank main() 
without any imports but this error shows up on everything 
I've attempted to compile since upgrading to Sonoma.


(dmd-2.105.2) confuzzled@test ~ % dmd add
ld: multiple errors: symbol count from symbol table and 
dynamic symbol table differ in '/Users/confuzzled/add.o' in 
'/Users/confuzzled/add.o'; address=0x0 points to section(2) 
with no content in 
'/Users/confuzzled/dlang/dmd-2.105.2/osx/lib/libphobos2.a[3177](config_a68_4c3.o)'
clang: error: linker command failed with exit code 1 (use -v 
to see invocation)

Error: linker exited with status 1


Try passing `-ld_classic` to the linker.  (`dmd -L-ld_classic`)

https://github.com/ldc-developers/ldc/issues/4501#issuecomment-1738295459

-Johan


Thanks, it worked for me as well on MacOS Sonoma! The issue 
you've linked has been resolved now. I am completely new to D, 
so if I may ask, how often do they release? The fix was merged 
2 weeks ago, should we expect a release within a few weeks or 
it's not released that often?


Release will not be in next weeks, first DMD 2.106.1 should be 
released, then probably a few weeks later LDC 1.36 will be 
released.


-Johan



Re: macOS Sonoma Linker Issue

2023-12-17 Thread Joel via Digitalmars-d-learn

On Wednesday, 4 October 2023 at 11:01:08 UTC, Johan wrote:

On Tuesday, 3 October 2023 at 23:55:05 UTC, confuzzled wrote:

[...]


Try passing `-ld_classic` to the linker.  (`dmd -L-ld_classic`)

https://github.com/ldc-developers/ldc/issues/4501#issuecomment-1738295459

-Johan


I've been holding off installing Sonoma, because of this. How 
does one use DUB with the linker fix?