Re: Can't get Visual D to come up. No warnings, no errors, no nothing

2014-09-23 Thread remco johannes via Digitalmars-d-learn

On Monday, 22 September 2014 at 03:21:44 UTC, WhatMeWorry wrote:

Anybody installed Visual D recently?

As per the install instructions, I downloaded the  Visual 
Studio isolated Shell 2013 and its integrated package. 
Everything went smoothly.  I then downloaded Visual D and 
installed it with no problems. However, when I try to run the 
vdserver.exe application, nothing happens?


Am I missing something obvious?


you should install: vs shell intergrated
Start: devenv.exe (develop environment) to start

But it is a pain i am having trouble installing it as well i 
tried 2008 and 2010


Good luck,

Remco


Re: New changes to DDOC where is the u tag coming from in parent classes?

2014-09-23 Thread Gary Willoughby via Digitalmars-d-learn
On Monday, 22 September 2014 at 20:44:25 UTC, Gary Willoughby 
wrote:
Below is a change that results from re-generating my 
documentation using ddoc. I wonder where the new u tags are 
coming from that wrap the parent class name.


-div class=module-membersh2a name=Button/aclass 
span class=symbolButton/span: 
tkd.widget.textwidget.TextWidget;
+div class=module-membersh2a name=Button/aclass 
span class=symbolButton/span: 
utkd.widget.textwidget.TextWidget/u;


Has there been a new ddoc symbol defined and not mentioned in: 
http://dlang.org/ddoc.html I've redefined most of these in my 
own .ddoc file and can't seem to get rid of the new tag. Is 
there a master ddoc file being read from somewhere?


Any help?


This has started to occur with the latest compiler release.


Re: Can't get Visual D to come up. No warnings, no errors, no nothing

2014-09-23 Thread evilrat via Digitalmars-d-learn
On Tuesday, 23 September 2014 at 07:02:58 UTC, remco johannes 
wrote:

On Monday, 22 September 2014 at 03:21:44 UTC, WhatMeWorry wrote:

Anybody installed Visual D recently?

As per the install instructions, I downloaded the  Visual 
Studio isolated Shell 2013 and its integrated package. 
Everything went smoothly.  I then downloaded Visual D and 
installed it with no problems. However, when I try to run the 
vdserver.exe application, nothing happens?


Am I missing something obvious?


you should install: vs shell intergrated
Start: devenv.exe (develop environment) to start

But it is a pain i am having trouble installing it as well i 
tried 2008 and 2010


Good luck,

Remco


why you guys have problems with it? it is so simple, install 
isolated shell first, then install ingegrated shell, install 
visuald and now you have your visuald environment ready to use.


Re: Can't get Visual D to come up. No warnings, no errors, no nothing

2014-09-23 Thread Remco johannes via Digitalmars-d-learn


why you guys have problems with it? it is so simple, install 
isolated shell first, then install ingegrated shell, install 
visuald and now you have your visuald environment ready to use.


i Tried al kind of combination and installing orer - including
the one you propossed - unfortunately it did not work for some
reason

Remco


Re: Can't get Visual D to come up. No warnings, no errors, no nothing

2014-09-23 Thread remco johannes via Digitalmars-d-learn


why you guys have problems with it? it is so simple, install 
isolated shell first, then install ingegrated shell, install 
visuald and now you have your visuald environment ready to use.


i Tried al kind of combination and installing order - including
the one you propossed - unfortunately it did not work for some
reason

Remco


Re: Does remove immutability using cast to pass in a function make sense?

2014-09-23 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/22/14 10:07 PM, AsmMan wrote:

I have this array:

static immutable string[] months = [jan, fev, ...];

I need to pass it into canFind(). But it doesn't works with immutables
so I need to cast it like in canFind(cast(string[]) months, month) to
work. There's a reason related to design why it doesn't work with
immutables or a function just wasn't written?

What I want to know is if I'm doing something wrong in casting it to
work. I know from C which such casts should be done carefully


