On Thursday, 5 January 2023 at 22:49:01 UTC, thebluepandabear
wrote:
Have fun reading this :
https://issues.dlang.org/show_bug.cgi?id=21929
Thanks for the code suggestion although it still doesn't fix
the bug. I am curious as to what those brackets do as well.
Okay, my bad for writing the w
On Thu, Jan 05, 2023 at 10:46:07PM +, thebluepandabear via
Digitalmars-d-learn wrote:
> On Thursday, 5 January 2023 at 17:36:55 UTC, H. S. Teoh wrote:
[...]
> > ```D
> > foreach (BoardSize boardSize; arr) {
> > Button button = new Button();
> > button.text = format("%sx%s", boardSize[0
them or remove them.
I agree, forbidding function call syntax would be a great usecase
for `@property`.
It will probably never get implemented though.
```
These two solutions should compile to approximately the same
runtime code, with optimizations enabled. So, it's really down
to personal preference; the former is more explicit about what
the computer is to do, while the latter is more concise.
Thanks! Works great.
Have fun reading this :
https://issues.dlang.org/show_bug.cgi?id=21929
Thanks for the code suggestion although it still doesn't fix the
bug. I am curious as to what those brackets do as well.
On Thursday, 5 January 2023 at 17:36:55 UTC, H. S. Teoh wrote:
On Thu, Jan 05, 2023 at 11:55:33AM +, thebluepandabear via
Digitalmars-d-learn wrote: [...]
```D
foreach (BoardSize boardSize; arr) {
Button button = new Button();
button.text = format("%sx%s", boardSize[0], boardSize[1])
On Thursday, 5 January 2023 at 17:23:39 UTC, H. S. Teoh wrote:
On Thu, Jan 05, 2023 at 06:32:47AM +, areYouSureAboutThat
Also, I cannot read hex,
[...]
IMNSHO, anyone who claims to be a programmer should at least
know that much.
??
Well, like all, I learnt this at uni. .. as well as lo
On Thu, Jan 05, 2023 at 08:18:42PM +, DLearner via Digitalmars-d-learn
wrote:
> On Thursday, 5 January 2023 at 19:54:01 UTC, H. S. Teoh wrote:
[...]
> > core.stdc.stdlib.{malloc,free} *is* the exact same malloc/free that
> > C uses, it has nothing to do with the GC. The allocated memory is
>
On Thursday, 5 January 2023 at 19:54:01 UTC, H. S. Teoh wrote:
On Thu, Jan 05, 2023 at 07:49:38PM +, DLearner via
Digitalmars-d-learn wrote:
Suppose there is a D main program (not marked anywhere with
@nogc),
that _both_
A: Calls one or more C functions that themselves call
malloc/free; a
On Thu, Jan 05, 2023 at 07:49:38PM +, DLearner via Digitalmars-d-learn
wrote:
> Suppose there is a D main program (not marked anywhere with @nogc),
> that _both_
>
> A: Calls one or more C functions that themselves call malloc/free; and
> also
> B: Calls one or more D functions that themselve
Suppose there is a D main program (not marked anywhere with
@nogc), that _both_
A: Calls one or more C functions that themselves call
malloc/free; and also
B: Calls one or more D functions that themselves call malloc/free
via `import core.stdc.stdlib;`
Assuming the malloc/free's are used cor
On Thursday, 5 January 2023 at 05:59:26 UTC, Ali Çehreli wrote:
While we're here, you can force the class objects to be on the
stack as well:
scope MyClassVar1 = new MyClass();
I replaced 'auto' with 'scope'.
Ali
Very interesting. Thanks Ali.
On Thu, Jan 05, 2023 at 02:32:17PM +, Dom DiSc via Digitalmars-d-learn
wrote:
[...]
> I think this is really another usecase for @property: we should forbid the
> function call syntax for them (so one needs to use them like a variable).
[...]
> Properties are not functions. If you want a funct
On Thu, Jan 05, 2023 at 11:55:33AM +, thebluepandabear via
Digitalmars-d-learn wrote:
[...]
> ```D
> foreach (BoardSize boardSize; arr) {
> Button button = new Button();
> button.text = format("%sx%s", boardSize[0], boardSize[1]);
> button.onButtonClick = {
> eventHandler.settingsW
On Thu, Jan 05, 2023 at 06:32:47AM +, areYouSureAboutThat via
Digitalmars-d-learn wrote:
[...]
> Second, to be sure your getting the correct results, it would be nice
> if there was a 'category of type' in std.traits for:
>
> isAllocatedOnStack
> isAllocatedOnHeap
>
> As it is, your just gue
On Thursday, 5 January 2023 at 16:41:32 UTC, Adam D Ruppe wrote:
On Thursday, 5 January 2023 at 16:38:49 UTC, Vijay Nayar wrote:
Does that class inherit the scope of the function it is
inside, similar to how an inner class does with an outer class?
yup. They can see the local variables from th
On Thursday, 5 January 2023 at 16:38:49 UTC, Vijay Nayar wrote:
Does that class inherit the scope of the function it is inside,
similar to how an inner class does with an outer class?
yup. They can see the local variables from the function.
On Thursday, 5 January 2023 at 13:47:24 UTC, Adam D Ruppe wrote:
On Thursday, 5 January 2023 at 13:27:23 UTC, Vijay Nayar wrote:
Why is this error only found when declaring a class in the
unittest?
A unittest is just a special function, it can run code and have
local variables.
classes and
On Thursday, 5 January 2023 at 11:55:33 UTC, thebluepandabear
wrote:
I am using CSFML D bindings and I have created my own sort of
UI library for drawing elements onto the screen.
One of the classes I've created is a `Button` class, which
contains a delegate called `onButtonClick` which is cal
On Wednesday, 4 January 2023 at 14:21:46 UTC, bauss wrote:
```d
class Foo {
int bar;
void setBar(Foo foo, int value) {
foo.bar = value;
}
}
void main() {
foo.setBar(100); // Not UFCS - just method call to the class
foo.setBar = 100; // Not UFCS - simply a setter function call
(eq
On Thursday, 5 January 2023 at 09:10:00 UTC, areYouSureAboutThat
wrote:
My question is: why is there no bounds checking occurring if I
forget to use -betterC?
module test;
extern(C) void main()
Note that whether bounds checking is performed depends on
[compiler
switches](https://dlang.org/
On Thursday, 5 January 2023 at 13:05:46 UTC, thebluepandabear
wrote:
Update some time later: the only way (oof!) around this seems
to be using a `static foreach` with arrays:
```D
Button[3] b;
static foreach (indx, BoardSize boardSize; arr) {
b[indx] = new Button();
b[indx].text = form
On Thursday, 5 January 2023 at 13:27:23 UTC, Vijay Nayar wrote:
Why is this error only found when declaring a class in the
unittest?
A unittest is just a special function, it can run code and have
local variables.
classes and structs declared inside it have access to those local
contexts, w
On Thursday, 5 January 2023 at 11:55:33 UTC, thebluepandabear
wrote:
```D
foreach (BoardSize boardSize; arr) {
Button button = new Button();
button.text = format("%sx%s", boardSize[0], boardSize[1]);
button.onButtonClick = {
eventHandler.settingsWindow_onBoardSizeButtonClick(
I've run into an unexpected problem that only seems to happen in
unittests, but not outside of them. Consider the following
example:
```
unittest {
class Ab {
int a;
string b;
static class Builder {
int _a;
string _b;
Builder a(int a) {
_a = a;
r
Update some time later: the only way (oof!) around this seems to
be using a `static foreach` with arrays:
```D
Button[3] b;
static foreach (indx, BoardSize boardSize; arr) {
b[indx] = new Button();
b[indx].text = format("%sx%s", boardSize[0], boardSize[1]);
b[indx].onButtonClick
I am using CSFML D bindings and I have created my own sort of UI
library for drawing elements onto the screen.
One of the classes I've created is a `Button` class, which
contains a delegate called `onButtonClick` which is called when
the button is clicked on by the user.
Up until now, everyt
On Thursday, 5 January 2023 at 09:10:00 UTC, areYouSureAboutThat
wrote:
I was playing around with betterC, when I discovered, that if i
accidently forget to provide -betterC to the compiler, it will
still compile this, but, there will be no runtime bounds
checking occuring.
My question is: wh
On Thursday, 5 January 2023 at 09:17:28 UTC, areYouSureAboutThat
wrote:
core.exception.ArrayIndexError@test.d(25): index [5] exceeds
array of length 5
Aborted (core dumped)
This is bounds checking happening.
On 05/01/2023 10:17 PM, areYouSureAboutThat wrote:
src/rt/dwarfeh.d:330: uncaught exception reached top of stack
This might happen if you're missing a top level catch in your fiber or
signal handler
core.exception.ArrayIndexError@test.d(25): index [5] exceeds array of
length 5
Aborted (core du
On Thursday, 5 January 2023 at 09:10:00 UTC, areYouSureAboutThat
wrote:
btw. the output (when you forget to use -betterC):
0
1
2
3
4
src/rt/dwarfeh.d:330: uncaught exception reached top of stack
This might happen if you're missing a top level catch in your
fiber or signal handler
core.except
I was playing around with betterC, when I discovered, that if i
accidently forget to provide -betterC to the compiler, it will
still compile this, but, there will be no runtime bounds checking
occuring.
My question is: why is there no bounds checking occurring if I
forget to use -betterC?
m
32 matches
Mail list logo