On Saturday, 28 May 2016 at 08:34:17 UTC, Mike Parker wrote:
const(F) cf = f;
immutable(f) if = f;
And, of course, those should be const(Foo) and immutable(Foo).
On Saturday, 28 May 2016 at 05:30:26 UTC, chmike wrote:
What is the difference between a const and immutable object ?
would a const object be allowed to modify itself by using a
hash table or caching results inside ?
The difference lies in the guarantees of const and immutable.
Foo f = new
On Saturday, 28 May 2016 at 08:10:50 UTC, Era Scarecrow wrote:
On Friday, 27 May 2016 at 09:22:49 UTC, Guillaume Piolat wrote:
You have to write your code three times, one for
version(D_InlineAsm_X86)
version (D_InlineAsm_X86_64)
and a version without assembly.
Rather than make a new thread
On Friday, 27 May 2016 at 16:47:19 UTC, Daniel Kozak wrote:
Why not to use distribute oprion?
Dne 27. 5. 2016 17:35 napsal uživatel "yawniek via
Digitalmars-d-learn" <
digitalmars-d-learn@puremagic.com>:
it its a flawed strategy.
what you should do is let the kernel handle it and use SO_
On Friday, 27 May 2016 at 09:22:49 UTC, Guillaume Piolat wrote:
You have to write your code three times, one for
version(D_InlineAsm_X86)
version (D_InlineAsm_X86_64)
and a version without assembly.
Rather than make a new thread I wonder if struct inheritance
wouldn't solve this, as trying
On Saturday, 28 May 2016 at 05:30:26 UTC, chmike wrote:
Would it be different if the object was declared const instead
of immutable ?
Sometimes compiler is able to figure out that const data is
immutable.
This is a bit frustrating because it is trivial to implement in
C and C++.
For a
On Friday, 27 May 2016 at 17:00:04 UTC, Steven Schveighoffer
wrote:
Now, the question here is, when does alias this kick in? I
would say it should follow alias this before looking outside
the module, so I say it's a bug.
https://issues.dlang.org/show_bug.cgi?id=16086
On Saturday, 28 May 2016 at 10:10:19 UTC, ZombineDev wrote:
The great thing about D's UFCS is that it allows exactly that:
Also, you can implement inc() in terms of ulong[2] - void
inc(ref ulong[2] w), which makes it applicable for other types,
with the same memory representation. E.g. cent
On Saturday, 28 May 2016 at 08:47:48 UTC, Kagamin wrote:
For a trick of static mutable allocation see
https://github.com/dlang/druntime/pull/1325
Thank you that looks promising. I'll study an experiment with the
code.
If I would like that the instances are not in TLS, can I use the
following
Let's say I have a generic function that uses pointers. It will
be inferred @system by the compiler, but I know that the pointer
usage can be @trusted.
The problem is that if I declare the function @trusted, I'm also
implicitly trusting any call to @system methods of the template
parameter.
On Saturday, 28 May 2016 at 11:50:33 UTC, Lodovico Giaretta wrote:
Is there any way around this? Any way to declare a function
@trusted as long as the methods of the template argument are at
least @trusted?
Thank you in advance.
Use traits..
https://dlang.org/phobos/std_traits.html#isSafe
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
Use traits..
https://dlang.org/phobos/std_traits.html#isSafe
so your function becomes (i believe)
auto doSomethingDumb(T)(ref T t) if(isSafe!(T))
The problem is that T is a type, and I should check for safety of
every
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta wrote:
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
auto doSomethingDumb(T)(ref T t) if(isSafe!(T))
The problem is that T is a type, and I should check for safety
of every method of T that I'm using in my
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
auto doSomethingDumb(T)(ref T t) if(isSafe!(T))
Should also probably test for a function or delegate. So...?
auto doSomethingDumb(T)(ref T t)
if(isSafe!T && (isFunctionPointer!T || isDelegate!T)) {
T* pt =
On Sunday, 29 May 2016 at 00:28:13 UTC, Mithun Hunsur wrote:
On Sunday, 29 May 2016 at 00:14:17 UTC, dan wrote:
Is there a standard alias for a class name inside class code?
Something like 'this' referring to a class instance, but
referring instead to the class itself?
[...]
typeof(this)
On Sunday, 29 May 2016 at 00:14:17 UTC, dan wrote:
Is there a standard alias for a class name inside class code?
Something like 'this' referring to a class instance, but
referring instead to the class itself?
[...]
typeof(this) gets you the type of the current class. :)
On Saturday, 28 May 2016 at 14:54:13 UTC, Era Scarecrow wrote:
Well here's what i got. Maybe someone else will tell me how i
did this wrong...
Using the pragma to output how the lines were being generated i
finally figured out why it kept complaining about the stack
pointer and 'this'. So
On 05/28/2016 09:54 PM, chmike wrote:
The only inconvenience left is that we can't have mutable references
to immutable objects.
There is std.typecons.Rebindable for that.
Is there a standard alias for a class name inside class code?
Something like 'this' referring to a class instance, but
referring instead to the class itself?
What i would like to do is have something like
class Clas {
// alias Clas THIS; <- don't want this boilerplate
static THIS
On Saturday, 28 May 2016 at 08:47:48 UTC, Kagamin wrote:
For a trick of static mutable allocation see
https://github.com/dlang/druntime/pull/1325
In the following instruction of the above commit, what effect has
the [] after init ?
_store[0 .. __traits(classInstanceSize, T)] =
On Saturday, 28 May 2016 at 16:24:21 UTC, chmike wrote:
In my long quest to implement a flyweight pattern with objects
instantiated at compile time, I was indirectly notified of the
possible problem of synchronization.
In a flyweight pattern the user has the impression there are
distinct
On Saturday, 28 May 2016 at 16:25:02 UTC, Seb wrote:
If you are interested how it works under the hood - it's pretty
simple & elegant:
I checked up on the phobos implementation and found that arrays
are mutated when iterated over as ranges, which didn't rest well
with me. Nor did the idea of
On 05/28/2016 10:34 AM, Mike Parker wrote:
On Saturday, 28 May 2016 at 05:30:26 UTC, chmike wrote:
[...]
Is a static const Category c variable a TLS variable ?
Yes. All variables are TLS unless explicitly marked with __gshared or
shared.
I don't think that's true.
import core.thread;
On Friday, 27 May 2016 at 14:59:25 UTC, Adam D. Ruppe wrote:
On Friday, 27 May 2016 at 14:54:30 UTC, pineapple wrote:
I've encountered one remarkable difference: The phobos
function accepts arrays and mine does not.
add `import std.array;` i think to your module and it should
make arrays
Never mind. D was fine. Needed an alureUpdate() to trigger the
call back.
On Saturday, 28 May 2016 at 14:11:56 UTC, Lodovico Giaretta wrote:
On Saturday, 28 May 2016 at 14:01:35 UTC, Era Scarecrow wrote:
Do you still want the template i'm building?
Thank you very much for your effort.
Please if you don't need it, don't make it, because I don't
know if I'll use
On Saturday, 28 May 2016 at 14:11:56 UTC, Lodovico Giaretta wrote:
On Saturday, 28 May 2016 at 14:01:35 UTC, Era Scarecrow wrote:
Do you still want the template i'm building?
Thank you very much for your effort.
Please if you don't need it, don't make it, because I don't
know if I'll use
On Saturday, 28 May 2016 at 20:43:00 UTC, pineapple wrote:
On Saturday, 28 May 2016 at 16:25:02 UTC, Seb wrote:
If you are interested how it works under the hood - it's
pretty simple & elegant:
I checked up on the phobos implementation and found that arrays
are mutated when iterated over as
On Saturday, 28 May 2016 at 13:10:56 UTC, Lodovico Giaretta wrote:
The only problem is that these structures are parameterized,
and the type parameters may have unsafe operations that I use.
Do you still want the template i'm building? It doesn't like
stack frame pointers, but will work with
On 05/28/2016 02:43 PM, Lodovico Giaretta wrote:
struct S1
{
int doSomething() @safe
{
// do something safely
return 1;
}
}
struct S2
{
int doSomething() @system
{
// do something usafe
return 2;
}
}
auto doSomethingDumb(T)(ref
On Friday, 27 May 2016 at 20:20:36 UTC, chmike wrote:
I need to create an app wide singleton instance for my class.
The singleton is immutable, but I want to allow mutable
references to that singleton object so that I can do fast 'is'
tests.
I declared this
class Category
{
protected
On Saturday, 28 May 2016 at 15:29:36 UTC, TheDGuy wrote:
Thanks a lot for the fast hot fix, now everything works fine!
:) Great IDE!
Do you mind implementing an option to reset the layout to
default? Because i think i messed up and no i don't know how i
can get the file view for the
On Saturday, 28 May 2016 at 15:31:18 UTC, TheDGuy wrote:
On Saturday, 28 May 2016 at 15:29:36 UTC, TheDGuy wrote:
Thanks a lot for the fast hot fix, now everything works fine!
:) Great IDE!
Do you mind implementing an option to reset the layout to
default? Because i think i messed up and
On 05/28/2016 06:09 PM, chmike wrote:
In the following instruction of the above commit, what effect has the []
after init ?
_store[0 .. __traits(classInstanceSize, T)] = typeid(T).init[];
T is a template argument that is a class derived from Error.
I couldn't find an explanation here
On Saturday, 28 May 2016 at 13:25:14 UTC, Basile B. wrote:
I've released a hot fix yesterday and now it works with latest
DUB tag (0.9.25).
But registering from the project that's loaded was already
working yesterday. I think that you have forgotten to choose
the right configuration to
On Saturday, 28 May 2016 at 14:01:35 UTC, Era Scarecrow wrote:
On Saturday, 28 May 2016 at 13:10:56 UTC, Lodovico Giaretta
wrote:
The only problem is that these structures are parameterized,
and the type parameters may have unsafe operations that I use.
Do you still want the template i'm
In my long quest to implement a flyweight pattern with objects
instantiated at compile time, I was indirectly notified of the
possible problem of synchronization.
In a flyweight pattern the user has the impression there are
distinct instances where in fact objects with the same state
(member
On Sunday, 29 May 2016 at 00:48:20 UTC, dan wrote:
Especially in a declaration like
static typeof(this) make_instance( )
but also in the 'new typeof(this)'. In both cases, 'this'
doesn't even exist.
https://dlang.org/spec/declaration.html#Typeof
it's another 'this' that has not the
On Sunday, 29 May 2016 at 02:44:33 UTC, jhps wrote:
On Sunday, 29 May 2016 at 00:48:20 UTC, dan wrote:
Especially in a declaration like
static typeof(this) make_instance( )
but also in the 'new typeof(this)'. In both cases, 'this'
doesn't even exist.
On Saturday, 28 May 2016 at 15:39:44 UTC, ag0aep6g wrote:
On 05/28/2016 10:34 AM, Mike Parker wrote:
On Saturday, 28 May 2016 at 05:30:26 UTC, chmike wrote:
[...]
Is a static const Category c variable a TLS variable ?
Yes. All variables are TLS unless explicitly marked with
__gshared or
On Sunday, 29 May 2016 at 05:35:33 UTC, Mike Parker wrote:
Well then, this completely breaks my understanding of variable
scope.
OK, I see now at [1] the following:
" Immutable data doesn't have synchronization problems, so the
compiler doesn't place it in TLS."
I've read that page more
On Saturday, 28 May 2016 at 12:33:28 UTC, Era Scarecrow wrote:
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta
wrote:
On Saturday, 28 May 2016 at 11:57:09 UTC, Era Scarecrow wrote:
auto doSomethingDumb(T)(ref T t) if(isSafe!(T))
The problem is that T is a type, and I should
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta wrote:
The problem is that T is a type, and I should check for safety
of every method of T that I'm using in my function. This does
not scale well, and if I change the body of the function to use
a new method, I may forget to add it
On Saturday, 28 May 2016 at 12:45:21 UTC, Era Scarecrow wrote:
On Saturday, 28 May 2016 at 12:25:14 UTC, Lodovico Giaretta
wrote:
The problem is that T is a type, and I should check for safety
of every method of T that I'm using in my function. This does
not scale well, and if I change the
On Saturday, 28 May 2016 at 12:45:21 UTC, Era Scarecrow wrote:
Fourth, you could create a helper function/template that
cycles through a struct of your choice and tells you if any of
it's methods fail to be safe. This will require a little more
work, but it could be used as a full insurance
On Saturday, 28 May 2016 at 11:50:33 UTC, Lodovico Giaretta wrote:
Let's say I have a generic function that uses pointers. It will
be inferred @system by the compiler, but I know that the
pointer usage can be @trusted.
What kind of pointer usage do you have? Remember that basic & and
*
On Saturday, 28 May 2016 at 13:03:10 UTC, Adam D. Ruppe wrote:
What kind of pointer usage do you have? Remember that basic &
and * operations ARE @safe.
If you have more internally, you might be able to wrap them up
in an @trusted function to again allow inference to work.
Ouch! I was under
On Saturday, 28 May 2016 at 13:10:56 UTC, Lodovico Giaretta wrote:
On Saturday, 28 May 2016 at 13:03:10 UTC, Adam D. Ruppe wrote:
What kind of pointer usage do you have? Remember that basic &
and * operations ARE @safe.
If you have more internally, you might be able to wrap them up
in an
On Friday, 27 May 2016 at 19:30:10 UTC, TheDGuy wrote:
On Thursday, 26 May 2016 at 22:15:17 UTC, Basile B. wrote:
gfm doesn't yield a .lib because of this:
https://github.com/d-gamedev-team/gfm/blob/master/dub.json#L22
it should be "library" or staticLibrary or "sourceLibrary"
thus it can't
49 matches
Mail list logo