On Tuesday, 3 May 2022 at 06:20:53 UTC, Elfstone wrote:
Yeah, I understand some cases are impossible, and to be
avoided. I believe your example is also impossible in C++, but
it's better the compiler do its job when it's totally possible
- needless to say, C++ compilers can deduce my _dot_.
Con
This produces compatible strings between symbol and runtime type:
```d
class Foo {}
void main() {
alias Foo F;
writeln(fullyQualifiedName!F);
auto f = new F;
writeln(typeid(f).name);
}
```
```
test.Foo
test.Foo
```
But if the class is a template, the strings differ
On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote:
Given a runtime typeid, how can I get the equivalent
fullyQualifiedName without attempting to mangle the string
myself manually? e.g. something I can pass to `Object.factory`.
Actually, looking at this further, does Object.factory even
suppor
On Monday, 2 May 2022 at 17:21:53 UTC, JG wrote:
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote:
On Sunday, 1 May 2022 at 03:57:12 UTC, Elfstone wrote:
[...]
Template deduction for aliased function parameter is a very
tricky argument and it's not so simple to handle in certain
cases. Co
On Monday, 2 May 2022 at 19:17:19 UTC, Stanislav Blinov wrote:
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote:
Template deduction for aliased function parameter is a very
tricky argument and it's not so simple to handle in certain
cases. Consider for example this code:
```d
template
On Tuesday, 3 May 2022 at 09:52:56 UTC, cc wrote:
On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote:
Given a runtime typeid, how can I get the equivalent
fullyQualifiedName without attempting to mangle the string
myself manually? e.g. something I can pass to
`Object.factory`.
Actually, looki
On 3/5/22 12:48, bauss wrote:
This is where compile-time has its limits compared to runtime type
creation, because templates only live during compile-time then it isn't
really that easy to do something like this, where it would be trivial in
other languages like C#.
That's something I don't r
On Tuesday, 3 May 2022 at 09:42:45 UTC, cc wrote:
something I can pass to `Object.factory`.
Object.factory is useless and will hopefully be removed someday.
Instead, make your own factory registration function.
Put a static constructor in the class which appends a factory
delegate to an arra
Error: array literal in @nogc function test.myfun may cause a GC
allocation
@nogc void myfun(){
scope int[] i=[1,2,3];
}//myfun
May is a fuzzy word...
On Tuesday, 3 May 2022 at 10:48:53 UTC, bauss wrote:
Object.factory calls TypeInfo_Class.find which just loops
through ModuleInfo and then looks if any of the entries in
localClasses has a name that matches.
Afterwards it calls the create function on the TypeInfo_Class
which of course isn't "
On 3/5/22 14:46, Adam D Ruppe wrote:
Put a static constructor in the class which appends a factory delegate
to an array or something you can use later. Then you can use your own
thing to construct registered objects.
I'd like to do a runtime registration system myself, using a "template
this"
On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote:
Error: array literal in @nogc function test.myfun may cause a
GC allocation
@nogc void myfun(){
scope int[] i=[1,2,3];
}//myfun
May is a fuzzy word...
It means if the compiler is free to allocate on the stack if
possible. I
On Tuesday, 3 May 2022 at 13:25:14 UTC, Arafel wrote:
I'd like to do a runtime registration system myself, using a
"template this" static constructor. A simple version supporting
only default constructors would be:
Yeah, you can't template this a static constructor, but you can
just use a sta
On 3/5/22 15:57, Adam D Ruppe wrote:
So doing things yourself gives you some control.
Yes, it is indeed possible (I acknowledged it), but I think it's much
more cumbersome than it should, and puts the load on the user.
If templated this worked in static context (ideally everywhere else
too)
On Tuesday, 3 May 2022 at 14:38:53 UTC, Arafel wrote:
Actually, it would be cool to do it through an interface,
although I don't think an interface's static constructors are
invoked by the implementing classes... it would be cool, though.
yeah interfaces can't have constructors.
I'd try it my
Note, It's not i'm against GC. But my preference is to use
builtin types and libraries if possible,
But at the same time be able to be sure memory is given free when
a variable is going out of scope.
It seems not easy to combine the two with a GC which does his
best effort but as he likes or not
On Tue, May 03, 2022 at 04:38:53PM +0200, Arafel via Digitalmars-d-learn wrote:
> On 3/5/22 15:57, Adam D Ruppe wrote:
> > So doing things yourself gives you some control.
>
> Yes, it is indeed possible (I acknowledged it), but I think it's much
> more cumbersome than it should, and puts the load
On Tue, May 03, 2022 at 02:57:46PM +, Alain De Vos via Digitalmars-d-learn
wrote:
> Note, It's not i'm against GC. But my preference is to use builtin
> types and libraries if possible,
> But at the same time be able to be sure memory is given free when a
> variable is going out of scope.
> It
On 5/3/22 07:57, Alain De Vos wrote:
> But at the same time be able to be sure memory is given free when a
> variable is going out of scope.
Let's expand on that please. What exactly is the worry there? Are you
concerned that the program will have memory leaks, and eventually got
killed by the
On 3/5/22 16:48, Adam D Ruppe wrote:
Believe it or not, you don't need to touch the compiler. Open your
druntime's object.d and search for `RTInfo`
http://druntime.dpldocs.info/object.RTInfo.html
That is instantiated for every user defined type in the program and you
have the compile time inf
On 5/2/22 13:36, Stanislav Blinov wrote:
>> That's fine because D does not promise to solve such problems. It
>> follows simple deduction rules.
>
> Words, dear guru. Words have a meaning. It is very possible to deduce
> here (note the premise). D just isn't trying. That's what I said. Yo
On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote:
class Base : Serializable!(Base) { ... }
class Derived : Serializable!(Base, Derived) { ... }
This is really interesting syntax, I'm surprised that works!
On Tuesday, 3 May 2022 at 12:59:31 UTC, Alain De Vos wrote:
Error: array literal in @nogc function test.myfun may cause a
GC allocation
@nogc void myfun(){
scope int[] i=[1,2,3];
}//myfun
May is a fuzzy word...
For this particular piece of code, you can use a static array to
guarant
On Tue, May 03, 2022 at 04:38:23PM +, cc via Digitalmars-d-learn wrote:
> On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote:
> > class Base : Serializable!(Base) { ... }
> > class Derived : Serializable!(Base, Derived) { ... }
>
> This is really interesting syntax, I'm surprised
On Tuesday, 3 May 2022 at 16:38:23 UTC, cc wrote:
This is really interesting syntax, I'm surprised that works!
Can read a little more on my blog about it:
http://dpldocs.info/this-week-in-d/Blog.Posted_2019_06_10.html#tip-of-the-week
pretty cool little pattern.
On Tuesday, 3 May 2022 at 16:51:33 UTC, H. S. Teoh wrote:
On Tue, May 03, 2022 at 04:38:23PM +, cc via
Digitalmars-d-learn wrote:
On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote:
>class Base : Serializable!(Base) { ... }
>class Derived : Serializable!(Base, Derived) { ... }
On Tue, May 03, 2022 at 04:59:42PM +, cc via Digitalmars-d-learn wrote:
> On Tuesday, 3 May 2022 at 16:51:33 UTC, H. S. Teoh wrote:
[...]
> > > On Tuesday, 3 May 2022 at 15:08:53 UTC, H. S. Teoh wrote:
> > > > class Base : Serializable!(Base) { ... }
> > > > class Derived : Seri
Hi,
The specification of string literals has either some errors or I
don't understand what is meant by a Character.
For instance we have:
WysiwygString:
r" WysiwygCharacters_opt " StringPostfix_opt
WysiwygCharacters:
WysiwygCharacter
WysiwygCharacter WysiwygCharacters
WysiwygCha
On Tuesday, 3 May 2022 at 17:05:09 UTC, H. S. Teoh wrote:
Oops, sorry, I made a mistake. The definition of Serializable
should be:
class Serializable(Base, Derived = Object) : Base {}
There we go, works with this, now I get what it's trying to do:
```d
class Serializable(Base, Derived
On Tue, May 03, 2022 at 05:25:06PM +, cc via Digitalmars-d-learn wrote:
> On Tuesday, 3 May 2022 at 17:05:09 UTC, H. S. Teoh wrote:
> > Oops, sorry, I made a mistake. The definition of Serializable should be:
> >
> > class Serializable(Base, Derived = Object) : Base {}
>
> There we go, wo
I made some changes to some code I'm working on and now there are
some lines that are giving me funky DMD error codes (I can tell
it is some lines because I comment them out and the errors go
away). So for instance, one line I have a static assert that
gives an error code -1073741819, but if I
On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote:
I was leaning towards it being something related to running out
of memory or something, but I'm using dub and I've tried
turning on and off "lowmem".
Note that dub cannot pass -lowmem to dmd.
https://issues.dlang.org/show_bug.cgi?id=20699
On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote:
Does anyone have any idea what causes these types of errors?
Sounds like a stack overflow, maybe your code has a
complex/recursive part that makes DMD's call stack very deep.
On Tuesday, 3 May 2022 at 19:03:56 UTC, Dennis wrote:
On Tuesday, 3 May 2022 at 18:22:49 UTC, jmh530 wrote:
Does anyone have any idea what causes these types of errors?
Sounds like a stack overflow, maybe your code has a
complex/recursive part that makes DMD's call stack very deep.
Thanks.
On Tuesday, 3 May 2022 at 17:21:47 UTC, JG wrote:
Hi,
The specification of string literals has either some errors or
I don't understand what is meant by a Character.
[...]
Which to me means that e.g.
r"""
should be a WysiwygString, which the compiler thinks is not
(not surprisingly).
Am I m
On Tuesday, 3 May 2022 at 15:41:08 UTC, Ali Çehreli wrote:
We also have NP-completeness.
Ok, so C++ has similar limitations when you have a template with
an unknown parameter in a function parameter, but is this because
it would be NPC? Also, do we know that it cannot be resolved for
the typ
On Tuesday, 3 May 2022 at 14:57:46 UTC, Alain De Vos wrote:
Note, It's not i'm against GC. But my preference is to use
builtin types and libraries if possible,
But at the same time be able to be sure memory is given free
when a variable is going out of scope.
It seems not easy to combine the two
On Wednesday, 4 May 2022 at 02:42:44 UTC, Mike Parker wrote:
On Tuesday, 3 May 2022 at 14:57:46 UTC, Alain De Vos wrote:
Note, It's not i'm against GC. But my preference is to use
builtin types and libraries if possible,
But at the same time be able to be sure memory is given free
when a variab
On Wednesday, 4 May 2022 at 04:52:05 UTC, forkit wrote:
It is certainly *not* about you not having to care anymore
(about memory management).
That's not at all what I said. You don't have to care about
*when* memory is deallocated, meaning you don't have to manage it
yourself.
On Wednesday, 4 May 2022 at 05:13:04 UTC, Mike Parker wrote:
On Wednesday, 4 May 2022 at 04:52:05 UTC, forkit wrote:
It is certainly *not* about you not having to care anymore
(about memory management).
That's not at all what I said. You don't have to care about
*when* memory is dealloca
40 matches
Mail list logo