On Wednesday, November 22, 2017 08:03:50 Fra Mecca via Digitalmars-d-learn
wrote:
> Why doesn't D have a in keyword for arrays?
>
> The docs explains that you can use in only for associative arrays
> but I don't see the reasons for such decision.
>
>
> Example code:
>
> void main()
> {
> auto v
On Wednesday, 22 November 2017 at 09:36:43 UTC, Dukc wrote:
On Wednesday, 22 November 2017 at 08:03:50 UTC, Fra Mecca wrote:
void main()
{
auto v = ["r", "i", "o"];
assert ("r" in v);
}
Also note that even if it wereimplemented, you search for 'r'
instead of "r". "r" is a
On Wednesday, 22 November 2017 at 08:29:26 UTC, MGW wrote:
Possibly it will be interesting
https://pp.userapi.com/c639524/v639524332/60240/uH3jnxrchik.jpg
On Tuesday, 21 November 2017 at 23:12:33 UTC, Markus wrote:
hi, im trying to interface a cpp class. I'd like to interface a
bigger library and I'm trying to figure out the minimum effort.
Possibly it will be interesting
https://www.youtube.com/watch?v=HTgJaRRfLPk
22.11.2017 02:12, Markus пишет:
snip
I could do the instancing/destruction by functions and write a custom d
class that calls these methods in this()/~this().
This is what I used to do as special members like ctor/dtor did not
supported in D before, but your example of using ctor is
On Wednesday, 22 November 2017 at 08:03:50 UTC, Fra Mecca wrote:
void main()
{
auto v = ["r", "i", "o"];
assert ("r" in v);
}
Also note that even if it wereimplemented, you search for 'r'
instead of "r". "r" is a string, but you would want to search for
a char.
On 11/22/17 5:19 PM, A Guy With a Question wrote:
I have an interface where I have a classes embedded in it's scope
(trying to create something for the classes that implement the interface
can use for unittesting).
interface IExample
{
// stuff ...
class Tester
On Thursday, November 23, 2017 00:58:21 Marc via Digitalmars-d-learn wrote:
> for example:
>
> enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
>
> enum int countOfA = coutOfFields(A); // 5 fields
import std.traits;
enum countOfA = EnumMembers!A.length;
- Jonathna M Davis
On Wednesday, 22 November 2017 at 22:45:53 UTC, A Guy With a
Question wrote:
On Wednesday, 22 November 2017 at 22:37:46 UTC, Steven
Schveighoffer wrote:
On 11/22/17 5:36 PM, Steven Schveighoffer wrote:
This allows access to the outer class's members. So you need
an instance to instantiate.
I
On Thursday, 23 November 2017 at 00:58:21 UTC, Marc wrote:
for example:
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int countOfA = coutOfFields(A); // 5 fields
https://dlang.org/spec/traits.html#allMembers
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int
On Thursday, November 23, 2017 00:49:33 Mike Parker via Digitalmars-d-learn
wrote:
> On Wednesday, 22 November 2017 at 22:45:53 UTC, A Guy With a
>
> Question wrote:
> > Out of curiosity, what does static mean in that context? When I
> > think of a static class I think of them in the context of
I have an interface where I have a classes embedded in it's scope
(trying to create something for the classes that implement the
interface can use for unittesting).
interface IExample
{
// stuff ...
class Tester
{
}
}
I'm trying to make an instance
On 11/22/17 5:36 PM, Steven Schveighoffer wrote:
This allows access to the outer class's members. So you need an instance
to instantiate.
I bet it's the same for interfaces.
All that being said, the error message is quite lousy.
-Steve
On Wednesday, November 22, 2017 22:45:53 A Guy With a Question via
Digitalmars-d-learn wrote:
> On Wednesday, 22 November 2017 at 22:37:46 UTC, Steven
>
> Schveighoffer wrote:
> > On 11/22/17 5:36 PM, Steven Schveighoffer wrote:
> >> This allows access to the outer class's members. So you need
>
here as non-static, nested class is associated with a specific
instance of the class and has access to that class instance via
its outer member.
- Jonathan M Davis
Hmmm...now you have me very intrigued. What is a use-case where
you'd want to use a non-static embedded class? Sorry if I'm
On Wednesday, 22 November 2017 at 22:45:53 UTC, A Guy With a
Question wrote:
Out of curiosity, what does static mean in that context? When I
think of a static class I think of them in the context of Java
or C# where they can't be instantiated and where they are more
like namespaces that you
On Wednesday, 22 November 2017 at 22:37:46 UTC, Steven
Schveighoffer wrote:
On 11/22/17 5:36 PM, Steven Schveighoffer wrote:
This allows access to the outer class's members. So you need
an instance to instantiate.
I bet it's the same for interfaces.
All that being said, the error message is
On Thursday, November 23, 2017 00:17:46 A Guy With a Question via
Digitalmars-d-learn wrote:
> > here as non-static, nested class is associated with a specific
> > instance of the class and has access to that class instance via
> > its outer member.
> >
> > - Jonathan M Davis
>
> Hmmm...now you
for example:
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int countOfA = coutOfFields(A); // 5 fields
On Thursday, 23 November 2017 at 01:04:29 UTC, Jonathan M Davis
wrote:
On Thursday, November 23, 2017 00:58:21 Marc via
Digitalmars-d-learn wrote:
for example:
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int countOfA = coutOfFields(A); // 5 fields
import std.traits;
enum
On 11/22/2017 05:21 PM, Marc wrote:
On Thursday, 23 November 2017 at 01:04:29 UTC, Jonathan M Davis wrote:
On Thursday, November 23, 2017 00:58:21 Marc via Digitalmars-d-learn
wrote:
for example:
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int countOfA = coutOfFields(A); // 5
On Wednesday, 22 November 2017 at 10:32:48 UTC, lobo wrote:
On Wednesday, 22 November 2017 at 09:36:43 UTC, Dukc wrote:
On Wednesday, 22 November 2017 at 08:03:50 UTC, Fra Mecca
wrote:
void main()
{
auto v = ["r", "i", "o"];
assert ("r" in v);
}
Also note that even if it
Thank you all for the helpful responses.
I will read more about ranges.
On Thursday, 23 November 2017 at 01:01:42 UTC, Michael V.
Franklin wrote:
On Thursday, 23 November 2017 at 00:58:21 UTC, Marc wrote:
for example:
enum A { a = -10, b = -11, c = -12, d = -13, e = -34}
enum int countOfA = coutOfFields(A); // 5 fields
On Thursday, 23 November 2017 at 01:34:54 UTC, Ali Çehreli wrote:
On 11/22/2017 05:21 PM, Marc wrote:
On Thursday, 23 November 2017 at 01:04:29 UTC, Jonathan M
Davis wrote:
On Thursday, November 23, 2017 00:58:21 Marc via
Digitalmars-d-learn wrote:
[...]
import std.traits;
enum countOfA =
Hello, is there way to reduce this condition:
if (c1) {
foo();
} else {
if (c2) {
bar();
} else {
if (c3) {
...
}
}
}
for instance in kotlin it can be replace with this:
when {
c1 -> foo(),
c2 -> bar(),
c3 -> ...
else ->
On Thursday, 23 November 2017 at 05:19:27 UTC, Andrey wrote:
Hello, is there way to reduce this condition:
if (c1) {
foo();
} else {
if (c2) {
bar();
} else {
if (c3) {
...
}
}
}
for instance in kotlin it can be replace with this:
when {
c1
DCD and DMD says that the symbol is undefined!
However, I look into derelichtGLFW3. It has this symbol defined!
It looks like a bug for me!
On Wednesday, 22 November 2017 at 15:07:08 UTC, Tim Hsu wrote:
I am a C++ game developer and I want to give it a try.
It seems "this" in Dlang is a reference instead of pointer.
How can I pass it as void *?
void foo(void *);
class Pizza {
public:
this() {
Pizza newone = this;
I couldn't find the d-apt-keyring package anywhere
root@d9:~# cat /etc/apt/sources.list.d/d-apt.list
deb http://master.dl.sourceforge.net/project/d-apt/ d-apt main
#APT repository for D
root@d9:~# LANG=C apt-get -y --allow-unauthenticated install
--reinstall d-apt-keyring
Reading package
On Wednesday, 22 November 2017 at 16:57:10 UTC, Joakim wrote:
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:
[...]
betterC is a new feature that's still being worked on and still
has holes in it:
https://github.com/dlang/dmd/pull/7151
I suggest you open an issue for it on
On Wednesday, 22 November 2017 at 15:14:32 UTC, Stefan Koch wrote:
On Wednesday, 22 November 2017 at 15:11:08 UTC, Tim Hsu wrote:
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch
will do.
I've tried it in the first place.
...
Error: this is not an lvalue
In that case casting
On Wednesday, 22 November 2017 at 15:23:58 UTC, Tim Hsu wrote:
I am afraid what will happen when casting this reference to
void *
a ref is a ptr.
The cast will produce a ptr which is valid as long as the ref is
valid.
I am a C++ game developer and I want to give it a try.
It seems "this" in Dlang is a reference instead of pointer.
How can I pass it as void *?
void foo(void *);
class Pizza {
public:
this() {
Pizza newone = this;
// works but newone is actually not this pizza.
On Wednesday, 22 November 2017 at 15:27:27 UTC, Dukc wrote:
On Wednesday, 22 November 2017 at 15:17:33 UTC, Adam D. Ruppe
wrote:
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch
wrote:
will do.
Even if it were an lvalue, that would be the address of a
local. You should basically
On Tuesday, 21 November 2017 at 19:22:47 UTC, Anonymouse wrote:
Compiling a debug dmd and running the build command in gdb, it
seems to be a stack overflow at ddmd/dtemplate.d:6241,
TemplateInstance::needsCodegen().
After a lot of trial and error I managed to find /a/ line which
lets it
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch wrote:
On Wednesday, 22 November 2017 at 15:07:08 UTC, Tim Hsu wrote:
I am a C++ game developer and I want to give it a try.
It seems "this" in Dlang is a reference instead of pointer.
How can I pass it as void *?
void foo(void *);
On Wednesday, 22 November 2017 at 15:11:08 UTC, Tim Hsu wrote:
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch
will do.
I've tried it in the first place.
...
Error: this is not an lvalue
In that case casting to void* should be fine.
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:
Why -betterC flag not 'include' -noboundscheck flag?
-noboundscheck is extremely harmful. If -betterC implied that, it
would no longer be a better C, it would just be the same buggy C.
The compiler should perhaps inline the
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch wrote:
will do.
Even if it were an lvalue, that would be the address of a local.
You should basically NEVER do that with D classes.
Just `cast(void*) this` if you must pass it to such a function.
On Wednesday, 22 November 2017 at 15:17:33 UTC, Adam D. Ruppe
wrote:
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch
wrote:
will do.
Even if it were an lvalue, that would be the address of a
local. You should basically NEVER do that with D classes.
Just `cast(void*) this` if
On Wednesday, 22 November 2017 at 15:17:33 UTC, Adam D. Ruppe
wrote:
On Wednesday, 22 November 2017 at 15:07:54 UTC, Stefan Koch
wrote:
will do.
Even if it were an lvalue, that would be the address of a
local. You should basically NEVER do that with D classes.
Just `cast(void*) this` if
On Wednesday, 22 November 2017 at 15:07:08 UTC, Tim Hsu wrote:
I am a C++ game developer and I want to give it a try.
It seems "this" in Dlang is a reference instead of pointer.
How can I pass it as void *?
void foo(void *);
class Pizza {
public:
this() {
Pizza newone = this;
Hello. I try compile simple example:
import core.stdc.stdio;
import std.algorithm : min;
extern (C) void main()
{
char[256] buf;
buf[] = '\0';
auto str = "hello world";
auto ln = min(buf.length, str.length);
buf[0..ln] = str[0..ln];
printf("%s\n", buf.ptr);
}
rdmd
On Wednesday, 22 November 2017 at 15:36:22 UTC, Adam D. Ruppe
wrote:
On Wednesday, 22 November 2017 at 15:31:36 UTC, Tim Hsu wrote:
It seems in D, reference has its own address, am I right?
unlike c++
The local variable does have its own address. Do not take its
address - avoid or
Just
On Wednesday, 22 November 2017 at 15:31:36 UTC, Tim Hsu wrote:
It seems in D, reference has its own address, am I right?
unlike c++
In case of classes, yes. But I think function parameter
references do not (or rather, of course they have since they
exist in memory but it's hidden). Not sure
Also
http://ithare.com/chapter-vb-modular-architecture-client-side-programming-languages-for-games-including-resilience-to-reverse-engineering-and-portability/ scroll to the part about language choice.
On Wednesday, 22 November 2017 at 15:27:27 UTC, Dukc wrote:
It's worth noting that you will still be passing different
addresses to foo(void*) because classes are reference types in
D (structs are not). In the constructor you're passing the
address of the class object itself, but in the main
On Wednesday, 22 November 2017 at 15:23:58 UTC, Tim Hsu wrote:
m_window = glfwCreateWindow();
glfwSetWindowUserPointer(m_window, cast(void *)());
That that & out of there!
glfwSetWindowUserPointer(m_window, cast(void *)(this));
without the &, you are fine.
Then, on the other side,
another indicator (as documented) that GC destructor won't work
// extern(C++) classes don't have a classinfo pointer in their
vtable so the GC can't finalize them
https://github.com/dlang/druntime/blob/3d8d4a45c01832fb657c16a656b6e1566d77fb21/src/rt/lifetime.d#L90
annoying :(
Markus
On Wednesday, 22 November 2017 at 15:31:36 UTC, Tim Hsu wrote:
It seems in D, reference has its own address, am I right?
unlike c++
The local variable does have its own address. Do not take its
address - avoid or
Just cast the ref itself.
In D, a class this or Object variable is already
On Wednesday, 22 November 2017 at 15:34:53 UTC, Adam D. Ruppe
wrote:
No, in both cases, if you do as I say, you will be passing the
same address.
I was referring to his version of the main function that used &.
But yes, if you do a cast instead it works just as you say.
On Wednesday, 22 November 2017 at 15:33:46 UTC, Anonymouse wrote:
On Tuesday, 21 November 2017 at 19:22:47 UTC, Anonymouse wrote:
Compiling a debug dmd and running the build command in gdb, it
seems to be a stack overflow at ddmd/dtemplate.d:6241,
TemplateInstance::needsCodegen().
After a
On Wednesday, 22 November 2017 at 08:43:54 UTC, drug wrote:
22.11.2017 02:12, Markus пишет:
What about dtor - you allocate class using D GC but try to
destroy it manually - namely this I guess gives you an error in
rt_finalize2 because it tries to destroy object that has been
destroyed.
22.11.2017 19:06, Markus пишет:
another indicator (as documented) that GC destructor won't work
// extern(C++) classes don't have a classinfo pointer in their vtable so
the GC can't finalize them
On Wednesday, 22 November 2017 at 15:10:40 UTC, Oleg B wrote:
Hello. I try compile simple example:
import core.stdc.stdio;
import std.algorithm : min;
extern (C) void main()
{
char[256] buf;
buf[] = '\0';
auto str = "hello world";
auto ln = min(buf.length, str.length);
56 matches
Mail list logo