I wished I never come across the nightmare of such a question.
And maybe, there is still a bug in my code, which I'm not aware
of (which I strongly suppose :/ ).
But nevertheless, and for learning purposes, assume I have
something like this:
´´´
auto foo(/*input params*/)
{
//some long cal
On Friday, 16 November 2018 at 20:13:42 UTC, Vinay Sajip wrote:
More complicated for the compiler writers, or users of
mixins/generics?
For users of generics. It's hard to come up with an actual
example because I don't know why one would ever use this, but in
this concocted scenario:
```
mi
On Friday, 16 November 2018 at 15:59:14 UTC, Vinay Sajip wrote:
This code should IMO give at least a warning, but it doesn't:
abstract class A {
int kind;
}
[...]
This is not unique to D you can do the same in Java or C++.
bye,
Norm
On Friday, 16 November 2018 at 12:12:12 UTC, Alex wrote:
=
This code compiles as long as `lazy` is commented out. But I'd
like to have
both lazy parameter and @nogc inferrence for `library_func` so
that user is not locked to code @nogc or not.
On Friday, 16 November 2018 at 19:12:42 UTC, Dennis wrote:
If something is definitively wrong, then it should be an error.
If it's not definitively wrong, then the compiler shouldn't say
anything about it, and it should be left up to a linter tool of
some kind like dcd."
https://forum.dlang.o
On Friday, 16 November 2018 at 14:55:52 UTC, Aditya wrote:
How can one write own factory function ? Any pointers to this ?
Something like
Interface delegate()[string] factories;
Interface create(string className) {
if(className in factories)
return factories[classname];
else
On Friday, 16 November 2018 at 18:37:00 UTC, Vinay Sajip wrote:
Design flaws in what?
Design flaws in the language.
Quoting Jonathan M Davis:
"Honestly, in general, warnings are a terrible idea. Anything
that's a warning in your code has to be fixed, because it's bad
practice to leave warnin
On Friday, 16 November 2018 at 17:35:13 UTC, Basile B. wrote:
D is not a compiler that warns much. You can still open an
issue asking for this (and the warning must be easy to add at
first glance), but the policy applied to warnings is "compilers
warnings are a sign of design flaws so instead o
On 11/16/18 12:10 PM, boolangery wrote:
Hi,
Is something like this is doable ?
---
// all compile time
MapperGen.Create!(A, B)
.Map!("p1", "p2")
.Map!("myprop", "otherprop")
.Gen();
// The code above must generate s
On Friday, 16 November 2018 at 17:49:06 UTC, Domain wrote:
But I cannot control the 3rd library!
Hmm, I see.
So one possibility would be to reopen stdout (and maybe stderr)
to a different file.
stdout.reopen("log.txt", "wt");
when you start your program and before you call the libr
BTW if you just want to ditch the output, you might be able to
use "NUL" as the file name. I havent' tried tho.
On Friday, 16 November 2018 at 17:46:20 UTC, Adam D. Ruppe wrote:
On Friday, 16 November 2018 at 17:36:01 UTC, Domain wrote:
I think this is unacceptable.
Why?
You are asking it to write to a file that doesn't exist... you
probably shouldn't be doing that...
But I cannot control the 3rd li
On Friday, 16 November 2018 at 17:36:01 UTC, Domain wrote:
I think this is unacceptable.
Why?
You are asking it to write to a file that doesn't exist... you
probably shouldn't be doing that...
When I link the app with /subsystem:windows, and all writeln and
writefln will cause a enforcement failed (stdio.d:2889).
I think this is unacceptable.
On Friday, 16 November 2018 at 17:28:15 UTC, Vinay Sajip wrote:
On Friday, 16 November 2018 at 17:08:00 UTC, Basile B. wrote:
I agree that this is almost a case of shadowing but i don't
know the exact rationale for allowing this.
I'm not saying it shouldn't be allowed - just that the compiler
On Friday, 16 November 2018 at 17:08:00 UTC, Basile B. wrote:
I agree that this is almost a case of shadowing but i don't
know the exact rationale for allowing this.
I'm not saying it shouldn't be allowed - just that the compiler
could warn you about what might very well be a mistake (as it w
Hi,
Is something like this is doable ?
---
// all compile time
MapperGen.Create!(A, B)
.Map!("p1", "p2")
.Map!("myprop", "otherprop")
.Gen();
// The code above must generate something like
//
// class Mapper {
// B
On Friday, 16 November 2018 at 15:59:14 UTC, Vinay Sajip wrote:
This code should IMO give at least a warning, but it doesn't:
abstract class A {
int kind;
}
class B : A {
int kind;
this(int k) {
kind = k;
}
}
In my actual code, the declaration of field "kind" in B was
On Friday, 16 November 2018 at 14:55:52 UTC, Aditya wrote:
On Friday, 16 November 2018 at 14:30:02 UTC, Adam D. Ruppe
wrote:
PS object.factory sucks and I hope it is removed some day.
There's no plan to do so, but I still wouldn't actually rely
on it... instead, I'd write your own factory funct
On 11/16/18 9:51 AM, Aditya wrote:
On Friday, 16 November 2018 at 14:28:22 UTC, Adam D. Ruppe wrote:
On Friday, 16 November 2018 at 14:24:10 UTC, Aditya wrote:
./ss/Stat.d (defines interface named 'Stat')
./ss/Min.d (defines class named 'Min' that implements Stat)
Did you put a module decl
This code should IMO give at least a warning, but it doesn't:
abstract class A {
int kind;
}
class B : A {
int kind;
this(int k) {
kind = k;
}
}
In my actual code, the declaration of field "kind" in B was left
in accidentally. Surprisingly, however, no warning was emit
On Friday, 16 November 2018 at 14:30:02 UTC, Adam D. Ruppe wrote:
PS object.factory sucks and I hope it is removed some day.
There's no plan to do so, but I still wouldn't actually rely on
it... instead, I'd write your own factory function and
registration system, so you control it and will hav
On Friday, 16 November 2018 at 14:28:22 UTC, Adam D. Ruppe wrote:
On Friday, 16 November 2018 at 14:24:10 UTC, Aditya wrote:
./ss/Stat.d (defines interface named 'Stat')
./ss/Min.d (defines class named 'Min' that implements Stat)
Did you put a module declaration at the top of those files? L
PS object.factory sucks and I hope it is removed some day.
There's no plan to do so, but I still wouldn't actually rely on
it... instead, I'd write your own factory function and
registration system, so you control it and will have reliability
to your specific needs.
but still if the factory w
On Friday, 16 November 2018 at 14:24:10 UTC, Aditya wrote:
./ss/Stat.d (defines interface named 'Stat')
./ss/Min.d (defines class named 'Min' that implements Stat)
Did you put a module declaration at the top of those files? Like
module ss.Stat;
That ought to be required; the compiler lets
Hello !
I am trying to work out "The D programming Language" chapter 1.6
problem on Interfaces and Classes.
folder
./stats.d(takes argument "Min/Max" on command line and loads
them)
./ss/Stat.d (defines interface named 'Stat')
./ss/Min.d (defines class named 'Min' that implements Stat
On Friday, 16 November 2018 at 12:08:33 UTC, Stanislav Blinov
wrote:
import std.range.primitives : isRandomAccessRange;
auto sortSubRange(R)(R range, size_t i, size_t j) if
(isRandomAccessRange!R) {
import std.algorithm.sorting : topN, partialSort;
size_t start = i;
if (i != 0) {
On Friday, 16 November 2018 at 12:59:22 UTC, aliak wrote:
Adding @trusted to declaration of opDispatch gets rid of @safe
error but I still get "Error: @nogc function D main cannot call
non-@nogc function". And going through the codebase and
figuring out where to add @trusted is *very* cumberso
debug {
import std.stdio;
writeln(args);
}
Hi, I previously had trouble trying to get print statements
working while debugging in nogc. And that was hackishly solved
[0], but I can't figure out how to do the same if I have @safe
involved. Here's a cut down sample:
// This is the function from the thread referenced
auto assumeNoGC(T)(T
On Friday, 16 November 2018 at 10:25:26 UTC, ikod wrote:
On Thursday, 15 November 2018 at 21:55:18 UTC, Steven
Schveighoffer wrote:
On 11/15/18 4:09 PM, Adam D. Ruppe wrote:
On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote:
what are the rules for @nogc inference?
It attempts it if a
On Friday, 16 November 2018 at 11:24:20 UTC, Per Nordlöw wrote:
/** Sort sub-range [sub_begin, sub_end] of [begin, end].
*
* Describe at
https://www.youtube.com/watch?v=0WlJEz2wb8Y&t=2686s
*/
template// I models RandomAccessIterator
void sort_subrange(I begin, I end,
How do I sort a subrange of a range `x` where the subrange is
defined by a lower and upper (in this case exlusive) element
contained within `x`?
auto x = [1,2,7,4,2,6,8,3,9,3];
auto y = sortSubRange(x, 3,5];
should yield `y` being
[3,3,4]
and `x` being
[a ,3,3,4, b]
where
On Thursday, 15 November 2018 at 21:55:18 UTC, Steven
Schveighoffer wrote:
On 11/15/18 4:09 PM, Adam D. Ruppe wrote:
On Thursday, 15 November 2018 at 21:00:48 UTC, ikod wrote:
what are the rules for @nogc inference?
It attempts it if and only if it is a template.
Well, the general "rule" is
On Friday, 16 November 2018 at 02:18:11 UTC, Ranjan wrote:
On Thursday, 15 November 2018 at 17:03:55 UTC, Andrea Fontana
wrote:
On Thursday, 15 November 2018 at 13:05:59 UTC, Ranjan wrote:
This is my first time on the Dlang forum. I like the language
but my usecase is a bit different.
I want
35 matches
Mail list logo