Yes, casting should be used very sparingly, and only when you have no 
other choice.


Ali suggests that the latest version of DMD on git handles this, but 
just an FYI, you do not need to cast to get a mutable array of strings:


canFind(months[], month)

should work.

-Steve


Re: New changes to DDOC where is the u tag coming from in parent classes?

2014-09-23 Thread Kagamin via Digitalmars-d-learn

https://issues.dlang.org/show_bug.cgi?id=198


Re: New changes to DDOC where is the u tag coming from in parent classes?

2014-09-23 Thread Kagamin via Digitalmars-d-learn
On Monday, 22 September 2014 at 20:44:25 UTC, Gary Willoughby 
wrote:

Is there a master ddoc file being read from somewhere?

https://github.com/D-Programming-Language/dmd/blob/master/src/doc.c#L132


Re: Can't get Visual D to come up. No warnings, no errors, no nothing

2014-09-23 Thread evilrat via Digitalmars-d-learn
On Tuesday, 23 September 2014 at 10:29:10 UTC, remco johannes 
wrote:


why you guys have problems with it? it is so simple, install 
isolated shell first, then install ingegrated shell, install 
visuald and now you have your visuald environment ready to use.


i Tried al kind of combination and installing order - including
the one you propossed - unfortunately it did not work for some
reason

Remco


iirc vs 2013 requires windows 8 or 8.1, try vs 2010 instead


Re: New changes to DDOC where is the u tag coming from in parent classes?

2014-09-23 Thread Gary Willoughby via Digitalmars-d-learn

On Tuesday, 23 September 2014 at 10:54:35 UTC, Kagamin wrote:
On Monday, 22 September 2014 at 20:44:25 UTC, Gary Willoughby 
wrote:

Is there a master ddoc file being read from somewhere?

https://github.com/D-Programming-Language/dmd/blob/master/src/doc.c#L132


Thanks! I'd bet my arse it's DDOC_PSUPER_SYMBOL! I haven't seen 
that one before, i'll try it later.


with (auto p = new ...)

2014-09-23 Thread Andre via Digitalmars-d-learn

Hi,

I just wonder why with (auto p = new ...) is not working.
It would be some syntax sugar in this scenario:

with (auto p = new Panel())
{
parent = this;
text = bla;
with (auto b = new Button())
{
parent = p; // Here p is needed
text = bla2;
}
}

source\app.d(8): Error: expression expected, not 'auto'
source\app.d(8): Error: found 'p' when expecting ')'
source\app.d(8): Error: found '=' instead of statement
...

Kind regards
André


Re: with (auto p = new ...)

2014-09-23 Thread Nordlöw

On Tuesday, 23 September 2014 at 15:19:59 UTC, Andre wrote:

I just wonder why with (auto p = new ...) is not working.
It would be some syntax sugar in this scenario:


I presume with is limited to expressions and not statements as 
the messages says.


However, you can use

if (auto p = new Panel())

instead as long as the new doesn't fail, that is you still have 
memory left :)


Re: with (auto p = new ...)

2014-09-23 Thread Graham Fawcett via Digitalmars-d-learn

How about:

