Re: No compile time bounds checking for static arrays?

2021-08-10 Thread Stefan Koch via Digitalmars-d-learn
On Wednesday, 11 August 2021 at 06:29:40 UTC, Tejas wrote: ```d import std; void main() { int[40] staticA; auto c = staticA[0..50];//mistake }``` results in: ```d core.exception.RangeError@onlineapp.d(5): Range violation ??:? _d_arrayboundsp [0x55db29a0b645] ./onlineapp.

No compile time bounds checking for static arrays?

2021-08-10 Thread Tejas via Digitalmars-d-learn
```d import std; void main() { int[40] staticA; auto c = staticA[0..50];//mistake }``` results in: ```d core.exception.RangeError@onlineapp.d(5): Range violation ??:? _d_arrayboundsp [0x55db29a0b645] ./onlineapp.d:5 _Dmain [0x55db29a0ae8c] ``` Is there a way to make this

Re: D has the same memory model as C++

2021-08-10 Thread Tejas via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 21:19:39 UTC, Bastiaan Veelo wrote: On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote: Basically, what are the subtle gotcha's in the differences between C++ and D code that looks similar The only gotcha that comes to my mind is that `private` means private

Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Mike Parker via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 19:03:06 UTC, Marcone wrote: On Tuesday, 10 August 2021 at 19:01:42 UTC, Adam D Ruppe wrote: On Tuesday, 10 August 2021 at 18:59:33 UTC, Marcone wrote: Using -Lgdi32.lib -Luser32.lib? Same error. The part after that: If you want the Windows subsystem too, use -

Re: writef, compile-checked format, pointer

2021-08-10 Thread Ali Çehreli via Digitalmars-d-learn
On 8/9/21 10:03 PM, nov wrote: > i dreamed that programming will be less-error with compile checking format. I still think so because many errors that can be caught at compile time are moved to run time in non-statically-typed languages. > but reality disappoint :( > message for every error

Re: D has the same memory model as C++

2021-08-10 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 18:13:17 UTC, Tejas wrote: On Tuesday, 10 August 2021 at 18:07:35 UTC, Bastiaan Veelo wrote: On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote: there's casting away const, a clearly seperate language feature which has no equivalent in D; You *can* cast away

Re: D has the same memory model as C++

2021-08-10 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote: Basically, what are the subtle gotcha's in the differences between C++ and D code that looks similar The only gotcha that comes to my mind is that `private` means private to the module in D, not private to the aggregate. — Bastiaan.

Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Marcone via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 19:01:42 UTC, Adam D Ruppe wrote: On Tuesday, 10 August 2021 at 18:59:33 UTC, Marcone wrote: Using -Lgdi32.lib -Luser32.lib? Same error. The part after that: If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup. Pass BOTH -L

Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 18:59:33 UTC, Marcone wrote: Using -Lgdi32.lib -Luser32.lib? Same error. The part after that: If you want the Windows subsystem too, use -L/subsystem:windows -L/entry:mainCRTStartup. Pass BOTH -L/subsystem:windows AND -L/entry:mainCRTStartup

Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Marcone via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 18:51:28 UTC, Adam D Ruppe wrote: On Tuesday, 10 August 2021 at 18:45:35 UTC, Marcone wrote: Hi, do you have some other solution without arsd.simpledisplay? I want only dmd feature. Did you read the paragraph under the link? That IS a dmd switch. Or a ldc switch.

Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 18:45:35 UTC, Marcone wrote: Hi, do you have some other solution without arsd.simpledisplay? I want only dmd feature. Did you read the paragraph under the link? That IS a dmd switch. Or a ldc switch. It explains the concept which works with anything.

Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Marcone via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 18:36:27 UTC, Adam D Ruppe wrote: On Tuesday, 10 August 2021 at 18:34:03 UTC, Marcone wrote: How can I hide console using -m64? http://dpldocs.info/experimental-docs/arsd.simpledisplay.html#installation-instructions Hi, do you have some other solution without ar

Re: -L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Adam D Ruppe via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 18:34:03 UTC, Marcone wrote: How can I hide console using -m64? http://dpldocs.info/experimental-docs/arsd.simpledisplay.html#installation-instructions

-L/SUBSYSTEM:windows Error when using -m64

2021-08-10 Thread Marcone via Digitalmars-d-learn
How use -L/SUBSYSTEM:windows for hide console in x64 prograns? Becouse if I use -L/SUBSYSTEM:windows and -m64 I get this error: lld-link: error: undefined symbol: WinMain referenced by msvcrt120.lib(msvcrt_stub2.obj):($LN5) Error: linker exited with status 1 If I delete -L/SUBSYSTEM:windows c

Re: D has the same memory model as C++

2021-08-10 Thread Tejas via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 18:07:35 UTC, Bastiaan Veelo wrote: On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote: there's casting away const, a clearly seperate language feature which has no equivalent in D; You *can* cast away `const` in D: https://run.dlang.io/is/sWa5Mf — Bastiaan.

Re: D has the same memory model as C++

2021-08-10 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 16:00:37 UTC, Tejas wrote: there's casting away const, a clearly seperate language feature which has no equivalent in D; You *can* cast away `const` in D: https://run.dlang.io/is/sWa5Mf — Bastiaan.

Re: Error when compile with DMD using -m64?

2021-08-10 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 17:13:31 UTC, Marcone wrote: On Tuesday, 10 August 2021 at 15:55:42 UTC, Bastiaan Veelo wrote: Use `size_t` and `ptrdiff_t` instead to make your program compile in both 32 bit and 64 bit modes. https://dlang.org/spec/type.html#aliased-types -- Bastiaan. Thank y

Re: Error when compile with DMD using -m64?

2021-08-10 Thread Marcone via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 15:55:42 UTC, Bastiaan Veelo wrote: On Tuesday, 10 August 2021 at 01:29:04 UTC, Marcone wrote: Solved converting long and int. Use `size_t` and `ptrdiff_t` instead to make your program compile in both 32 bit and 64 bit modes. https://dlang.org/spec/type.html#al

Re: .tupleof for static array

2021-08-10 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 15:32:25 UTC, Dennis wrote: Thanks for this solution as well. On Tuesday, 10 August 2021 at 13:10:23 UTC, Paul Backus wrote: Would definitely be nice to have this in the language, though. Do you know more use cases for this? I've written range pipelines like th

Re: D has the same memory model as C++

2021-08-10 Thread Tejas via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 13:18:24 UTC, Paul Backus wrote: On Tuesday, 10 August 2021 at 11:05:53 UTC, Tejas wrote: Also, I have read here a principle that **If it looks like C, it behaves like C** How true is that for C++? Does code that look like C++(minus obvious syntax differences) be

Re: Error when compile with DMD using -m64?

2021-08-10 Thread Bastiaan Veelo via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 01:29:04 UTC, Marcone wrote: Solved converting long and int. Use `size_t` and `ptrdiff_t` instead to make your program compile in both 32 bit and 64 bit modes. https://dlang.org/spec/type.html#aliased-types -- Bastiaan.

Re: .tupleof for static array

2021-08-10 Thread Dennis via Digitalmars-d-learn
Thanks for this solution as well. On Tuesday, 10 August 2021 at 13:10:23 UTC, Paul Backus wrote: Would definitely be nice to have this in the language, though. Do you know more use cases for this?

Re: D has the same memory model as C++

2021-08-10 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 11:05:53 UTC, Tejas wrote: Also, I have read here a principle that **If it looks like C, it behaves like C** How true is that for C++? Does code that look like C++(minus obvious syntax differences) behave like C++? No. D and C++ have different semantics for many

Re: .tupleof for static array

2021-08-10 Thread Paul Backus via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 12:01:24 UTC, Dennis wrote: ```D struct Vec { float x, y, z; } void setPosition(float x, float y, float z) { } void main() { Vec posS = Vec(10, 20, 30); setPosition(posS.tupleof); // pass float[3] posA = [10, 20, 30]; setPosition(posA.tupleof)

Re: .tupleof for static array

2021-08-10 Thread Dennis via Digitalmars-d-learn
Thanks! I was considering turning the static array into an AliasSeq directly, but casting it to a struct and doing tupleof on that is pretty smart. On Tuesday, 10 August 2021 at 12:50:55 UTC, jfondren wrote: And I don't see very many static-array-generic functions in Phobos. Indeed, static a

Re: .tupleof for static array

2021-08-10 Thread jfondren via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 12:01:24 UTC, Dennis wrote: ```D struct Vec { float x, y, z; } void setPosition(float x, float y, float z) { } void main() { Vec posS = Vec(10, 20, 30); setPosition(posS.tupleof); // pass float[3] posA = [10, 20, 30]; setPosition(posA.tupleof)

.tupleof for static array

2021-08-10 Thread Dennis via Digitalmars-d-learn
```D struct Vec { float x, y, z; } void setPosition(float x, float y, float z) { } void main() { Vec posS = Vec(10, 20, 30); setPosition(posS.tupleof); // pass float[3] posA = [10, 20, 30]; setPosition(posA.tupleof); // Error: no property `tupleof` for type `float[3]` } `

D has the same memory model as C++

2021-08-10 Thread Tejas via Digitalmars-d-learn
What exactly does the above statement mean? Also, I have read here a principle that **If it looks like C, it behaves like C** How true is that for C++? Does code that look like C++(minus obvious syntax differences) behave like C++? Does having the same memory model help? Thanks for reading!

Re: writef, compile-checked format, pointer

2021-08-10 Thread Tejas via Digitalmars-d-learn
On Tuesday, 10 August 2021 at 05:03:12 UTC, nov wrote: every time i try to use templates, i have problems :( That is why C++ introduced concepts. Wonder when D will be getting them :(