Re: Is there a way to slice non-array type in @safe?

2019-07-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, July 11, 2019 1:44:51 PM MDT Stefanos Baziotis via Digitalmars- d-learn wrote: > On Thursday, 11 July 2019 at 19:37:38 UTC, Nathan S. wrote: > > If you know that what you're doing cannot result in memory > > corruption but the compiler cannot automatically infer @safe, > > it is

Re: Is there a way to slice non-array type in @safe?

2019-07-11 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 11 July 2019 at 19:44:51 UTC, Stefanos Baziotis wrote: On Thursday, 11 July 2019 at 19:37:38 UTC, Nathan S. wrote: If you know that what you're doing cannot result in memory corruption but the compiler cannot automatically infer @safe, it is appropriate to use @trusted. (For

Re: Is there a way to slice non-array type in @safe?

2019-07-11 Thread Stefanos Baziotis via Digitalmars-d-learn
On Thursday, 11 July 2019 at 19:37:38 UTC, Nathan S. wrote: If you know that what you're doing cannot result in memory corruption but the compiler cannot automatically infer @safe, it is appropriate to use @trusted. (For this case make sure you're not returning the byte slices, since if the

Re: Is there a way to slice non-array type in @safe?

2019-07-11 Thread Nathan S. via Digitalmars-d-learn
On Thursday, 11 July 2019 at 16:31:58 UTC, Stefanos Baziotis wrote: I searched the forum but did not find something. I want to do this: int foo(T)(ref T s1, ref T s2) { const byte[] s1b = (cast(const(byte)*))[0 .. T.sizeof]; const byte[] s2b = (cast(const(byte)*))[0 .. T.sizeof]; }

Re: Is there a way to slice non-array type in @safe?

2019-07-11 Thread Stefanos Baziotis via Digitalmars-d-learn
On Thursday, 11 July 2019 at 18:46:57 UTC, Paul Backus wrote: Casting from one type of pointer to another and slicing a pointer are both @system, by design. Yes, I'm aware, there are no pointers in the code. The pointer was used here because it was the only way to solve the problem (but not

Re: Is there a way to slice non-array type in @safe?

2019-07-11 Thread Stefanos Baziotis via Digitalmars-d-learn
On Thursday, 11 July 2019 at 18:46:57 UTC, Paul Backus wrote: What's the actual problem you're trying to solve? There may be a different way to do it that's @safe. I hope I answered the "what". In case the "why" helps too, it is because I'm implementing memcmp().

Re: "lld-link: error: could not open libcmt.lib: no such file or directory"

2019-07-11 Thread moth via Digitalmars-d-learn
in case anyone else suffers from this in the future and is looking for a solution - redownloading visual studio 2017 and making sure the c++ workload was enabled fixed this for me. i'm not really sure why that worked, but i'm just happy to be able to learn again. trans rights! - moth

Re: Is there a way to slice non-array type in @safe?

2019-07-11 Thread Paul Backus via Digitalmars-d-learn
On Thursday, 11 July 2019 at 16:31:58 UTC, Stefanos Baziotis wrote: I searched the forum but did not find something. I want to do this: int foo(T)(ref T s1, ref T s2) { const byte[] s1b = (cast(const(byte)*))[0 .. T.sizeof]; const byte[] s2b = (cast(const(byte)*))[0 .. T.sizeof]; }

Is there a way to slice non-array type in @safe?

2019-07-11 Thread Stefanos Baziotis via Digitalmars-d-learn
I searched the forum but did not find something. I want to do this: int foo(T)(ref T s1, ref T s2) { const byte[] s1b = (cast(const(byte)*))[0 .. T.sizeof]; const byte[] s2b = (cast(const(byte)*))[0 .. T.sizeof]; } Which is to create a byte array from the bytes of the value given, no

Re: Blog Post #0051: MVC IV - ComboBox with Text

2019-07-11 Thread Ron Tarrant via Digitalmars-d-learn
On Wednesday, 10 July 2019 at 20:31:36 UTC, Greatsam4sure wrote: Is it possible to get all the tutorials in a pdf file for offline work? Thanks in advance Just found out about this on FB. Packt is having a sale right now, 3 ebooks for $30 and they have three books about D.

Re: LDC won't find ld linker -why?

2019-07-11 Thread Dukc via Digitalmars-d-learn
On Wednesday, 10 July 2019 at 23:15:38 UTC, Johan Engelen wrote: On Tuesday, 9 July 2019 at 15:25:17 UTC, Dukc wrote: I just downloaded ldc 1.15.0 for Linux from GH releases. Testing it, it will make the object file out of a hello world application, but then complain: ``` collect2: fatal

Re: Is it possible to execute a function inside .d script that has no main function?

2019-07-11 Thread Alex via Digitalmars-d-learn
On Thursday, 11 July 2019 at 09:43:55 UTC, BoQsc wrote: Here I have a file named: module.d import std.stdio : writeln; void interestingFunction(){ writeln("Testing"); } There is no main() function since, I want to import this module, into another .d file. ( If I try to import

Is it possible to execute a function inside .d script that has no main function?

2019-07-11 Thread BoQsc via Digitalmars-d-learn
Here I have a file named: module.d import std.stdio : writeln; void interestingFunction(){ writeln("Testing"); } There is no main() function since, I want to import this module, into another .d file. ( If I try to import and module.d does have main() function I get this error:

Re: How to use std.windows.registry, there are no documentations.

2019-07-11 Thread Max Haughton via Digitalmars-d-learn
On Thursday, 11 July 2019 at 08:53:35 UTC, BoQsc wrote: https://dlang.org/phobos/std_windows_registry.html https://github.com/dlang/phobos/blob/master/std/windows/registry.d Can someone provide some examples on how to: set, change, receive something from the Windows registry using Phobos

How to use std.windows.registry, there are no documentations.

2019-07-11 Thread BoQsc via Digitalmars-d-learn
https://dlang.org/phobos/std_windows_registry.html https://github.com/dlang/phobos/blob/master/std/windows/registry.d Can someone provide some examples on how to: set, change, receive something from the Windows registry using Phobos std.windows.registry library?

Re: Blog Post #0051: MVC IV - ComboBox with Text

2019-07-11 Thread Ron Tarrant via Digitalmars-d-learn
On Wednesday, 10 July 2019 at 20:31:36 UTC, Greatsam4sure wrote: On Tuesday, 9 July 2019 at 12:08:04 UTC, Ron Tarrant wrote: Today's post starts a mini series-within-a-series on dressing up the ComboBox using a ListStore. Essentially, it's ListStore basics leading up to how this type of model