Re: I don't understand betterC

2023-09-08 Thread rempas via Digitalmars-d-learn
On Monday, 4 September 2023 at 07:39:21 UTC, confused wrote: So then I guess I'd still like to know how I'm expected to store and access an array of characters without the C runtime as I tried in my original post. You are going to allocate memory using the system call of your operation syst

Re: I don't understand betterC

2023-09-04 Thread evilrat via Digitalmars-d-learn
On Monday, 4 September 2023 at 07:39:21 UTC, confused wrote: So then I guess I'd still like to know how I'm expected to store and access an array of characters without the C runtime as I tried in my original post. Without C runtime functions such as malloc you can still have fixed-length ar

Re: I don't understand betterC

2023-09-04 Thread confused via Digitalmars-d-learn
On Saturday, 2 September 2023 at 07:59:31 UTC, Jonathan M Davis wrote: If you put it into a package, then you could have your own object module that then isn't at the top level - e.g. mypkg/object.d with module mypkg.object; but you can't have more than one module in your program with the sa

Re: I don't understand betterC

2023-09-02 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, September 2, 2023 4:38:41 AM BST confused via Digitalmars-d-learn wrote: > On Friday, 1 September 2023 at 13:45:05 UTC, evilrat wrote: > > It is shadowing default implicit "import object;", here a > > demonstration > > > > ```d > > // this example shows default implicit import of "obj

Re: I don't understand betterC

2023-09-01 Thread evilrat via Digitalmars-d-learn
On Saturday, 2 September 2023 at 03:27:51 UTC, confused wrote: So I guess my next question is why, exactly, classes *can*, in fact, be implemented in ``` betterC ```, but are not? IIRC you can have extern(C++) classes in betterC, the real issue is the plain extern(D) classes which has some ass

Re: I don't understand betterC

2023-09-01 Thread bachmeier via Digitalmars-d-learn
On Saturday, 2 September 2023 at 03:18:31 UTC, confused wrote: On Friday, 1 September 2023 at 13:31:37 UTC, bachmeier wrote: You can read the documentation for object.d [here](https://dlang.org/phobos/object.html). It's kind of important. I'm not sure which specific part of the documentation

Re: I don't understand betterC

2023-09-01 Thread confused via Digitalmars-d-learn
On Friday, 1 September 2023 at 13:45:05 UTC, evilrat wrote: It is shadowing default implicit "import object;", here a demonstration ```d // this example shows default implicit import of "object" module // compile this example: // ldc2 -c test.d // output: // tuple("object", "core", "main",

Re: I don't understand betterC

2023-09-01 Thread confused via Digitalmars-d-learn
On Saturday, 2 September 2023 at 01:05:39 UTC, ryuukk_ wrote: If you are looking for a better C you are not looking for classes You contradict yourself If you heard about betterC, then you heard about this: https://dlang.org/spec/betterc.html Read it again, and specially this part: https:

Re: I don't understand betterC

2023-09-01 Thread confused via Digitalmars-d-learn
On Friday, 1 September 2023 at 13:31:37 UTC, bachmeier wrote: You can read the documentation for object.d [here](https://dlang.org/phobos/object.html). It's kind of important. I'm not sure which specific part of the documentation was supposed to illuminate the exact nature of that error.

Re: I don't understand betterC

2023-09-01 Thread ryuukk_ via Digitalmars-d-learn
On Friday, 1 September 2023 at 13:17:08 UTC, confused wrote: On Friday, 1 September 2023 at 08:19:55 UTC, Richard (Rikki) Andrew Cattermole wrote: ``size_t`` is defined in ``object.d`` which is implicitly imported into all modules. If it cannot be found, one of three things is happening: 1) Y

Re: I don't understand betterC

2023-09-01 Thread evilrat via Digitalmars-d-learn
On Friday, 1 September 2023 at 13:17:08 UTC, confused wrote: On Friday, 1 September 2023 at 08:19:55 UTC, Richard (Rikki) Andrew Cattermole wrote: ``size_t`` is defined in ``object.d`` which is implicitly imported into all modules. If it cannot be found, one of three things is happening: 1) Y

Re: I don't understand betterC

2023-09-01 Thread bachmeier via Digitalmars-d-learn
On Friday, 1 September 2023 at 13:17:08 UTC, confused wrote: On Friday, 1 September 2023 at 08:19:55 UTC, Richard (Rikki) Andrew Cattermole wrote: ``size_t`` is defined in ``object.d`` which is implicitly imported into all modules. If it cannot be found, one of three things is happening: 1) Y

Re: I don't understand betterC

2023-09-01 Thread confused via Digitalmars-d-learn
On Friday, 1 September 2023 at 08:19:55 UTC, Richard (Rikki) Andrew Cattermole wrote: ``size_t`` is defined in ``object.d`` which is implicitly imported into all modules. If it cannot be found, one of three things is happening: 1) You have messed with some cli args related to picking druntime

Re: I don't understand betterC

2023-09-01 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
``size_t`` is defined in ``object.d`` which is implicitly imported into all modules. If it cannot be found, one of three things is happening: 1) You have messed with some cli args related to picking druntime/phobos 2) You have defined a module called object. 3) You have a broken compiler instal

Re: I don't understand betterC

2023-08-31 Thread confused via Digitalmars-d-learn
On Thursday, 31 August 2023 at 18:42:57 UTC, Richard (Rikki) Andrew Cattermole wrote: ```d extern(C) int main() { import core.stdc.stdio; string hello = "hello"; printf(hello.ptr); return 0; } ``` 1) You forgot to import ``core.stdc.stdio`` 2) String literal is of type string (

Re: I don't understand betterC

2023-08-31 Thread Richard (Rikki) Andrew Cattermole via Digitalmars-d-learn
```d extern(C) int main() { import core.stdc.stdio; string hello = "hello"; printf(hello.ptr); return 0; } ``` 1) You forgot to import ``core.stdc.stdio`` 2) String literal is of type string (which is an alias to ``immutable(char)[]``). 3) A slice is a pointer + length, and C d

I don't understand betterC

2023-08-31 Thread confused via Digitalmars-d-learn
I decided to try out betterC with the most trivial example I could think of, but why doesn't this work? ```d extern(C) int main() { char[] hello = "hello"; printf(hello); return 0; } ```