Jonathan M Davis jmdavisp...@gmx.com wrote:
struct Ordinal {
private int representation;
char getChar( ) {
return representation + 'a'-1;
}
alias representation this;
alias getChar this;
}
But like I said, it currently does not work.
Would alias getChar this
Peter Lundgren lundg...@rose-hulman.edu wrote:
I'd like to define a type Ordinal which behaves like an int (using a
struct or
alias) that represents the 26 letters, A-Z, with the numbers 1-26. Then,
I
would like to be able to coerce between chars and Ordinals appropriately.
chars and ints
Tyro[a.c.edwards] nos...@home.com wrote:
class Class{}
void main()
{
Class myClass;
Class* pClass0 = myClass; // OK
Class* pClass1 = new Class; // Error: cannot implicitly convert [8]
// expression (new Class) of type t.Class
//
Tyro[a.c.edwards] nos...@home.com wrote:
I'm trying to convert some c++ code that defines
T func(par...)
{
Controller * pCtrl = WinGetLongController * (hwnd);
.
.
.
switch(msg)
{
case FirstMatch:
pCtrl = new Controller (hwnd, reinterpret_castCREATESTRUCT *
bearophile bearophileh...@lycos.com wrote:
I don't know if there is a way to write IsClass() in a shorter way, like
a lambda template.
No such thing, sadly. I have suggested it before, and would love to see
such a feature.
--
Simen
Sean Eskapp eatingstap...@gmail.com wrote:
I remember in C++, I had to do double-dispatch using the visitor
pattern. This
is cumbersome, just because each subclass has to have the exact same
singly-dispatched code that looks like:
void dispatch(Base other)
{
other.dispatch(*this);
}
Is
%u wfunct...@hotmail.com wrote:
Hi,
I was wondering, why are we allowed to omit parentheses when calling
functions
with no arguments, when they are not @properties? Is there a good reason
for
relaxing the language rules like this?
This behavior is deprecated, but other features have had
Nrgyzer nrgy...@gmail.com wrote:
Hey guys,
I have an associative array like this: T[hash_t] myArray; (T means
the template type).
Is there any chance to cast/convert this array to an indexed array or
is it possible to iterate over specific indices? I know that there is
something like next()
Magnus Lie Hetland mag...@hetland.org wrote:
Hm. Just to make sure this *is* a bug, and I'm not just being a dumbass
... this is a tiny program that illustrates the problem (i.e., gives the
error above). Perhaps the use of a local function here really is
prohibited...?
Maybe it is. It
Magnus Lie Hetland mag...@hetland.org wrote:
Sort of related (though perhaps only remotely) is the following, which
won't compile (Error: static assert Bad unary function: f(a) for type
int):
Not related. unaryFun and binaryFun are simply glorified string mixins,
and thus can only access
Magnus Lie Hetland mag...@hetland.org wrote:
On 2011-02-01 16:09:22 +0100, Simen kjaeraas said:
Magnus Lie Hetland mag...@hetland.org wrote:
Sort of related (though perhaps only remotely) is the following, which
won't compile (Error: static assert Bad unary function: f(a) for type
int
Magnus Lie Hetland mag...@hetland.org wrote:
I'm building a function (or template or whatever, really) that is
related to map and minPos in std.algorithm. Basically, it's the standard
mathematical argmin, except that it also returns min. It looks something
like this:
auto minArg(alias
Magnus Lie Hetland mag...@hetland.org wrote:
Might I also ask why you use an out parameter instead of a tuple return?
Well... I had a tuple return at first, but one of the advantages of
returning multiple values that I'm accustomed to is the ability to
assign to multiple variables, such
Andrej Mitrovic andrej.mitrov...@gmail.com wrote:
On 1/31/11, Simen kjaeraas simen.kja...@gmail.com wrote:
module foo;
import std.typecons;
import std.functional;
import std.array;
template optArg( alias pred ) {
template optArg( alias fn ) {
auto optArg( Range )( Range r
Magnus Lie Hetland mag...@hetland.org wrote:
Hm. Using code quite similar to you, supplying a lambda in the second
aliasing, I get this error:
something.d(93): Error: template instance cannot use local
'__dgliteral2(__T3)' as parameter to non-global template optArg(alias
fun)
It seems
Eelco Hoogendoorn hoogendoorn.ee...@gmail.com wrote:
Hi,
I am trying to combine C# and D, to get what is to me the best of both
worlds; large libraries and excellent toolchain, with to the
metal programming.
Currently, I am doing this by means of C#/CLI/C++ interop, but I got
reminded as
Michel Fortin michel.for...@michelf.com wrote:
unless it's acceptable to just make the mutability const. which would
give:
csm cs
csc cs
msm cs
msc cs
No, that doesn't
Nrgyzer nrgy...@gmail.com wrote:
The result is: true which means that testInstance of type a is null -
but I
already created a instance and if I write writeln(testInstance is
null); after
Thread.yield(); in the main, it says false which means testInstance is
a valid
instance of the class
spir denis.s...@gmail.com wrote:
Adds one char compared to D syntax, but allows partially hex-coded
string:
blah #xx xxx# blah
I like having the ability to embed #'s in my strings, thank you.
--
Simen
Trass3r u...@known.com wrote:
Why do they exist and why does typeof(this) strip constness?
Template this parameters allow for covariant return types, that's about
all the use cases I've found for it. It seems like such a great thing,
almost doing automatic overriding of methods in subclasses,
Trass3r u...@known.com wrote:
2. What is the reason for Phobos defining param funcs as template
params?
Correct me if I'm wrong but there's no way to pass an arbitrary
function to a function in a type-safe way. If you use pointers and
casts you can't check if the passed function meets certain
spir denis.s...@gmail.com wrote:
Hello,
Cannot find corresponding opSomething method, if any. (opDispatch seems
to specialise for method call.)
Else, how to catch obj.member?
opDispatch is likely what you want. with the @property annotation, it
will readily support obj.member; and
spir denis.s...@gmail.com wrote:
On 01/25/2011 10:29 PM, Simen kjaeraas wrote:
spir denis.s...@gmail.com wrote:
Hello,
Cannot find corresponding opSomething method, if any. (opDispatch
seems to
specialise for method call.)
Else, how to catch obj.member?
opDispatch is likely what you
pragma the_ignora...@hotmail.com wrote:
Hi i come from a c# background
I would like to write the following code in the according D style but
i'm not
sure howto do it
c# code:
void foo(IEnumerabledouble[] data)
{
foreach (var d in data)
{
do_some_stuff(d);
}
}
i guess the D
Jesse Phillips jessekphillip...@gmail.com wrote:
Simen kjaeraas Wrote:
pragma the_ignora...@hotmail.com wrote:
Hi i come from a c# background
I would like to write the following code in the according D style but
i'm not
sure howto do it
c# code:
void foo(IEnumerabledouble[] data
Ellery Newcomer ellery-newco...@utulsa.edu wrote:
in the following:
void main(){
char[] x;
string s;
string y;
y = s ~ x;
}
tok.d(5): Error: cannot implicitly convert expression
(cast(const(char)[])s ~ x) of type char[] to string
why should typeof(s ~ x) == char[] ?
Luke J. West l...@west.me.uk wrote:
Hi,
I don't want to keep typing isNumeric!T | isSomeChar!T. I want to type
isBuiltIn!T instead, but am trying to work out how to implement it.
Something like
template isBuiltInT(T) {const bool t=isNumeric!T | isSomeChar!T};}
alias isBuiltInT.t isBuiltIn;
Trass3r u...@known.com wrote:
class Foo
{
int x;
int y;
int z;
mixin NonSerialized!(z);
}
Had a quick look at
http://dsource.org/projects/orange/browser/orange/serialization/Serializable.d
1. How come it works without 'mixin' in the template declaration (mixin
Mandeep Singh Brar mand...@brars.co.in wrote:
This would be easily resolved if interfaces were known to be Objects.
But shouldnt this be the case, because there would be nothing called as
an
Interface which can be pointed to; it would be an Object which is
implementing an
interface which
Steven Schveighoffer schvei...@yahoo.com wrote:
Nope. try it:
interface I { bool opEquals(I other); }
I a;
I b;
a == b; // same error.
The problem is that when TDPL was implemented, (Object)a == (Object)b
was redefined from a.opEquals(b) to object.opEquals(a, b), where object
is the
Stewart Gordon smjg_1...@yahoo.com wrote:
Of course, if the interface declares an opEquals, it's a whole different
story
It is? Can't seem to get it to work here, and I get the same errors you
get.
--
Simen
Mandeep Singh Brar mand...@brars.co.in wrote:
Hi,
I am not able to assign an interface to object. The following code
does not compile.
module testObj;
public interface testInterface {
void someMethod();
}
public class testObj
{
Object someCaller;
this(Object caller) {
Trass3r u...@known.com wrote:
module testObj;
public interface testInterface {
void someMethod();
}
public class testObj
{
Object someCaller;
this(Object caller) {
someCaller = caller;
}
this(testInterface tI, bool xyz) {
Moritz Warning moritzwarn...@web.de wrote:
My tangofied of this code works, maybe it's a lib bug?
On the other hand, is the delegate allocated on the stack?
Anyway, here is another way:
R delegate(T) toDg(R, T...)(R function(T) fp)
{
struct dg
{
R opCall(T t)
{
Sean Eskapp eatingstap...@gmail.com wrote:
The language documentation covers some basic uses of TypeTuples in
templates,
but nothing about using them with classes. I would like a template class,
which essentially wraps a function, which has template parameters for
return
value and template
%u e...@ee.com wrote:
I only need something to make a void deleg() from a void func().
This works for me:
ReturnType!( F ) delegate( ParameterTypeTuple!( F ) ) toDelegate( F )( F
fn ) {
return ( ParameterTypeTuple!( F ) args ){ return fn( args ); };
}
--
Simen
%u e...@ee.com wrote:
Should I post it as a bug, even though I have no code to accompany it?
I have no clue as to where to start my directed search for a minimal
case.
Please do post it, yes. As for searching, if you are willing to share
the code , others may be willing to do the search.
Sean Eskapp eatingstap...@gmail.com wrote:
I have a variable of type TypeTuple!(int, int), and I want to convert
all its
elements into a variable of type TypeTuple!(string, string). Is there a
way to
do this? Using a loop fails compilation with Error: Integer constant
expression expected
Mitja odtih...@gmail.com wrote:
I would like to have a template which returns
appropriate delegate, something like this:
So like this?
module mod1;
import std.algorithm;
import std.functional;
import std.stdio;
void main( ) {
auto haystack = [a,b,c];
auto needle = b;
auto flt =
%u wfunct...@hotmail.com wrote:
You have to add it to the garbage collector's list of roots
But if I need to do that, then what would be the difference between
void[] and
ubyte[]?
None what so ever. If you want to mark some memory with special bits,
use setattr in core.memory.
--
Simen
Jun bli...@naver.com wrote:
Does anyone knows how can I set the boundary of uniform()?
I got an error with uniform([], 0, 10);
The documentation seems a bit weird on uniform, yes.
The correct way is:
uniform![]( 0, 10 )
--
Simen
%u wfunct...@hotmail.com wrote:
Hi,
There's a question that's been lurking in the back of my mind ever since
I learned about D:
How does the GC distinguish code from data when determining the objects
to collect? (E.g. void[] from uint[], size_t from void*, etc.?)
This is hardly the
Daren Scot Wilson dar...@darenscotwilson.com wrote:
As shown, the total evil return statement gets a value from subroutine
foo(). Being somehow so perfect in its evilness, this passes through
the compiler without a burp. The resulting executable returns zero (or
my bash shell defaults to
Jacob Carlborg d...@me.com wrote:
When I try to compile the following code:
class A
{
void opDispatch (string name, this T) () { }
}
class B : A {}
void main ()
{
auto b = new B;
b.foobar();
}
I get this error:
Error: template instance opDispatch!(foobar) does not match
Piotr Szturmaj bncr...@jadamspam.pl wrote:
static assert(isNullable!(Nullable!int));
Question is, what I'm doing wrong?
The problem here is that Nullable!T is not a real type. Hence,
Nullable!int is actually
Algebraic!(int,void*). Checking for that apparently does not work as
simply as
Ellery Newcomer ellery-newco...@utulsa.edu wrote:
why does SList.insertFront have a complexity of O(log(n)) ?
Good question! It certainly is not the code's fault, as that's O(1) for
single elements and O(m) for ranges. File it to Bugzilly, I guess.
--
Simen
bearophile bearophileh...@lycos.com wrote:
(I don't know why templated methods can't be virtual)
First of all, they can. But it's a shitload of extra work, and requires
that compilation be mixed up with linking.
Whenever a templated method is used from any subclass, it has to be
generated
doubleagent doubleagen...@gmail.com wrote:
The former works while the latter fails. It looks like there's some
manipulation of 'bytes' and 'list' when writefln forces evaluation. My
question is should this happen?
void main() {
immutable auto bytes = splitter(stdin.readln(), ' ');
spir denis.s...@gmail.com wrote:
Also, My actual need would rather be to move forward. The reason is this
allows important optimisations for common cases. In fact, the codes are
unicode code points: if the 5 first bits are 0 (tested with a mask), I
can jump forward to a sub-tree
spir denis.s...@gmail.com wrote:
foreach ( i; 0..BIT_SIZE ) {
bit = ( code i ) 1;
node = node.nodes[bit];
}
You have not read my post carefully enough ;-) That's ~ how I coded
traversing the bit seq backwards (right-to-left, LSB - MSB); but I was
trying to find a way to
spir denis.s...@gmail.com wrote:
Hello,
If I have
class Node (Element) {...}
can I subtype it like with
class Leaf (Element) : Node (Element) {...}
or such?
Yes.
--
Simen
Stanislav Blinov stanislav.bli...@gmail.com wrote:
On 12/26/2010 05:47 PM, spir wrote:
Hello,
If I have
class Node (Element) {...}
can I subtype it like with
class Leaf (Element) : Node (Element) {...}
or such?
Denis
Absolutely:
class Leaf(Element) : Node!Element {...}
doubleagent doubleagen...@gmail.com wrote:
There have been several asking for tail-const (i.e. const(int)[])
support for ranges other than arrays. I have even written an
implementation that to an extent works, but more language support would
be preferable.
That seems like a really important
Nrgyzer nrgy...@gmail.com wrote:
I just figured out that this doesn't work, when I use a array with
super class as base type, for example: Drawable[] textures;
Then, I'll get the following error:
Error: function draw!(void*).draw non-virtual functions cannot be
abstract.
I just implemented
Jonathan M Davis jmdavisp...@gmx.com wrote:
A big problem with having template functions be virtual is the fact that
such
functions don't exist until they're called, whereas a class and its
virtual
function need to exist regardless of whether the functions get called -
particularly when you
Heywood Floyd soul...@gmail.com wrote:
Is this possible somehow:
int op(int r, int i)
{
static auto tbl = [add, sub, mul];
goto tbl[i % 3];
add:
r++;
goto end;
sub:
r--;
goto end;
mul:
Heywood Floyd soul...@gmail.com wrote:
Thanks for the answer!
Ok, hm, how about this then:
auto opTable = [op_add, op_cmp, op_end]; //etc.
ubyte[] eval(ubyte[] prog)
{
int ip = 0, sp = 0;
ubyte[4096] stack;
next:
d coder dlang.co...@gmail.com wrote:
Greetings
I want to find if a given struct type is instantiated from a
particular template struct type. For example:
struct S (T) {
alias T Type;
T t;
}
And later I want to find out if a given type is of type S(*)
(basically any type instantiated
d coder dlang.co...@gmail.com wrote:
I do know the template. I will try out your solution. Will let you
know if I face issues.
Simen
It works perfect, And this is exactly what I was looking for. If you
see my original post, I also thought this form of is expression
should work. Just could
Andrej Mitrovic n...@none.none wrote:
I found this by accident:
import std.stdio;
import std.conv;
void main()
{
writeln(to!string(2, 2)); // writes 10
writeln(to!string(1, 0)); // std.conv.ConvException: Radix error
}
I'm not sure why std.conv.to would even take multiple
d coder dlang.co...@gmail.com wrote:
Greetings
I need a way to know (using traits or other compile time constructs)
all the types derived from a given type.
Is it possible in D?
No.
Is it possible to get a list of all the user-defined classes? I could
use that to filter out the classes
Simen kjaeraas simen.kja...@gmail.com wrote:
Given an index structure like this:
struct Index( alias arr ) if ( is( typeof( arr ) t : U[], U ) ) {
private size_t idx;
@property pure nothrow size_t get( ) const {
return idx;
}
alias get this;
invariant
Eyyub eyyu...@hotmail.fr wrote:
I recently upgraded to the D 2, and i would like understand for which
reason they are the immutable keyword !
immutable means 'this data cannot change'. It is different from const in
that the latter means 'I cannot change this data (but someone else may
change
spir denis.s...@gmail.com wrote:
PS: Also tried to make iteration work by defining slice with no
argument (coll[]) only, like indicated in TDPL p.381. But could not
manage to do it.
The point of coll[] is that a collection may not want to define the
range primitives itself, but rather
spir denis.s...@gmail.com wrote:
(1) In my case, I do not want to modify the range (actually the private
collection), because the type is not only about beeing a range (~
provide iteration). So that I defined the range methods, using a private
'rangeIndex slot', as (the type also maintains
Given an index structure like this:
struct Index( alias arr ) if ( is( typeof( arr ) t : U[], U ) ) {
private size_t idx;
@property pure nothrow size_t get( ) const {
return idx;
}
alias get this;
invariant( ) {
assert( idx arr.length );
}
this(
Andrej Mitrovic andrej.mitrov...@gmail.com wrote:
Cool! But, when is ctod.exe coming out? :p
That should have been cpptod. ;)
As soon as you write it.
--
Simen
Ellery Newcomer ellery-newco...@utulsa.edu wrote:
I might just be having one of those moments, but if static arrays are
value types, doesn't it make more sense that
arr1 = arr2;
performs a value copy than a reference copy?
That's what it does. Not a deep value copy, of course, but a value
spir denis.s...@gmail.com wrote:
Hello,
In a previous post, I asked how to define, in a module, a set of symbols
for export.
I was blocked then mainly because the compiler did not let me freely
define what I wanted to define, at the module's toplevel. Especially, it
does not allow
spir denis.s...@gmail.com wrote:
In the general case, defining symbols requires kinds of statement (but I
don't see what you mean by statement as for me an assignemnt is the
archetype of a statement, so how can you define anything?).
http://digitalmars.com/d/2.0/declaration.html
A
Andrej Mitrovic n...@none.none wrote:
maintest.def:
EXETYPE NT
SUBSYSTEM WINDOWS
maintest.d:
http://pastebin.com/3c4CKDG1
Compiled with DMD 2.050:
dmd maintest.d maintest.def
The output in the log file is Lenght: 0. The static constructor is
never called when using WinMain.
But if I use
Pelle MÃ¥nsson pelle.mans...@gmail.com wrote:
'auto' is not a placeholder for a type, but the default storage class.
IOW, 'int n;' == 'auto int n;'. This does however not compile,
complaining that it has no effect.
Specifying just the storage class signals the compiler to use type
inference.
Nrgyzer nrgy...@gmail.com wrote:
But... when I try the following:
char[] myString = Currency: ~ cast(char) CURRENCY.DOLLAR
It works, but not for all currencies.
What can I do to support all currencies?
The problem is that not all UTF-8 code points fit in one char.
I would recommend in this
Nrgzyer nrgz...@gmail.com wrote:
When I use an string enumeration, I get the following error (dmd1):
CURRENCY base type must be of integral type, not char[]
Ah, you're using D1. Well, a solution would be to use dchar[] instead
of char[].
--
Simen
bearophile bearophileh...@lycos.com wrote:
If in a D2 program I have an array of mutable items I may want to
iterate on them but not modify them, so I'd like the iteration variable
to be const. This is possible, but it seems I lose type inference:
void main() {
int[3] array; // not
spir denis.s...@gmail.com wrote:
On Mon, 15 Nov 2010 12:44:24 -0500
bearophile bearophileh...@lycos.com wrote:
spir:
1. name objects automatically
I need some objects to know their name (as field on themselves). the
only solution I can else imagine is for the user write:
x = ...;
Michal Minich michal.min...@gmail.com wrote:
first: extern (C) means that the function 'fun' is not defined in D, but
in C.
Wrong. It means the function has C calling convention. If it has a body,
it is defined in D, and can be called from C (and D). If not, it is defined
elsewhere, and can
Jesse Phillips jessekphillip...@gmail.com wrote:
Can you forward declare a reference like this in D? If not does it
matter what I define it to be?
struct fuse {} // Since I'm really only passing pointers to this anyway.
Sure hope this makes it work.
It's completely safe to define it like
Adam Burton adz...@gmail.com wrote:
I looked into alias this and it does indeed work, unless the alias is to
a
function. That has been reported as a bug though
http://d.puremagic.com/issues/show_bug.cgi?id=2814
Wouldn't that be the opposite of what you were discussing earlier?
alias this
spir denis.s...@gmail.com wrote:
On Sun, 31 Oct 2010 17:31:54 -0400
Nick Sabalausky a...@a.a wrote:
spir denis.s...@gmail.com wrote in message
news:mailman.45.1288523296.21107.digitalmars-d-le...@puremagic.com...
Also, I could not find functional methods like map, filter,
reduce in
Trass3r u...@known.com wrote:
I also wanted to allow for swizzled setters, but apparently that's
currently not possible[1].
[1]: http://d.puremagic.com/issues/show_bug.cgi?id=620
What a pity!
Actually, after a bit of hacking, I have found a way:
// new helper function
static private bool
spir denis.s...@gmail.com wrote:
Hello,
I have a little issue with pointer syntax:
auto toS = (abc) ; // ok
auto toS = abc ; // ok
auto toI = (1) ; // Error: constant 1 is not an lvalue
auto toI = 1 ; // Error: constant 1 is not an lvalue
The
spir denis.s...@gmail.com wrote:
I would like to learn about possible workarounds, or other alternative
approaches to such problems, if ever you now any.
Basically, you probably want to use alias this:
http://digitalmars.com/d/2.0/class.html#AliasThis
It lets you subtype structs by
spir denis.s...@gmail.com wrote:
Hello,
The reference states:
ThrowStatement:
throw Expression ;
Expression is evaluated and must be an Object reference. The Object
reference is thrown as an exception.
throw new Exception(message);
The example uses an Excpetion type, but
Mike Chaten mcha...@gmail.com wrote:
I was under the impression that alias this just was shorthand for
Class Foo {
int x;
alias x this;
}
Foo foo = new Foo
foo = 9; // foo.x = 9
Foo Foo = 9 // null.x =9;
Not just. this would also work:
int n = foo;
// void bar( int n ) {}
bar( foo );
spir denis.s...@gmail.com wrote:
===
alias char[] Text ;
Text letters = ['a','b','c',...] ;
Text[] nameSet (uint count , uint size) {
/* set of count random names of size size */
Text[] names ; names.length = count ;
Text name ; name.length = size ;
Andrej Mitrovic n...@none.com wrote:
AFAIK the following should be allowed, but it's not (v2.048):
void test(uint) { }
void test(T)(T value) { }
void main()
{
test(42);
test(hello);
}
These end up conflicting with each other. From what I've read in TDPL we
should be able to
Bob Cowdery b...@bobcowdery.plus.com wrote:
x_points[]
=(x_average[0]+x_average[1]+x_average[2]+x_average[3]+x_average[4]+x_average[5]+
x_average[6]+x_average[7]+x_average[8]+x_average[9])/10;
The average gives me a compile error of incompatible types.
You need to append [] to
Bob Cowdery b...@bobcowdery.plus.com wrote:
On 12/10/2010 20:29, Simen kjaeraas wrote:
Bob Cowdery b...@bobcowdery.plus.com wrote:
x_points[]
=(x_average[0]+x_average[1]+x_average[2]+x_average[3]+x_average[4]+x_average[5]+
x_average[6]+x_average[7]+x_average[8]+x_average[9])/10
Bob Cowdery b...@bobcowdery.plus.com wrote:
x_average[ptr] = x_points; // tells me array length don't match.
When I print x_average[ptr] or x_average[][ptr] or x_average[ptr][] they
all tell me the length is 10. What do I have to do to get to the row
which is 600?
Oh, yes. Sorry, I didn't
%u e...@ee.com wrote:
How gc unfriendly is an union of objects and sizet_t?
union{
size_t arr[10];
Class obj[10];
}
All elements of this union will be considered pointers by the GC.
And, if multiple arrays contain exclusively the same objects, is it then
safe/useful to mark all but
%u e...@ee.com wrote:
== Quote from Simen kjaeraas (simen.kja...@gmail.com)'s article
%u e...@ee.com wrote:
How gc unfriendly is an union of objects and sizet_t?
union{
size_t arr[10];
Class obj[10];
}
All elements of this union will be considered pointers by the GC.
The object
Benjamin Thaut c...@benjamin-thaut.de wrote:
Hi, I'm writing a vec4 math struct and I have a method of which the
return value has to be a lvalue so I wonder which is the correct way to
do this:
vec4 Normalize() const { ... } //won't work, not a lvalue
ref vec4 Normalize() const {
vec4
Steven Schveighoffer schvei...@yahoo.com wrote:
The correct way is to use auto ref as the parameter:
struct vec4
{
...
vec4 Normalize(auto ref const(vec4) param) {...}
}
But AFAIK, this doesn't really work.
It doesn't, no. I'm not even sure it's scheduled for inclusion.
Also, with
bearophile bearophileh...@lycos.com wrote:
In D classes start with an upper case, and methods with a lower case
(and both generally use camelCase/CamelCase instead of underscores).
So the way to write that code is:
abstract class Foo {
protected:
void wrongType() {
Yes, if one is to
Benjamin Thaut c...@benjamin-thaut.de wrote:
If I want to tell the compiler that a certain function argument should
not be
copied (say a large struct, or a array) which is the right way to do?
arrays:
1. function foo(in float[] bar) { ... }
2. function foo(ref const(float[]) bar) { ... }
3.
Sebastian Schuberth sschube...@gmail.com wrote:
As a side note, I find the syntax quite unfortunate. It reads to me as
if the static constructor will only be called if the default constructor
is used (I know, this does not make sense as the static constructor will
be called before main,
Trass3r u...@known.com wrote:
Here's a basic D2 fixed-size vector implementation for you to study:
http://sfml.svn.sourceforge.net/viewvc/sfml/branches/sfml2/DSFML/import/dsfml/system/vector.d?view=markup
I can't help but wonder if those neat SSE functions are a waste.
Functions that use
Simen kjaeraas simen.kja...@gmail.com wrote:
Trass3r u...@known.com wrote:
Here's a basic D2 fixed-size vector implementation for you to study:
http://sfml.svn.sourceforge.net/viewvc/sfml/branches/sfml2/DSFML/import/dsfml/system/vector.d?view=markup
I can't help but wonder if those neat
Sebastian Schuberth sschube...@gmail.com wrote:
Hi,
I'm all new to D (coming from C++), and currently playing around with
the language. I'm using DMD 2.049 and was expecting this to compile:
struct Vector(alias N,T)
{
Vector(T[N] v ...) {
This is not a constructor, but a malformed
201 - 300 of 453 matches
Mail list logo