The following program compiles, and does what you'd expect:
struct A {
int a;
}
pure int func( ref A a )
{
return a.a += 3;
}
As far as I can tell, however, it shouldn't. I don't see how or
why func can possibly be considered pure, as it changes a state
external to the function.
On Monday, 25 August 2014 at 06:27:00 UTC, Shachar wrote:
The following program compiles, and does what you'd expect:
struct A {
int a;
}
pure int func( ref A a )
{
return a.a += 3;
}
As far as I can tell, however, it shouldn't. I don't see how or
why func can possibly be considered
On Monday, 25 August 2014 at 02:04:43 UTC, Aerolite wrote:
On Monday, 25 August 2014 at 01:34:14 UTC, Idan Arye wrote:
On Monday, 25 August 2014 at 01:10:32 UTC, Aerolite wrote:
-- No syntax modification (unless you want the feature to be
optional)
If this ever gets into the core language,
On Monday, 25 August 2014 at 07:36:22 UTC, Idan Arye wrote:
Are you suggesting the compiler will try to resolve the
polymorphism at compile-time, looking at all possible paths
that lead to a function call to check all possible runtime
values it's object arguments can get?
I've argued for
On Sunday, 24 August 2014 at 00:41:36 UTC, Ellery Newcomer wrote:
Can't think off the top of my head how you do this
template IsTemplate(alias t) {
??
}
static assert(IsTemplate!IsTemplate)
__traits(compiles, is(t!X, X...))
should do it, or something similar.
On Monday, 25 August 2014 at 07:36:22 UTC, Idan Arye wrote:
If multi-dispatching is done at compile-time, it can't rely on
the object's runtime type - only on the static type of the
reference that holds it. This is no different than regular
function overloading that we already have.
Well any
On Monday, 25 August 2014 at 08:45:15 UTC, Ola Fosheim Grøstad
wrote:
However, why do you want multiple dispatch? I cannot think of
any application level use scenario where you have two class
hierarchies that you have no control over. So I don't really
see the value of multiple dispatch in a
[code]
void doSome(size_t N, T, string AS)( vec!(N,T,AS) v ) { }
struct vec(size_t N, T, string AS) { T[N] data; }
void main() { doSome( vec!(3,float,xyz)([1,2,3]) ); }
[/code]
compile with new dmd v2.066.0 and get error:
Error: template opbin.doSome(ulong N, T, string AS)(vec!(N, T,
AS) v)
Oleg B:
[code]
void doSome(size_t N, T, string AS)( vec!(N,T,AS) v ) { }
struct vec(size_t N, T, string AS) { T[N] data; }
void main() { doSome( vec!(3,float,xyz)([1,2,3]) ); }
[/code]
compile with new dmd v2.066.0 and get error:
Error: template opbin.doSome(ulong N, T, string AS)(vec!(N, T,
On Monday, 25 August 2014 at 11:41:28 UTC, bearophile wrote:
Oleg B:
[code]
void doSome(size_t N, T, string AS)( vec!(N,T,AS) v ) { }
struct vec(size_t N, T, string AS) { T[N] data; }
void main() { doSome( vec!(3,float,xyz)([1,2,3]) ); }
[/code]
compile with new dmd v2.066.0 and get error:
and when I minimal fix my libs with this issue compiler fails
without any output... =(
% gdb dmd
(gdb) run -unittest matrix.d vector.d
Starting program: /usr/bin/dmd -unittest matrix.d vector.d
[Thread debugging using libthread_db enabled]
Using host libthread_db library
On Monday, 25 August 2014 at 10:16:29 UTC, Aerolite wrote:
Well there are a few go-to use-cases, the handling of collisions
between objects in a game-engine being the most well-known
(which
requires Double-Dispatch).
I think a game engine is better off using a simple table or a
more
So i have been trying to follow the instructions on:
http://wiki.dlang.org/Win32_DLLs_in_D
but when i get to the step where i compile the dll
dmd -ofmydll.dll -L/IMPLIB mydll.d dll.d mydll.def
I get this output:
OPTLINK (R) for Win32 Release 8.00.15
Copyright (C) Digital Mars 1989-2013 All
On Monday, 25 August 2014 at 15:09:59 UTC, Taylor Hillegeist
wrote:
So i have been trying to follow the instructions on:
http://wiki.dlang.org/Win32_DLLs_in_D
but when i get to the step where i compile the dll
dmd -ofmydll.dll -L/IMPLIB mydll.d dll.d mydll.def
I get this output:
OPTLINK (R)
On Monday, 25 August 2014 at 15:09:59 UTC, Taylor Hillegeist
wrote:
So i have been trying to follow the instructions on:
http://wiki.dlang.org/Win32_DLLs_in_D
but when i get to the step where i compile the dll
dmd -ofmydll.dll -L/IMPLIB mydll.d dll.d mydll.def
I get this output:
OPTLINK (R)
I've done things like this before with traits and I figured that
this way should work as well, but it gives me errors instead.
Perhaps someone can point out my flaws.
immutable(T)[] toString(T)(const(T)* str)
if(typeof(T) is dchar)//this is where the error is
{
return
Jeremy DeHaan:
It compiles if I remove the 'if(typeof(T) is dchar)' section.
Any thoughts?
Try:
if (is(T == dchar))
Bye,
bearophile
On Mon, 25 Aug 2014 15:48:10 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
It compiles if I remove the 'if(typeof(T) is dchar)' section. Any
thoughts?
is should be used as function. here. i.e.: `if (is(T == dchar))`
signature.asc
Description: PGP
On Monday, 25 August 2014 at 15:59:38 UTC, ketmar via
Digitalmars-d-learn wrote:
On Mon, 25 Aug 2014 15:48:10 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
It compiles if I remove the 'if(typeof(T) is dchar)' section.
Any thoughts?
is should be used as
On Monday, 25 August 2014 at 15:52:20 UTC, bearophile wrote:
Jeremy DeHaan:
It compiles if I remove the 'if(typeof(T) is dchar)' section.
Any thoughts?
Try:
if (is(T == dchar))
Bye,
bearophile
That one compiles, and I'm assuming it works. I didn't know you
could use is this way. I've
On Mon, 25 Aug 2014 16:11:27 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Is its ability to be used as a function like this documented
anywhere? I looked and could not find it.
http://dlang.org/concepts.html
template constraints is a special case. is not
On Monday, 25 August 2014 at 16:20:24 UTC, ketmar via
Digitalmars-d-learn wrote:
On Mon, 25 Aug 2014 16:11:27 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Is its ability to be used as a function like this documented
anywhere? I looked and could not find
Me: Software developer for 30 years.
So perhaps this is old fashion, but I wanted to start using D by
whipping together nice little personal utilities.
I tried installing MonoDevelop and Mono-D. I can't even figure
out the basics, such as adding references to a project. There
are no
On Mon, 25 Aug 2014 15:48:10 +
Jeremy DeHaan via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
I've done things like this before with traits and I figured that
this way should work as well, but it gives me errors instead.
Perhaps someone can point out my flaws.
On Monday, 25 August 2014 at 16:46:11 UTC, Ryan wrote:
Me: Software developer for 30 years.
So perhaps this is old fashion, but I wanted to start using D
by whipping together nice little personal utilities.
I tried installing MonoDevelop and Mono-D. I can't even figure
out the basics, such
On Mon, Aug 25, 2014 at 03:48:10PM +, Jeremy DeHaan via Digitalmars-d-learn
wrote:
I've done things like this before with traits and I figured that this way
should work as well, but it gives me errors instead. Perhaps someone can
point out my flaws.
immutable(T)[] toString(T)(const(T)*
On Monday, 25 August 2014 at 16:46:11 UTC, Ryan wrote:
Me: Software developer for 30 years.
So perhaps this is old fashion, but I wanted to start using D
by whipping together nice little personal utilities.
I tried installing MonoDevelop and Mono-D. I can't even figure
out the basics, such
On Monday, 25 August 2014 at 17:05:48 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Mon, Aug 25, 2014 at 03:48:10PM +, Jeremy DeHaan via
Digitalmars-d-learn wrote:
I've done things like this before with traits and I figured
that this way
should work as well, but it gives me errors
People have been saying for quite a long time not to use the `delete`
keyword on GC-allocated pointers.
I've looked extensively through the code inside the engine and even made
a few modifications on it/benchmarked it for weeks and I still can't see
why it would be wrong. Wouldn't it help
On Monday, 25 August 2014 at 10:02:41 UTC, Aerolite wrote:
On Monday, 25 August 2014 at 07:36:22 UTC, Idan Arye wrote:
If multi-dispatching is done at compile-time, it can't rely on
the object's runtime type - only on the static type of the
reference that holds it. This is no different than
On Monday, 25 August 2014 at 17:10:11 UTC, Etienne wrote:
People have been saying for quite a long time not to use the
`delete` keyword on GC-allocated pointers.
I've looked extensively through the code inside the engine and
even made a few modifications on it/benchmarked it for weeks
and I
On Monday, 25 August 2014 at 17:16:10 UTC, Idan Arye wrote:
* Alternative implementations need to implement them(even
though the frontend is shared, there can always be some
complications(plus I think mutli-methods might need some
backend modifications as well, thhoguh I'm no expert on that
On Monday, 25 August 2014 at 17:28:45 UTC, Ola Fosheim Grøstad
wrote:
Then extend the typeinfo of classes in the first param with a
minimal typeid and 2D table that lists all combinations that
the custom linker can find based on the mangling?
Maybe it would be better to put in the restriction
On Mon, Aug 25, 2014 at 05:10:18PM +, via Digitalmars-d-learn wrote:
On Monday, 25 August 2014 at 17:05:48 UTC, H. S. Teoh via
Digitalmars-d-learn wrote:
On Mon, Aug 25, 2014 at 03:48:10PM +, Jeremy DeHaan via
Digitalmars-d-learn wrote:
I've done things like this before with traits
On 08/25/14 18:52, Jonathan M Davis via Digitalmars-d-learn wrote:
Another commonly used one is is(typeof(foo)). typeof(foo) gets the type of foo
and will result in void if foo doesn't exist, and is(void) is false, whereas
D is not quite that simple. ;)
static assert(is(void)==true);
(a)
Thanks for both responses. This is the information I was looking
for.
I have DMD, GTK# (For MonoDevelop), MonoDevelop, MonoD, dubs, and
GTKD installed.
I've got some things to compile... So the crux of my issue is
that I can't figure out how to link lib files in MonoDevelop. I
wonder if
Anyone know MonoDevelop?
Why is the Edit References context menu item missing. I have
it at the top (Project-Edit References...) but when I click it
nothing happens. Grrr.
Compiling the following code:
import std.typecons;
class Foo
{
private int foo;
mixin Proxy!(foo);
this(int x)
{
this.foo = x;
}
}
void main()
On Monday, 25 August 2014 at 17:57:54 UTC, Ryan wrote:
Anyone know MonoDevelop?
Why is the Edit References context menu item missing. I have
it at the top (Project-Edit References...) but when I click it
nothing happens. Grrr.
I couldnt figure it out either tbh (creating dub projects using
On 08/25/2014 11:10 AM, Gary Willoughby wrote:
Compiling the following code:
import std.typecons;
class Foo
{
private int foo;
mixin Proxy!(foo);
this(int x)
{
this.foo = x;
}
}
void main()
{
}
On Monday, 25 August 2014 at 18:10:33 UTC, Gary Willoughby wrote:
:!rdmd --force -de -debug -w test.d
/usr/include/dmd/phobos/std/typecons.d(4043): Error: template
instance isArray!(typeof(a)) template 'isArray' is not defined
test.d(7): Error: mixin test.Foo.Proxy!(foo) error instantiating
On 08/25/2014 11:38 AM, Marc Schütz schue...@gmx.net wrote:
On Monday, 25 August 2014 at 18:10:33 UTC, Gary Willoughby wrote:
:!rdmd --force -de -debug -w test.d
/usr/include/dmd/phobos/std/typecons.d(4043): Error: template instance
isArray!(typeof(a)) template 'isArray' is not defined
On Monday, 25 August 2014 at 18:44:36 UTC, Ali Çehreli wrote:
It can be explained if the mixed-in template is evaluated at
the mixin context without bringing in the imported modules to
that context. I don't know whether it is true or whether it is
a known limitation.
You're right, that's it!
On Monday, 25 August 2014 at 19:12:48 UTC, Marc Schütz wrote:
On Monday, 25 August 2014 at 18:44:36 UTC, Ali Çehreli wrote:
It can be explained if the mixed-in template is evaluated at
the mixin context without bringing in the imported modules to
that context. I don't know whether it is true
On Monday, 25 August 2014 at 17:20:20 UTC, Brad Anderson wrote:
On Monday, 25 August 2014 at 17:10:11 UTC, Etienne wrote:
People have been saying for quite a long time not to use the
`delete` keyword on GC-allocated pointers.
I've looked extensively through the code inside the engine and
On Monday, 25 August 2014 at 18:12:25 UTC, Colin wrote:
On Monday, 25 August 2014 at 17:57:54 UTC, Ryan wrote:
Anyone know MonoDevelop?
Why is the Edit References context menu item missing. I
have it at the top (Project-Edit References...) but when I
click it nothing happens. Grrr.
I
Is there a way to have cross-module inlining but with separate
compilation?
Like with link-time generation in C++ compilers.
Hello,
the code below compiles and runs fine. However, when I change
Payload from struct to class I get compiler errors:
Error 1 Error: template instance
std.typecons.RefCounted!(Payload,
cast(RefCountedAutoInitialize)1) does not match template
declaration RefCounted(T,
On 08/25/2014 12:17 PM, Marc Schütz schue...@gmx.net wrote:
On Monday, 25 August 2014 at 19:12:48 UTC, Marc Schütz wrote:
On Monday, 25 August 2014 at 18:44:36 UTC, Ali Çehreli wrote:
It can be explained if the mixed-in template is evaluated at the
mixin context without bringing in the
Ok, let's try something simpler... Where can I find the D1
v1.076 compiler error meaning of,
Error: duplicate union initialization for size
for this line,
const Size DEFAULT_SCALE = { 5, 13 };
thanks.
On Monday, 25 August 2014 at 17:10:11 UTC, Etienne wrote:
People have been saying for quite a long time not to use the
`delete` keyword on GC-allocated pointers.
I've looked extensively through the code inside the engine and
even made a few modifications on it/benchmarked it for weeks
and I
On Monday, 25 August 2014 at 20:37:16 UTC, Ryan wrote:
Then I thought I'd learn dub. Well, this is NOT going well...
I did a git clone of gtk-d, then tried to build with dub
(renamed the package.json to dub.json), and it told me
Conflicting package multi-reference I have no clue and
I've
On Sunday, 24 August 2014 at 23:20:21 UTC, maik klein wrote:
On Sunday, 24 August 2014 at 21:51:39 UTC, Weaseldog wrote:
On Sunday, 24 August 2014 at 20:32:02 UTC, maik klein wrote:
Are there any exercises/challenges for D?
Something like this?
On Tuesday, 26 August 2014 at 01:57:06 UTC, Meta wrote:
Have you heard of Project Euler? https://projecteuler.net/
The problems are mostly mathematical, and once you answer you
can compare your solution to the other solutions people have
written in other languages. The early questions also
Not sure how up your alley this is, but vim support for D is
excellent.
On Tue, Aug 26, 2014 at 02:13:04AM +, Weaseldog via Digitalmars-d-learn
wrote:
Not sure how up your alley this is, but vim support for D is
excellent.
I use vim for D.
T
--
War doesn't prove who's right, just who's left. -- BSD Games' Fortune
Is it possible to allow implicit casting from a base type to a
union type? For example, considering the following basic vector
union:
union vec2 {
struct {
float x = 0.0f;
float y = 0.0f;
}
float[2] v;
enum length = v.length;
On Tuesday, 26 August 2014 at 02:33:25 UTC, cc wrote:
Is it possible to allow implicit casting from a base type to a
union type?
All implict conversions are done using alias this:
http://dlang.org/class.html#AliasThis
- Jonathan M Davis
On Mon, 25 Aug 2014 21:07:06 +
ponce via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:
Is there a way to have cross-module inlining but with separate
compilation?
Like with link-time generation in C++ compilers.
i think that turning your functions into templates should do
On Tuesday, 26 August 2014 at 04:34:39 UTC, ketmar via
Digitalmars-d-learn wrote:
On Mon, 25 Aug 2014 21:07:06 +
ponce via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:
Is there a way to have cross-module inlining but with separate
compilation?
Like with link-time
On Tue, 26 Aug 2014 04:49:17 +
hane via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote:
No template hack needed now.
unless you using gdc, for example. ;-)
signature.asc
Description: PGP signature
61 matches
Mail list logo