auto b - new Button(); with (b) {

On Tuesday, 23 September 2014 at 15:19:59 UTC, Andre wrote:

Hi,

I just wonder why with (auto p = new ...) is not working.
It would be some syntax sugar in this scenario:

with (auto p = new Panel())
{
parent = this;
text = bla;
with (auto b = new Button())
{
parent = p; // Here p is needed
text = bla2;
}
}

source\app.d(8): Error: expression expected, not 'auto'
source\app.d(8): Error: found 'p' when expecting ')'
source\app.d(8): Error: found '=' instead of statement
...

Kind regards
André




Re: with (auto p = new ...)

2014-09-23 Thread Graham Fawcett via Digitalmars-d-learn

Sorry, I sent that last message before I intended to.

How about:

 auto b = new Button(); with (b) {
   ...
 }

'b' is explicitly outside of the scope of the 'with' block, which 
may not be what you intended. But you could use more braces to 
add an extra level of scope if that's an issue:


...
text = blah;
{
   auto b = new Button(); with (b) {
   ...
   }
}
// b is no longer in scope

Graham




On Tuesday, 23 September 2014 at 15:19:59 UTC, Andre wrote:

Hi,

I just wonder why with (auto p = new ...) is not working.
It would be some syntax sugar in this scenario:

with (auto p = new Panel())
{
parent = this;
text = bla;
with (auto b = new Button())
{
parent = p; // Here p is needed
text = bla2;
}
}

source\app.d(8): Error: expression expected, not 'auto'
source\app.d(8): Error: found 'p' when expecting ')'
source\app.d(8): Error: found '=' instead of statement
...

Kind regards
André




Re: with (auto p = new ...)

2014-09-23 Thread andre via Digitalmars-d-learn
Yes, that is also working. As far as I remember (only my tablet 
currently available) also this works:


Panel p;
with(p = new Panel ()) {}

Therefore it seems strange,the same does not work with auto.

Kind regards
André


On Tuesday, 23 September 2014 at 19:49:22 UTC, Graham Fawcett 
wrote:

Sorry, I sent that last message before I intended to.

How about:

 auto b = new Button(); with (b) {
   ...
 }

'b' is explicitly outside of the scope of the 'with' block, 
which may not be what you intended. But you could use more 
braces to add an extra level of scope if that's an issue:


...
text = blah;
{
   auto b = new Button(); with (b) {
   ...
   }
}
// b is no longer in scope

Graham




On Tuesday, 23 September 2014 at 15:19:59 UTC, Andre wrote:

Hi,

I just wonder why with (auto p = new ...) is not working.
It would be some syntax sugar in this scenario:

with (auto p = new Panel())
{
parent = this;
text = bla;
with (auto b = new Button())
{
parent = p; // Here p is needed
text = bla2;
}
}

source\app.d(8): Error: expression expected, not 'auto'
source\app.d(8): Error: found 'p' when expecting ')'
source\app.d(8): Error: found '=' instead of statement
...

Kind regards
André




Re: with (auto p = new ...)

2014-09-23 Thread Meta via Digitalmars-d-learn
I think this is just a language oversight. It's allowed in if 
statements, and people have made a good case for allowing it for 
switch statements. It just hasn't been implemented. I made an 
attempt one evening to implement it for switch statements,  but 
I'm not at all familiar with DMD, so I put it on the back burner 
for the time being.


How to export a deduced template type to the enclosing scope?

2014-09-23 Thread Ali Çehreli via Digitalmars-d-learn

I think similar questions were asked by others in different contexts before.

I played with core.thread.Fibre a little bit. As others have done a 
number of times before, I tried to make the following syntax possible 
inside fiber code:


yield(42);

I wonder whether there is a clever trick to pull out a deduced type from 
a template. I don't think it is possible, because there may be many 
instantiations of the template and it would not be clear which one to 
pull out. (I don't think there is any way of getting all of the 
instantiations of a template because the compiler has only a partial 
view of the program at a time.)


However, what if there is exactly one instantiation allowed?

struct S(alias Func)
{
/* This template mixin will instantiate the yield(T) template. */
mixin Func!();

void yield(T)(T)
{
/* As expected and demonstrated by the following pragma, in
 * this case T happens to be 'double'. Assuming that Func is
 * not allowed to call yield() with more than one type, can we
 * pull the actual type of T out into S's scope? */

alias YieldedT = T;
pragma(msg, YieldedT);/* Prints 'double'. */
}

/* QUESTION: Can we know the type for the single instantiation of
 *   yield(T) here? */

YieldedT data;/* What is YieldedT? */
}

mixin template MyFunc()
{
void foo()
{
double d;
yield(d);/* -- The single instantiation */
}
}

void main()
{
auto s = S!MyFunc();
s.foo();
}

So near and yet so far... :)

Ali



Re: How to export a deduced template type to the enclosing scope?

2014-09-23 Thread Ali Çehreli via Digitalmars-d-learn

On 09/23/2014 03:28 PM, monarch_dodra wrote:

On Tuesday, 23 September 2014 at 22:09:11 UTC, Ali Çehreli wrote:

So near and yet so far... :)

Ali


You explain how you want to achieve your goal, but I'm not sure I
understand what the goal is. Perhaps if you explain that in more
detail, I'd have a better understanding of the problem.

I've never used core.thread.Fibre, so I don't know what yield(42);
would do, so apologies if the question is stupid.


Sorry. You are right. :) I almost deleted all of the specifics to avoid 
any concrete example as I think the question is still valid.


Very briefly, fibers provide faster concurrency by executing both the 
owner and the fiber on the same thread. They are D's coroutines, without 
the much-missed 'yield' keyword. There is some language (runtime?) 
support for fibers though as the 'yield()' and 'call()' calls do involve 
context switching behind the scenes (much faster than thread context 
switching).


I am not experienced with them either but from the examples on the 
core.thread documentation it looks like a fiber cannot yield a value in 
D; it must cause side-effects first, and then yield(), so that the owner 
can observe the side-effect.


Fibers give the convenience of iteration a.la. opCall(), and InputRange 
interface comes naturally. (Example below.)


I played with the idea of enabling the yield(42) syntax from the fiber 
code just because it does not involve side-effects and is more 
intuitive. There are blog posts, thread discussions, and enhancement 
reports about the same.


So, my goal was the above: The client would make a yield(42) call, the 
data would be saved in a local variable automatically (the type of which 
is the question at hand), and then the result would be provided on an 
InputRange interface.


Additionally, although I am not aware of other examples of it, again as 
an experiment, I tried to see whether injecting user code by a template 
mixin would make any sense. Since template mixins are expanded where 
they are mixed-in, then I thought perhaps I could deduce a type from 
inside that code. I failed, you will succeed. :o)


Here is a working example with the minor inconvenience of having to 
specify ResultT from the outside, which seems redundant. The goal is to 
remove the need for that parameter.


Note that I am aware of the inheritance-based kind of fibers and the 
following may not make sense at all. I was just experimenting.


import std.stdio;
import core.thread;
import std.algorithm;

/* This is what the user provides. We will mix this in. */
mixin template Foo()
{
void run()
{
/* Note how naturally the elements are produced in imperative
 * style: */
foreach (i; 0 .. 10) {
yield(i);/* The element type is obviously 'int'. */
}
}
}

/* This is an InputRange that exposes the yielded values as
 * elements. PROBLEM: Admittedly minor, ResultT seems redundant. */

class FiberRange(alias Func, ResultT)
{
mixin Func!(); // User code mixed-in
ResultT result;// The front element
Fiber fiber;   // The fiber that does the work

/* Supports the more natural yield(42) syntax. */
final void yield(T : ResultT)(T result)
{
this.result = result;
Fiber.yield;
}

public:

this()
{
/* He fiber is started by the user's 'run' function. */
this.fiber = new Fiber(run);
this.fiber.call();
}

/* Trivial InputRange interface: */

final
@property
bool empty() const
{
return fiber.state == Fiber.State.TERM;
}

final
@property
ResultT front() const
{
return result;
}

final
void popFront()
{
this.fiber.call;
}
}

/* Convenience function: */
auto fiberRange(alias Func, ResultT)()
{
return new FiberRange!(Func, ResultT);
}

void main()
{
/* Works like a charm! :p */
auto result = fiberRange!(Foo, int)
  .filter!(a = a % 2);

assert(result.equal([1, 3, 5, 7, 9]));
}

Can we get rid of the ResultT template parameter? Tricks with variadic 
templates, the with statement, etc. come to mind but I could not manage it.


Ali



Re: Does remove immutability using cast to pass in a function make sense?

2014-09-23 Thread AsmMan via Digitalmars-d-learn

On Tuesday, 23 September 2014 at 03:34:22 UTC, Ali Çehreli wrote:

If it still doesn't work for you please show us a minimal 
program that demonstrates the problem.


Ali


Ok, the case is the follow, I updated my dmd compiler some days 
ago (after my mono crashed and I lost some of D files, I posted 
on this forum) and I can't reproduce the error anymore. What I 
remember it was about a template error and when I removed the 
immutable keyword it compiled. I tried really, but it doesn't 
give any error anymore and your code compile. :/


Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together

2014-09-23 Thread csmith via Digitalmars-d-learn

Hi everyone,

I've got derelict.opengl3.gl3 and derelict.glfw3.glfw3 setup with 
dub and can get a window to open up and close with glfw3. I can 
also use glClear(GL_COLOR_BUFFER_BIT); however, beyond this most 
OpenGL commands fail and I can't seem to figure out how to fix it.


Code:

import std.stdio;
import derelict.opengl3.gl3, derelict.glfw3.glfw3;

void main(string args[])
{
DerelictGL3.load(); // Loads OpenGL v1.0 and v1.1
DerelictGLFW3.load(); // Loads GLFW3

assert (glfwInit(), Failed to initialize GLFW3);
scope (exit) glfwTerminate();

glfwSetErrorCallback(error_callback);

auto window = glfwCreateWindow(640, 480, Simple 
example, null, null);	

assert (window !is null);

glfwMakeContextCurrent(window);
auto vers = DerelictGL3.reload(); // Created GLFW3 
context, so GL3 needs to be reloaded


while (!glfwWindowShouldClose(window)) {
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
glfwSetWindowShouldClose(window, GL_TRUE);

glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POINTS);
glEnd();

glfwSwapBuffers(window);
glfwPollEvents();
}

glfwDestroyWindow(window);
glfwTerminate();
}

extern (C) void error_callback(int error, const(char)* 
description) nothrow {

printf(%s %s, error, description);
}

Compiler Output:

derelict-util: [derelict-util]
derelict-util: [derelict-util]
derelict-glfw3: [derelict-glfw3, derelict-util]
derelict-util: [derelict-util]
derelict-gl3: [derelict-gl3, derelict-util]
myproj: [myproj, derelict-util, derelict-glfw3, 
derelict-util, derelict-gl3, derelict-util]
Target is up to date. Using existing build in 
/home/csmith/.dub/packages/derelict-util-1.0.2/.dub/build/library-debug-linux.posix-x86_64-dmd-A741715720F146208FFF241F87E468DD/. 
Use --force to force a rebuild.
Target is up to date. Using existing build in 
/home/csmith/.dub/packages/derelict-glfw3-1.0.2/.dub/build/library-debug-linux.posix-x86_64-dmd-DD1819CE8266F370192AAD3190CA5B06/. 
Use --force to force a rebuild.
Target is up to date. Using existing build in 
/home/csmith/.dub/packages/derelict-gl3-1.0.6/.dub/build/library-debug-linux.posix-x86_64-dmd-59B635D839F3A8CFC2737986D4B622FD/. 
Use --force to force a rebuild.

Building myproj configuration application, build type debug.
Compiling...
source/app.d(25): Error: undefined identifier glBegin
source/app.d(26): Error: undefined identifier glEnd
FAIL 
.dub/build/application-debug-linux.posix-x86_64-dmd-357CCD4CB91CACEC384AF7BAA514E3A7 
myproj executable
Error executing command run: DMD compile run failed with exit 
code 1


Any ideas?

Thanks,
Charles


Re: with (auto p = new ...)

2014-09-23 Thread Nordlöw

On Tuesday, 23 September 2014 at 20:16:29 UTC, andre wrote:

Therefore it seems strange,the same does not work with auto.


Yes, it seem logical to me allow this also in with and switch.