Re: Passing a sting as 'in char[]' yields "immutable is not callable using argument types ()"

2016-06-08 Thread chmike via Digitalmars-d-learn
final Tuple!(int,"value",bool,"hasValue") value(const 
string name) { return nameImpl(value); }



Sorry, this is the error. It should have been

   final Tuple!(int,"value",bool,"hasValue") value(const
string name) { return valueImpl(name); }



Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 15:52:06 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 15:40:48 UTC, Ola Fosheim Grøstad 
wrote:

On Wednesday, 8 June 2016 at 15:31:34 UTC, ketmar wrote:
i'm trying to hint that there is no reason to reimplement 
*everything* in D. bad engineers reinvent, good engineers 
reuse!


This is about marketing, not engineering.


nope, it is about engineering. as long as D is not backed by 
some giant like google or apple, it is about engineering.


Huh? No, as long as D is not backed by some giant like Google or 
Apple it has to do its own marketing and showcase its own stuff 
where it can.


People are not looking for something that takes engineering to 
work well. They are looking for something that just-works and 
that they can build on from the get go.




Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 16:23:13 UTC, Ola Fosheim Grøstad 
wrote:

Yes, no point in writing your own forum software.


ah, sure, there was the reason to write DFeed! that's why 
forum.dlang.org is using engine written in D.


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 16:28:54 UTC, dewitt wrote:

On Wednesday, 8 June 2016 at 15:18:27 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:
People check out stuff like that. The forum backend also use 
a standard NNTP server, not implemented in D? That's ok too 
as there is no D forum software...


it's even more than that: D servers are using OS which is not 
implemented in D!


Whats worse is the software running the power stations that 
power the servers that host the website aren't written in D.  
Neither were the software that run the militaries that protect 
the interests of the locations where the servers live.  
Obviously this means that D is useless and should die.


Yes, indeed, if golang was not showcased as a web server language 
then I would not even consider looking at it for the purpose.


They do of course use golang for their blog and make it available 
as a download.


As they _should_.


Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 16:40:37 UTC, Ola Fosheim Grøstad 
wrote:

DFeed is a NNTP client, not a NNTP server.


sure. why should it be an NNTP server? there is task to solve: 
provide web frontend to the existing NNTP server. that task was 
solved. there was no task "waste some time to rewrite already 
working NNTP server software in D in the sake of rewriting".


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 16:53:32 UTC, ketmar wrote:
go write it! nope? why do you think that D devs should? they 
have other work to do, it would be *stupid* to not reuse 
existing tools.


If I thought that D was good for the purpose, I would. I have not 
made such claims. I am pointing out that those who claim that D 
is suitable for a particular field should be expected to 
demonstrate it on their own turf.


It _does_ not take a lot of effort, if it is as good as is being 
claimed.

If it takes a lot of effort, then why should I bother with it?

You need to understand that you are contradicting the claims that 
are being made about D by not actually being willing to showcase 
it.


This is very basic marketing 101.

Not expensive.

Belive in something? Showcase it on your own lawn, house, car, 
website...


Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 14:43:35 UTC, Mike Parker wrote:
Really? I just don't see it as that big of a deal. Again, three 
subdomains are using D right now. So it's not like it's not 
being used at all. Moving the website to D just hasn't been a 
priority (nor should it be, IMO). Anyone in the community who 
*does* feel it's important is certainly free to put together a 
prototype and pitch it to the core team. I would ask their 
thoughts about it first, though, before embarking on such a 
project.


I can definitely see and relate to your points.  You're using 
sound arguments when making decisions about software in general.  
However, I think you have to consider the emotional impact of 
this.  If you walked into a printer company and found out they 
didn't use their own printers, what would that say to you?  Since 
dlang.org is the face of the D programming language, it's going 
to be the first thing people use to judge it.  IMO that makes it 
a big deal.


Re: dlang.org using apache?

2016-06-08 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 14:57:11 UTC, Jonathan Marler wrote:
However, I think you have to consider the emotional impact of 
this.


nodejs.org's homepage is served by nginx. D is general purpose, 
node is specifically web.


Nobody seems to care (probably because using nginx is the 
recommended way to do a production deployment anyway!)


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 14:45:58 UTC, Mike Parker wrote:
What does that have to do with the website? The forum software 
is written in D and has a reputation for performance. This is 
simply a matter of it not popping up on anyone's radar and has 
nothing to do with the GC or performance hits.


Jonathan pointed out that people loose confidence when projects 
don't use their own tech if they have it. If this was just a 
single datapoint it would be a non-issue, but when it is a 
tendency, then it is a marketing issue.


The forum-index http header report:

Server:nginx/1.4.6 (Ubuntu)

People check out stuff like that. The forum backend also use a 
standard NNTP server, not implemented in D? That's ok too as 
there is no D forum software... but having many data-points like 
that is not good if you want to positions yourself as suitable 
for hosting websites.


Just like writing special cased memory management for DMD is not 
good marketing of D's ability to support fast memory management 
out of the box.


It is better to take a performance hit and show statistics of how 
you improve over time. People react more negatively to stagnation 
than absolute numbers.


People do notice. One data-point, ok. Many data-points, bad.



Re: dlang.org using apache?

2016-06-08 Thread dewitt via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 15:18:27 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:
People check out stuff like that. The forum backend also use a 
standard NNTP server, not implemented in D? That's ok too as 
there is no D forum software...


it's even more than that: D servers are using OS which is not 
implemented in D!


Whats worse is the software running the power stations that power 
the servers that host the website aren't written in D.  Neither 
were the software that run the militaries that protect the 
interests of the locations where the servers live.  Obviously 
this means that D is useless and should die.


Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 16:58:31 UTC, Ola Fosheim Grøstad 
wrote:

This is very basic marketing 101.


engineers doesn't do marketing. engineers solving tasks.


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 16:07:26 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 15:57:42 UTC, Ola Fosheim Grøstad 
wrote:
Huh? No, as long as D is not backed by some giant like Google 
or Apple it has to do its own marketing and showcase its own 
stuff where it can.


the key words are "where it can". rewriting already working 
tools (perfectly working) in D is "marketing for the marketing 
sake". if there are money to waste, an engineer can be hired to 
rewrite such tools. otherwise, it is much wiser to reuse 
existing ones.


Yes, no point in writing your own forum software. However, if you 
need nginx to perform on a small scale site like dlang.org then 
you basically say that the D http stack is not yet competitive 
with C++.


Contrast that to:
- Vibe.d is so great that we don't need a front end to perform 
well.


so they should pass-by. D is the language to build tools, not 
some "batteries included" language. this is The Way to market 
it, i believe.


Fair enough, maybe that is more honest, but it doesn't drive the 
project forward to a situation where it can showcase 
"download-compile-install" starting points.


And that is what most people want. Most people want to solve a 
specific problem. If you have something they can make work right 
away and then modify then you are more like to be adopted.




Re: dlang.org using apache?

2016-06-08 Thread Seb via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 13:32:00 UTC, Mike Parker wrote:
On Wednesday, 8 June 2016 at 13:13:07 UTC, Jonathan Marler 
wrote:
I've decided to write a web application using vibe and was 
shocked to see that dlang.org was using apache.


Should I be scared that even after this long, the official D 
website doesn't rely on its own web tools?


No, you shouldn't. Like everything else, it's a matter of 
priorities and resources. Currently, code.dlang.org and 
tour.dlang.org both run on vibe.d, both of which were put 
together by community members. The forums here is Vladimir's 
DFeed, which he developed with his own web tools. There may yet 
come a time when someone converts dlang.org to a vibe.d web 
app, but it almost certainly isn't going to be any of the core 
team members. They have enough on their plate already.


Btw for development dlang.org uses vibed since 2.5 years ;-)

```
make -f posix.mak apidocs-serve
```

It will run ddox on every request.

Hell, if it's ever been brought up in the forums before now, I 
don't remember seeing it. While it would be great in terms of 
dog fooding to see such a project, I personally don't see that 
it's a big deal if dlang.org runs on Apache. Maybe if you've 
got some extra time... :)



I agree - this is bikeshedding. We all rely on existing software 
for our day to day life. I quickly checked the first hit server 
for other languages - have a look:


rust.org: nginx
php.net: nginx
julia.org: Apache
scala-lang.org: Apache
julia-lang.org: Github
python.org: nginx
www.cplusplus.com: Apache
perl.org: Apache
developer.mozilla.org: Apache
ruby-lang.org: nginx
swift.org: Apache

... and the last time I checked all of them use the C 
implementation of git for their source code ;-)


Mike's call for help was about actively _improving_ dlang.org by 
pointing out


- what is (or could be) confusing for newcomers
- bad written texts
- missing examples
- not user-friendly parts of the documentation
- missing info
- ...

Basically everything that could stop someone from having awesome 
first five minutes with D!


Re: How to enable feedback for AssertError?

2016-06-08 Thread your_name via Digitalmars-d-learn

On Tuesday, 7 June 2016 at 04:21:34 UTC, Mike Parker wrote:

On Tuesday, 7 June 2016 at 02:05:00 UTC, Seb wrote:

On Tuesday, 7 June 2016 at 01:40:01 UTC, your_name wrote:


The way I traced the problem, ironically ;), was to catch 
Error and print it to screen.
It involved dereferencing a null pointer in a thread and an 
'assert null this' silently killed the thread leaving me 
wondering why it didn't produce data.
Anyhow, I've had this behavior at least 1 more time but I 
forgot what exactly it was related to.


Maybe I missed something beyond building a normal -debug 
version.


Anyways, thanks for your reply :)


Please open an issue - this sounds like a big then.


Exceptions thrown from spawned threads do not, by default, 
terminate the main thread, so they will not be printed to the 
screen unless it's done explicitly. See this old forum thread 
at [1].


Note this quote from Sean Kelley (the original maintainer of 
DRuntime):


"Oh, I should mention that if you use core.thread explicitly, 
any unhandled exception will be re-thrown in the context of 
whoever joins that thread."



[1] 
http://forum.dlang.org/post/mailman.1153.130030.31962.digitalmars-d-le...@puremagic.com


Hi Mike,

thanks for the pointer.

However, since this is my first program in D using multi 
threading I am very sure that the other issue occured in a single 
threaded program.
This was a while ago and I have since updated dmd/druntime/phobos 
several times so I could not tell if it would still apply.


I try to investigate tomorrow, or day after tomorrow, depending 
on my schedule...


Anyways, thanks everyone for your help so far :)



Re: Passing a sting as 'in char[]' yields "immutable is not callable using argument types ()"

2016-06-08 Thread NX via Digitalmars-d-learn

String is an alias for 'immutable(char)[]'.

I assume you meant const(char)[] instead of 'const string'?

P.S. always use parentheses.


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 15:18:27 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:
People check out stuff like that. The forum backend also use a 
standard NNTP server, not implemented in D? That's ok too as 
there is no D forum software...


it's even more than that: D servers are using OS which is not 
implemented in D!


If D had their own OS then that would have been an issue, yes. 
Just like if Redhat had used Debian on their servers. Oh... you 
were trying to be funny...? ha...


Re: dlang.org using apache?

2016-06-08 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:

On Wednesday, 8 June 2016 at 14:45:58 UTC, Mike Parker wrote:
What does that have to do with the website? The forum software 
is written in D and has a reputation for performance. This is 
simply a matter of it not popping up on anyone's radar and has 
nothing to do with the GC or performance hits.


Jonathan pointed out that people loose confidence when projects 
don't use their own tech if they have it. If this was just a 
single datapoint it would be a non-issue, but when it is a 
tendency, then it is a marketing issue.



I was specifically referencing the bit you chopped out in the 
quote about GC and bad performance. I understood Jonathan's 
argument just fine (though I disagree with it). I didn't 
understand yours.


At any rate, we *are* using our own tech in several places. And I 
think Seb has shown that in practice, it probably isn't that big 
a deal that the entire website isn't served by a D project.


Passing a sting as 'in char[]' yields "immutable is not callable using argument types ()"

2016-06-08 Thread chmike via Digitalmars-d-learn
I have an immutable final class with methods with the following 
signature



import std.typecons;

immutable class Base{
...
@safe pure nothrow
final Tuple!(int,"value",bool,"hasValue") value(const string 
name) { return nameImpl(value); }

@safe pure nothrow
protected abstract Tuple!(int,"value",bool,"hasValue") 
valueImpl(const string name);

...
}

final immutable class Info: Base{
...
@safe pure nothrow
static Tuple!(int,"value",bool,"hasValue") value(const string 
name)

{
auto p = name in name2value_; // <-- Error in this line
return (p) ? Tuple!(int,"value",bool,"hasValue")(*p,true) 
: Tuple!(int,"value",bool,"hasValue")(int.init,false);

}
@safe pure nothrow
protected override Tuple!(int,"value",bool,"hasValue") 
valueImpl(const string name) { return value(name); }

...
enum int[string] name2value_ = [ "info_1" : 1, ...];

}


When trying to compile this I get the following error

 Error: function Info.value (const(string) name) immutable is not 
callable using argument types ()


What is the error ? Why is argument types () ?


Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 15:51:58 UTC, Adam D. Ruppe wrote:
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:

The forum-index http header report:

Server:nginx/1.4.6 (Ubuntu)

People check out stuff like that.


Yeah, and that's an industry-standard production deployment.

But perhaps we should just change the server line for the 
people who do look at it. No need to change the deployment, 
just the apache/nginx config to spit out something different.


I can picture the article now:

The D programming language maintains its own web framework 
called vibe.d, but the official website dlang.org doesn't use 
it.  Instead they use the Apache framework written in C.  They 
also decided to modify Apache to make it look like their own 
vibe.d framework.  Apparently tricking people into thinking 
they use their own code was easier the actually using it.




Re: dlang.org using apache?

2016-06-08 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:

The forum-index http header report:

Server:nginx/1.4.6 (Ubuntu)

People check out stuff like that.


Yeah, and that's an industry-standard production deployment.

But perhaps we should just change the server line for the people 
who do look at it. No need to change the deployment, just the 
apache/nginx config to spit out something different.


Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 15:40:48 UTC, Ola Fosheim Grøstad 
wrote:

On Wednesday, 8 June 2016 at 15:31:34 UTC, ketmar wrote:
i'm trying to hint that there is no reason to reimplement 
*everything* in D. bad engineers reinvent, good engineers 
reuse!


This is about marketing, not engineering.


nope, it is about engineering. as long as D is not backed by some 
giant like google or apple, it is about engineering.


Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 15:57:42 UTC, Ola Fosheim Grøstad 
wrote:
Huh? No, as long as D is not backed by some giant like Google 
or Apple it has to do its own marketing and showcase its own 
stuff where it can.


the key words are "where it can". rewriting already working tools 
(perfectly working) in D is "marketing for the marketing sake". 
if there are money to waste, an engineer can be hired to rewrite 
such tools. otherwise, it is much wiser to reuse existing ones.



People are not looking for something that takes engineering to 
work well. They are looking for something that just-works and 
that they can build on from the get go.


so they should pass-by. D is the language to build tools, not 
some "batteries included" language. this is The Way to market it, 
i believe.


Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 16:38:02 UTC, Ola Fosheim Grøstad 
wrote:
They do of course use golang for their blog and make it 
available as a download.


As they _should_.


google. money. does that rings the bell?


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 16:36:50 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 16:23:13 UTC, Ola Fosheim Grøstad 
wrote:

Yes, no point in writing your own forum software.


ah, sure, there was the reason to write DFeed! that's why 
forum.dlang.org is using engine written in D.


DFeed is a NNTP client, not a NNTP server.

(NNTP is pretty much dead, so not much point in it, true. Was 
that your point? Or are you back into zealot-mode? :^)





Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 16:49:46 UTC, Ola Fosheim Grøstad 
wrote:

On Wednesday, 8 June 2016 at 16:44:00 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 16:38:02 UTC, Ola Fosheim Grøstad 
wrote:
They do of course use golang for their blog and make it 
available as a download.


As they _should_.


google. money. does that rings the bell?


No. The go blog software is very small, <400 lines of code.


go write it! nope? why do you think that D devs should? they have 
other work to do, it would be *stupid* to not reuse existing 
tools.


google. money.


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 16:44:00 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 16:38:02 UTC, Ola Fosheim Grøstad 
wrote:
They do of course use golang for their blog and make it 
available as a download.


As they _should_.


google. money. does that rings the bell?


No. The go blog software is very small, <400 lines of code.

If you use vibe.d for development as it has been said then it 
makes people wonder even more why it isn't deployed.


srsly.

Showcase your own stuff, nobody else are likely to do it.



template with enum arg ?

2016-06-08 Thread chmike via Digitalmars-d-learn


In a first implementation I defined a named enum in my class 
which I could use with my template function foo.



final class Info {
...
enum Value { info_1 = 1, ... }
...
static bar(Value e) {...}
}

void foo(T)(T.Value e) { T.bar(e); }



I could then write : foo(Info.Value.info_1);

I would prefer to write : foo(Info.info_1);

If I change the enum into an anonymous enum the template doesn't 
work anymore.


How could I solve this ?

Also, do I need a template argument filter if() ?



Re: dlang.org using apache?

2016-06-08 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 17:05:42 UTC, Jonathan Marler wrote:

I can picture the article now:


I can't. It is an industry-standard deployment with a commonly 
used configuration option - people change that all the time. PHP, 
for example, will modify it to output something like this:


Server: Apache/2.4.6 (Unix) PHP/5.4.20

when you use it - they append their brand to the existing string.


The only articles I have ever seen about this is people saying 
you should blank it out to make script kiddies have a harder time 
figuring out just which version you have installed - people 
SUGGEST that you obscure it!



BTW, when I see a live server running a custom httpd, I tend to 
have a negative reaction: the sysadmin is lazy and didn't bother 
with a proper setup. There's a reason ALL the other major 
languages and frameworks use Apache/nginx/IIS on their websites. 
It's the recommended way to do it.


There's a difference between an application server and a frontend 
web server.


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 15:04:24 UTC, Adam D. Ruppe wrote:
On Wednesday, 8 June 2016 at 14:57:11 UTC, Jonathan Marler 
wrote:
However, I think you have to consider the emotional impact of 
this.


nodejs.org's homepage is served by nginx. D is general purpose, 
node is specifically web.


Nobody seems to care (probably because using nginx is the 
recommended way to do a production deployment anyway!)


Node.js is widely deployed, they don't need any marketing or 
showcases. Vibe.d and D does.


That is a major difference.



Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:
People check out stuff like that. The forum backend also use a 
standard NNTP server, not implemented in D? That's ok too as 
there is no D forum software...


it's even more than that: D servers are using OS which is not 
implemented in D!


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 15:31:34 UTC, ketmar wrote:
i'm trying to hint that there is no reason to reimplement 
*everything* in D. bad engineers reinvent, good engineers reuse!


This is about marketing, not engineering.

Walter is arguing that vibe.d should be distributed with the 
compiler. If it is good enough to get semi-official status it 
makes you wonder why it isn't showcased on dlang.org?


Same thing with memory management. If memory management in D is 
not a problem, why is it then a problem to use the standard 
memory management in the official D compiler, a non-interactive 
batch-application?


Compare this to:
- We are using our own web framework, out-of-the-box, 
compile-and-run.

- We are using our own standard library/runtime, unmodified.

And it works great!
No need to dig deep to get decent performance!




Re: dlang.org using apache?

2016-06-08 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 14:41:55 UTC, Ola Fosheim Grøstad 
wrote:




But DMD also doesn't use the GC because it doesn't perform well 
enough. Stuff like this adds up.


So I agree with you in essence, sending the message that there 
are things to avoid is not good in the long run. It might be 
better to take a slight performance hit and use your own stuff 
and post a list of things you are working on to improve it.


I like the "are we fast yet" websites that various project put 
up, displaying improvements over time.


What does that have to do with the website? The forum software is 
written in D and has a reputation for performance. This is simply 
a matter of it not popping up on anyone's radar and has nothing 
to do with the GC or performance hits.


Re: dlang.org using apache?

2016-06-08 Thread ketmar via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 15:23:58 UTC, Ola Fosheim Grøstad 
wrote:

On Wednesday, 8 June 2016 at 15:18:27 UTC, ketmar wrote:
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:
People check out stuff like that. The forum backend also use 
a standard NNTP server, not implemented in D? That's ok too 
as there is no D forum software...


it's even more than that: D servers are using OS which is not 
implemented in D!


If D had their own OS then that would have been an issue, yes. 
Just like if Redhat had used Debian on their servers. Oh... you 
were trying to be funny...? ha...


i'm trying to hint that there is no reason to reimplement 
*everything* in D. bad engineers reinvent, good engineers reuse!


Re: dlang.org using apache?

2016-06-08 Thread dewitt via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 17:05:42 UTC, Jonathan Marler wrote:

On Wednesday, 8 June 2016 at 15:51:58 UTC, Adam D. Ruppe wrote:
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:

The forum-index http header report:

Server:nginx/1.4.6 (Ubuntu)

People check out stuff like that.


Yeah, and that's an industry-standard production deployment.

But perhaps we should just change the server line for the 
people who do look at it. No need to change the deployment, 
just the apache/nginx config to spit out something different.


I can picture the article now:

The D programming language maintains its own web framework 
called vibe.d, but the official website dlang.org doesn't use 
it.  Instead they use the Apache framework written in C.  They 
also decided to modify Apache to make it look like their own 
vibe.d framework.  Apparently tricking people into thinking 
they use their own code was easier the actually using it.



A lot of languages have a web framework that sits behind a server 
written in a different language.  .NET powers a ton of sites and 
applications and usually runs on IIS which is written in C++.  
Also if I were to use vibe then I would prolly run it behind a 
reverse proxy like nginx.  This is actually pretty standard way 
of deploying apps like say a Django, Flask, etc Nothing wrong 
with that and that by no means makes Python a useless language 
for the web.  Even Digital Oceans guide for Node and Python apps 
have you setup nginx as a reverse proxy.  Also Plays uguide shows 
how to setup nginx as a proxy.


Re: dlang.org using apache?

2016-06-08 Thread Seb via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 17:59:29 UTC, Ola Fosheim Grøstad 
wrote:

On Wednesday, 8 June 2016 at 17:43:23 UTC, dewitt wrote:

vibes website doesn't use a proxy.


Yes, but more people visit dlang.org, and it makes it more 
official if it is showcased here as a visible part of the 
website (one way or another).


But if D wants to compete in web then there are alot of better 
areas to improve on like ORMs (I know not everyone likes them 
but they have their use cases and users), DB support, etc.  
That will attract more ppl more than some proxy would..


Probably. I don't know.


Pretty sure and I hope std.database is coming soon to Phobos 
(there was quite some buzz at this year's dconf)


http://dconf.org/2016/talks/smith.html
https://github.com/cruisercoder/dstddb

See also Martin Nowak's talk about his idea for ORM in D:

http://dconf.org/2016/talks/nowak.html


I can only tell what I am looking out for:

- good memcache client


https://github.com/TiberiuGal/memcached4d ?


- good nosql interface


what's wrong with vibed's mongodb?

- easy deployment in the cloud (in my case Google, but could be 
any other vendor)


Just compile & upload? Isn't that the great part about having 
just one executable?
For better control, I use systemd, but I do agree that there 
should be more guides & documentation - so go ahead and write 
them!



And optionally:
- fast javascript interpreter/JIT (for precompiling pages)


https://github.com/higgsjs/Higgs?


Re: dlang.org using apache?

2016-06-08 Thread dewitt via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 17:34:25 UTC, Ola Fosheim Grøstad 
wrote:

On Wednesday, 8 June 2016 at 17:17:37 UTC, Adam D. Ruppe wrote:
bother with a proper setup. There's a reason ALL the other 
major languages and frameworks use Apache/nginx/IIS on their 
websites. It's the recommended way to do it.


Sure, you can have vibe.d behind nginx, if you want to, but it 
would be more impressive if you didn't have to. Scripting 
languages do of course have to.


The main point is that it isn't visible at all that vibe.d is 
involved or how it is being used. So you loose out on a 
showcase opportunity.


What other adopted solutions do is not really relevant as they 
already _have_ massive amounts of showcases around the web _or_ 
they are not trying to position themselves in as a web backend 
langauge. D is not a scripting language, if it wants to compete 
with Go in the web arena it has to showcase itself where it can.


AFAIK golang.org uses their own stuff, Go on AppEngine.


There's a difference between an application server and a 
frontend web server.


Well, you should be able to write a proxy in a system level 
language. If you can showcase that it is easy to get comparable 
performance then all the better.


vibes website doesn't use a proxy.  But if D wants to compete in 
web then there are alot of better areas to improve on like ORMs 
(I know not everyone likes them but they have their use cases and 
users), DB support, etc.  That will attract more ppl more than 
some proxy would..  At least as far as people and companies that 
build applications..  I mean D could also be used to build a 
database but why when there are already used alternatives..


Re: dlang.org using apache?

2016-06-08 Thread Seb via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 17:05:42 UTC, Jonathan Marler wrote:

On Wednesday, 8 June 2016 at 15:51:58 UTC, Adam D. Ruppe wrote:
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim Grøstad 
wrote:

The forum-index http header report:

Server:nginx/1.4.6 (Ubuntu)

People check out stuff like that.


Yeah, and that's an industry-standard production deployment.

But perhaps we should just change the server line for the 
people who do look at it. No need to change the deployment, 
just the apache/nginx config to spit out something different.


I can picture the article now:

The D programming language maintains its own web framework 
called vibe.d, but the official website dlang.org doesn't use 
it.  Instead they use the Apache framework written in C.  They 
also decided to modify Apache to make it look like their own 
vibe.d framework.  Apparently tricking people into thinking 
they use their own code was easier the actually using it.


Did you even bother reading my response
Stop wasting your time by trolling - make a difference!

--

I agree - this is bikeshedding. We all rely on existing software 
for our day to day life. I quickly checked the first hit server 
for other languages - have a look:


rust.org: nginx
php.net: nginx
julia.org: Apache
scala-lang.org: Apache
julia-lang.org: Github
python.org: nginx
www.cplusplus.com: Apache
perl.org: Apache
developer.mozilla.org: Apache
ruby-lang.org: nginx
swift.org: Apache

... and the last time I checked all of them use the C 
implementation of git for their source code ;-)


Mike's call for help was about actively _improving_ dlang.org by 
pointing out


- what is (or could be) confusing for newcomers
- bad written texts
- missing examples
- not user-friendly parts of the documentation
- missing info
- ...

Basically everything that could stop someone from having awesome 
first five minutes with D!


Re: dlang.org using apache?

2016-06-08 Thread Seb via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 17:34:25 UTC, Ola Fosheim Grøstad 
wrote:

On Wednesday, 8 June 2016 at 17:17:37 UTC, Adam D. Ruppe wrote:
bother with a proper setup. There's a reason ALL the other 
major languages and frameworks use Apache/nginx/IIS on their 
websites. It's the recommended way to do it.


Sure, you can have vibe.d behind nginx, if you want to, but it 
would be more impressive if you didn't have to. Scripting 
languages do of course have to.


The main point is that it isn't visible at all that vibe.d is 
involved or how it is being used. So you loose out on a 
showcase opportunity.


How is serving static HTML difficult or even impressive?

I agree that a showcase website for vibed (or another D web 
framework) would be beneficial, but a real showcase has totally 
different specs:


- > 1 million visitors per day
- highly dynamic content (high-throughput databases)
- solved technological difficulties (e.g. in-memory caching)
- ...

That being said, we are working on getting a page [1] of 
organizations using D ready, so that we can link to _real_ 
showcases ;-)


[1] http://dlang.org/orgs-using-d.html


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 18:15:22 UTC, Seb wrote:

- good nosql interface


what's wrong with vibed's mongodb?


Probably nothing for those who use it. I only use:

https://cloud.google.com/datastore/
https://cloud.google.com/storage/
https://cloud.google.com/sql/

Amazon and Microsoft have similar solutions.


Just compile & upload? Isn't that the great part about having 
just one executable?


Yes... if it only was that easy. Anyway, if you succeed in 
attracting enough web developers then at some point it makes 
sense for consultants to maintain a cloud API layer. Until then 
it is really an uphill battle, but you can aim for niches (like 
game servers, text search engines etc).



https://github.com/higgsjs/Higgs?


Doesn't look production ready at this point in time? Not a big 
deal, you can use a different server with V8 on it.





Re: dlang.org using apache?

2016-06-08 Thread Brad Anderson via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 14:41:55 UTC, Ola Fosheim Grøstad 
wrote:

[snip]

I like the "are we fast yet" websites that various project put 
up, displaying improvements over time.


You mean like this? http://digger.k3.1azy.net/trend/


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 16:58:42 UTC, Mike Parker wrote:
At any rate, we *are* using our own tech in several places. And 
I think Seb has shown that in practice, it probably isn't that 
big a deal that the entire website isn't served by a D project.


If you want to convince me, as a backend web developer, that you 
have something worth looking at you have to showcase the result 
and also provide the source code for it. Ideally I should be able 
to download the source from github and get something similar 
running with little effort. If I have to write lots of code for 
things that are basic, then it isn't interesting to me.


Same thing for the compiler. I look at it in order to find out 
how D can be used in a larger project. If I find that you bypass 
the runtime in order to perform and revert to manual raw-pointer 
memory management, then it isn't interesting to me.


Same thing with standard library. I look at it to see how real 
world programming in D (by language experts) turns out.


The only reason I am starting to adopt Go for backend is that 
they showcase that the things I want to do can done with concise 
source code. Without such real world showcases I would most 
likely not even consider it.




Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 17:25:32 UTC, Brad Anderson wrote:
On Wednesday, 8 June 2016 at 14:41:55 UTC, Ola Fosheim Grøstad 
wrote:

[snip]

I like the "are we fast yet" websites that various project put 
up, displaying improvements over time.


You mean like this? http://digger.k3.1azy.net/trend/


Yes, but running DMD with/without GC, compiling itself.

Such graphs are very good for showing end-users that you have 
steady progress (as changes in absolute values are difficult to 
experience over 12 months)




Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 17:43:23 UTC, dewitt wrote:

vibes website doesn't use a proxy.


Yes, but more people visit dlang.org, and it makes it more 
official if it is showcased here as a visible part of the website 
(one way or another).


But if D wants to compete in web then there are alot of better 
areas to improve on like ORMs (I know not everyone likes them 
but they have their use cases and users), DB support, etc.  
That will attract more ppl more than some proxy would..


Probably. I don't know.

I can only tell what I am looking out for:

- good memcache client
- good nosql interface
- easy deployment in the cloud (in my case Google, but could be 
any other vendor)


And optionally:
- fast javascript interpreter/JIT (for precompiling pages)


I mean D could also be used to build a database but why when 
there are already used alternatives..


A database is no point as people won't use it unless it is proven 
rock solid (wait and see for a decade). Interfacing with 
infrastructure is more important.


Working well without a proxy/frontend is useful, when you start 
thinking about things like websockets etc.




Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 17:17:37 UTC, Adam D. Ruppe wrote:
bother with a proper setup. There's a reason ALL the other 
major languages and frameworks use Apache/nginx/IIS on their 
websites. It's the recommended way to do it.


Sure, you can have vibe.d behind nginx, if you want to, but it 
would be more impressive if you didn't have to. Scripting 
languages do of course have to.


The main point is that it isn't visible at all that vibe.d is 
involved or how it is being used. So you loose out on a showcase 
opportunity.


What other adopted solutions do is not really relevant as they 
already _have_ massive amounts of showcases around the web _or_ 
they are not trying to position themselves in as a web backend 
langauge. D is not a scripting language, if it wants to compete 
with Go in the web arena it has to showcase itself where it can.


AFAIK golang.org uses their own stuff, Go on AppEngine.


There's a difference between an application server and a 
frontend web server.


Well, you should be able to write a proxy in a system level 
language. If you can showcase that it is easy to get comparable 
performance then all the better.




Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 17:43:03 UTC, Seb wrote:
On Wednesday, 8 June 2016 at 17:05:42 UTC, Jonathan Marler 
wrote:

On Wednesday, 8 June 2016 at 15:51:58 UTC, Adam D. Ruppe wrote:
On Wednesday, 8 June 2016 at 15:05:54 UTC, Ola Fosheim 
Grøstad wrote:

The forum-index http header report:

Server:nginx/1.4.6 (Ubuntu)

People check out stuff like that.


Yeah, and that's an industry-standard production deployment.

But perhaps we should just change the server line for the 
people who do look at it. No need to change the deployment, 
just the apache/nginx config to spit out something different.


I can picture the article now:

The D programming language maintains its own web framework 
called vibe.d, but the official website dlang.org doesn't use 
it.  Instead they use the Apache framework written in C.  
They also decided to modify Apache to make it look like their 
own vibe.d framework.  Apparently tricking people into 
thinking they use their own code was easier the actually 
using it.


Mike's call for help was about actively _improving_ dlang.org 
by pointing out


- what is (or could be) confusing for newcomers
- bad written texts
- missing examples
- not user-friendly parts of the documentation
- missing info
- ...

Basically everything that could stop someone from having 
awesome first five minutes with D!


Great points to make dlang.org more welcoming.  Where it is now 
is much further ahead then years past.


I read your post but I don't think we in any disagreement.  I 
think everyone can agree that it would look better to others if 
dlang.org used it's own web framework.  Whether or not it makes 
sense to actually implement it is another question.  Since I'm 
not intimately familiar with the internals of dlang.org, or the 
consequences of switching, I don't assert that either way would 
be better.  I am, however, pointing out that there are going to 
be poeple trying to share the D language in a negative light, and 
dlang.org not using vibe is exactly the kind of thing these 
people will feed off of and possibly use to turn off others from 
the language.


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 17:50:11 UTC, Seb wrote:
I agree that a showcase website for vibed (or another D web 
framework) would be beneficial, but a real showcase has totally 
different specs:


- > 1 million visitors per day
- highly dynamic content (high-throughput databases)
- solved technological difficulties (e.g. in-memory caching)


As a backend developer I don't really care about those, scaling 
is done by a separate infrastructure and memcache has to be 
shared (but a good memcache client is necessary, true). I care 
about:


- my own productivity
- how easy it is to locate failures on a running instance
- interfacing with infrastructure (also logging over network)
- spin up time
- number of concurrent requests on a single instance / memory 
usage

- full separation between requests
- robustness / uptime (and how close to out-of-memory situations 
are handled)

- http2 support
- websockets
...



Re: template with enum arg ?

2016-06-08 Thread Ali Çehreli via Digitalmars-d-learn

On 06/08/2016 10:02 AM, chmike wrote:


In a first implementation I defined a named enum in my class which I
could use with my template function foo.


final class Info {
...
enum Value { info_1 = 1, ... }
...
static bar(Value e) {...}
}

void foo(T)(T.Value e) { T.bar(e); }



I could then write : foo(Info.Value.info_1);

I would prefer to write : foo(Info.info_1);

If I change the enum into an anonymous enum the template doesn't work
anymore.

How could I solve this ?

Also, do I need a template argument filter if() ?


One way is to bring the enum values to the class scope:

alias info_1 = Value.info_1;

Which can be automated with a mixin:

string expandEnumMembers(E)() {
string result;

foreach (m; __traits(allMembers, E)) {
import std.string : format;
result ~= format("alias %s = %s.%s;", m, E.stringof, m);
}

return result;
}

final class Info {
enum Value { info_1 = 1, info_2 }

mixin (expandEnumMembers!Value());

static bar(Value e) {}
}

void foo(T)(T.Value e) {
T.bar(e);
}

void main() {
foo(Info.info_1);
foo(Info.info_2);
}

To see at compile time what is being mixed in, insert the following 
somewhere in your code:


pragma(msg, expandEnumMembers!(Info.Value));

Ali



Re: Asio Bindings?

2016-06-08 Thread Andrej Mitrovic via Digitalmars-d-learn
I do have (Steinberg) ASIO binding in D.

The problem is I couldn't release the bindings. I've asked Steinberg
if it was OK to release D bindings and they were strongly against it
unfortunately (and this was over 3 years ago..).

Any kind of direct use of ASIO requires their approval first.. meaning
you had to register on their website.

I would recommend using third party libs that abstract the underlying
engine, like PortAudio  or RtAudio (the later of which I'm going to
release a port of soon!).

I had a binding to PortAudio but the devs of that library insisted on
only supporting interleaved audio, RtAudio supports both interleaved
and non-interleaved audio, and the library is easy to port.



On 6/2/16, Pie? via Digitalmars-d-learn
 wrote:
> On Thursday, 2 June 2016 at 11:15:59 UTC, Guillaume Piolat wrote:
>> On Thursday, 2 June 2016 at 06:28:51 UTC, Pie? wrote:
>>> On Thursday, 2 June 2016 at 04:52:50 UTC, Mithun Hunsur wrote:
 On Thursday, 2 June 2016 at 04:02:36 UTC, Pie? wrote:
> Does anyone know if there is any Asio bindings or direct D
> available that allows for IO?

 Check out vibe.d: https://vibed.org/ - it includes a fairly
 complete implementation of asynchronous I/O, among other
 things.
>>>
>>> Oh, lol, I should have mentioned I meant for audio! ;)
>>
>> It doesn't seem to exist but using bindings for FMOD you should
>> be able to access ASIO as an audio driver.
>
> If FMOD is that commercial sound lib then I'm not interested. I
> guess I'll have to try and write some type of asio lib when I get
> around to it. Hopefully it is not too difficult.
>


dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
I've decided to write a web application using vibe and was 
shocked to see that dlang.org was using apache.


Should I be scared that even after this long, the official D 
website doesn't rely on its own web tools?


Re: dlang.org using apache?

2016-06-08 Thread Mike Parker via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 13:13:07 UTC, Jonathan Marler wrote:
I've decided to write a web application using vibe and was 
shocked to see that dlang.org was using apache.


Should I be scared that even after this long, the official D 
website doesn't rely on its own web tools?


No, you shouldn't. Like everything else, it's a matter of 
priorities and resources. Currently, code.dlang.org and 
tour.dlang.org both run on vibe.d, both of which were put 
together by community members. The forums here is Vladimir's 
DFeed, which he developed with his own web tools. There may yet 
come a time when someone converts dlang.org to a vibe.d web app, 
but it almost certainly isn't going to be any of the core team 
members. They have enough on their plate already.


Hell, if it's ever been brought up in the forums before now, I 
don't remember seeing it. While it would be great in terms of dog 
fooding to see such a project, I personally don't see that it's a 
big deal if dlang.org runs on Apache. Maybe if you've got some 
extra time... :)


Re: dlang.org using apache?

2016-06-08 Thread rikki cattermole via Digitalmars-d-learn

On 09/06/2016 1:13 AM, Jonathan Marler wrote:

I've decided to write a web application using vibe and was shocked to
see that dlang.org was using apache.

Should I be scared that even after this long, the official D website
doesn't rely on its own web tools?


Why would we change over when Apache is working quite happily to serve 
up static content?


Re: Recommended coding convention for combining unix and windows code ?

2016-06-08 Thread Olivier Pisano via Digitalmars-d-learn

Hi,

I personally separate OS-specific implementations in modules with 
the same name, in different directories. From the filesystem 
perspective:


widget.d
linux/widgetimpl.d
windows/widgetimpl.d

From the code perspective, the *impl modules would present 
homonymic types with the same public interface.


module widget;

class Widget
{
version(Windows)
{
import windows.widgetimpl;
}
version(linux)
{
import linux.widgetimpl;
}

void systemSpecificTask()
{
auto s = SystemSpecificStruct(); // defined in every 
widgetimpl.d

s.execute();
}
}


Best way to convert Apachelog Datetime 01/Jan/2016:02:25:10 -> 2016-01-01 02:25:10 MySQL-Datetime Format

2016-06-08 Thread Martin Tschierschke via Digitalmars-d-learn

I know there are easy ways to handle this,
anyone with a code snippet for me?

I would use two regex first to make 01,02,03... from Jan,Feb,.. 
and

second to split the result.

best regards mt.


Re: Best way to convert Apachelog Datetime 01/Jan/2016:02:25:10 -> 2016-01-01 02:25:10 MySQL-Datetime Format

2016-06-08 Thread Martin Tschierschke via Digitalmars-d-learn
On Wednesday, 8 June 2016 at 10:42:19 UTC, Martin Tschierschke 
wrote:

I know there are easy ways to handle this,
anyone with a code snippet for me?

I found this solution, letting the MySQL engine do the work:

  SELECT STR_TO_DATE('26/Apr/2011:13:21:58', '%d/%b/%Y:%H:%i:%S');

https://www.experts-exchange.com/questions/26992776/convert-apache-log-date-time-to-mysql.html

Maybe  there is an other short solution using the std.datetime 
and or

https://code.dlang.org/packages/dateparser ?


Re: Fibers under the hood

2016-06-08 Thread Nikolay via Digitalmars-d-learn

On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote:
I've googled and searched through the forums but haven't found 
too much on how fibers are implemented.  How does yield return 
execution to the caller but then resume execution in the same 
place on the next call?  Also some information on how the fiber 
call stack works would be nice.  I'm assuming it allocates the 
stack on the GC heap.  If so, what is the default size and is 
that configurable?  Any information or pointers to resources 
that provide this information would be helpful.  Thanks.


See "Documentation of Fiber internals" inside
https://github.com/dlang/druntime/blob/master/src/core/thread.d


Re: Fibers under the hood

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn

On Thursday, 9 June 2016 at 05:07:33 UTC, Nikolay wrote:

On Thursday, 9 June 2016 at 04:57:30 UTC, Jonathan Marler wrote:
I've googled and searched through the forums but haven't found 
too much on how fibers are implemented.  How does yield return 
execution to the caller but then resume execution in the same 
place on the next call?  Also some information on how the 
fiber call stack works would be nice.  I'm assuming it 
allocates the stack on the GC heap.  If so, what is the 
default size and is that configurable?  Any information or 
pointers to resources that provide this information would be 
helpful.  Thanks.


See "Documentation of Fiber internals" inside
https://github.com/dlang/druntime/blob/master/src/core/thread.d


Exactly what I was looking for, thanks.  Would be nice if this 
documentation was published on the website somewhere (probably in 
the Fiber library documentation).


Re: a lambda with arguments has type void?

2016-06-08 Thread cy via Digitalmars-d-learn

On Tuesday, 7 June 2016 at 22:17:03 UTC, ag0aep6g wrote:
You don't specify the types of the parameters of the function 
literals, so you effectively have templates there. As such the 
literals have no types, and can't be passed as arguments.


Yeah, I see that now. The compiler does have all the necessary 
information to infer the argument types in both templates, 
though. There's no reason that it /couldn't/ infer the type of 
the argument. Like this is why it doesn't really make sense:


import std.stdio;

auto foo(Callable)(Callable c) {
  return c(42);
}

auto foo2(alias c)() {
  return c(42);
}

void main() {
  // this works, when you know it's an int delegate(int) 
beforehand...

  writeln(foo!(int delegate(int))((arg) => arg + 1));
  // and this can infer that your argument is an int delegate(int)
  writeln(foo2!((arg) => arg + 1));
  // so why doesn't this work, if the compiler can infer that the
  // argument is an int delegate(int)?
  static assert(!__traits(compiles,
 writeln(foo((arg) => arg + 1;
}

My guess the reason this doesn't work is: nobody worked on it yet.


You can:
* make it `int bar` in the literals, or


Sure, but it's a bit of a pain to have to export SomeArgumentType 
just so my callbacks can go ((SomeArgumentType rows) => ...). I 
don't like anything that makes you have to go through even more 
trouble to specify your imported symbols explicitly.


* explicitly take a `void delegate(int)` or `void 
function(int)` in foo2,


The problem with that is you don't always know if it's going to 
be a void delegate(int) or a void function(int). You can use 
"toDelegate" to force the issue, but that's more boilerplate 
required for the caller, and really that's the purpose of 
templates, to adjust your code to fit whether a function pointer 
or a delegate pointer or whatever is being passed.


Or you could overload the function, copying and pasting all the 
code, one for "void delegate(int)" and one for "void 
function(int)". Which is exactly what templates are SUPPOSED to 
prevent, but in this case they just... don't.



* take the callback as a "template alias parameter":


Sure, that works great, except when the source is a member 
function. Then it doesn't work at all. But since D has the trick, 
where you can take a non-member-function and make it act like 
one, it's workable.


Like this is the problem:

import std.stdio;

version(logical) {
  struct foo {
int arg;
void bar(alias c)() {
  c("foobar",arg);
}
  }
} else {

  struct foo {
int arg;
  }

  void bar(alias c, foo)(ref foo f) {
c("foobar",f.arg);
  }

  void bar(alias c, foo)(foo* f) {
return bar!(c,foo)(*f);
  }
}

void main() {
  import std.stdio;
  foo f = foo(42);

  f.bar!((message,arg) => writeln(message,arg));
}

Not to mention if "foo/bar" is defined in a support module, you 
now have to separately import "bar" to get "struct foo" to work 
right, since it won't import along with "foo", which makes it 
more difficult to use explicitly named imports, and I try never 
to do that. Anything that makes it more difficult to explicitly 
name imports encourages people to write BAD CODE THAT NOBODY CAN 
READ BECAUSE WHERE DID THAT SYMBOL COME FROM RGH


ahem

It's probably the lesser of three evils, using 
non-member-function templates, to take a template as a callback. 
I can definitely see a use for being able to specialize templates 
using inferred types, rather than ones explicitly passed to the 
!() list.


Re: a lambda with arguments has type void?

2016-06-08 Thread ketmar via Digitalmars-d-learn

On Thursday, 9 June 2016 at 05:20:46 UTC, cy wrote:

On Tuesday, 7 June 2016 at 22:17:03 UTC, ag0aep6g wrote:
You don't specify the types of the parameters of the function 
literals, so you effectively have templates there. As such the 
literals have no types, and can't be passed as arguments.


Yeah, I see that now. The compiler does have all the necessary 
information to infer the argument types in both templates, 
though. There's no reason that it /couldn't/ infer the type of 
the argument.


yes, you can find alot of situations where it is theoretically 
possible to infer types (sometimes by doing several passes to 
"refine" the info), but dmd currently doesn't do that. partially 
because it's a good amount of work, partially because it will 
slow down the compiler considerably in some cases.


Re: Asio Bindings?

2016-06-08 Thread Joerg Joergonson via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 23:19:13 UTC, Andrej Mitrovic wrote:

I do have (Steinberg) ASIO binding in D.

The problem is I couldn't release the bindings. I've asked 
Steinberg if it was OK to release D bindings and they were 
strongly against it unfortunately (and this was over 3 years 
ago..).


Any kind of direct use of ASIO requires their approval first.. 
meaning you had to register on their website.


I would recommend using third party libs that abstract the 
underlying engine, like PortAudio  or RtAudio (the later of 
which I'm going to release a port of soon!).


I had a binding to PortAudio but the devs of that library 
insisted on only supporting interleaved audio, RtAudio supports 
both interleaved and non-interleaved audio, and the library is 
easy to port.




Why would bindings have any issues with licensing? People release 
VST source code all the time. Sure they will be against it 
because they are muddlefudgers! They can't officially endorse it 
without having to dealing with the user end to some degree and 
Steinberg is known for that kind of behavior(just look at all the 
hoops one has to jump through to get asio in the first place).


Of course, I can't convince you but and I'll probably have to 
re-create your work, but hosting something like that on git 
shouldn't cause any problems. At most, SB will send you a cease 
and desist type of letter. In which case you take it down. Think 
of mono, it essentially duplicated .net and MS hasn't done a 
thing about it(they can't do much but flex their big muscles, in 
which case they didn't).


I would appreciate it though if you thought about it again, it 
would save me a bunch of work!


If the problem is that you have included SB source code, then 
that can easily be remedied by removing and and placing an 
abstraction in it's place where others can plug in the source 
when they d/l it from SB.


I haven't got into writing any audio stuff yet but when I look in 
to it more I'll check out the options. I don't need anything 
overly complex but do need low latency IO.






Fibers under the hood

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn
I've googled and searched through the forums but haven't found 
too much on how fibers are implemented.  How does yield return 
execution to the caller but then resume execution in the same 
place on the next call?  Also some information on how the fiber 
call stack works would be nice.  I'm assuming it allocates the 
stack on the GC heap.  If so, what is the default size and is 
that configurable?  Any information or pointers to resources that 
provide this information would be helpful.  Thanks.


Re: dlang.org using apache?

2016-06-08 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 13:13:07 UTC, Jonathan Marler wrote:
I've decided to write a web application using vibe and was 
shocked to see that dlang.org was using apache.


It is very common for real world web apps to run behind Apache, 
nginx, IIS, or another major production server.


These servers tend to be very efficient at front end tasks like 
load balancing, static file serving and cache management, 
standards compliance (including automatically up/down grading 
HTTP versions or TLS requirements), management, security 
(including handling horribly malformed requests) - stuff that can 
take megabytes of code to get right and is typically outside the 
scope of an application server.


Of course, they can also serve up different parts of a large 
website to different application servers transparently to the end 
user - e.g. one part in PHP, another part proxied to vibe.



BTW ironically, a lot of people complain that D DOES use its own 
web technology on the website: it is mostly statically generated 
ddoc!


Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 13:32:00 UTC, Mike Parker wrote:
Why would we change over when Apache is working quite happily 
to serve up static content?


I've heard that same argument as the reason people don't use the 
D language.  Why would I change over to D when C/C++ is working 
quite happily?


If the official D website doesn't feel like migrating it's own 
infrastructure to use D, why would anyone else?  Of course apache 
works (so does C++), but choosing not to put in the time to 
switch says a lot to the rest of the world.




Re: dlang.org using apache?

2016-06-08 Thread Jonathan Marler via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 14:30:53 UTC, Adam D. Ruppe wrote:
These servers tend to be very efficient at front end tasks like 
load balancing, static file serving and cache management, 
standards compliance (including automatically up/down grading 
HTTP versions or TLS requirements), management, security 
(including handling horribly malformed requests) - stuff that 
can take megabytes of code to get right and is typically 
outside the scope of an application server.


That's actually the reason I would think dlang.org should use 
vibe.  Those features are critical to the success and viability 
of vibe.  By making dlang.org dependent on vibe, those features 
are much more likely to be flushed out and maintained at a high 
standard.




BTW ironically, a lot of people complain that D DOES use its 
own web technology on the website: it is mostly statically 
generated ddoc!


I saw some discussion on that in the forums when I was searching 
for info on why dlang.org doesn't use vibe.  I personally like 
that dlang uses ddoc, but I don't know too much about the 
realistic pros and cons.  I do like the concept though.




Re: dlang.org using apache?

2016-06-08 Thread Steven Schveighoffer via Digitalmars-d-learn

On 6/8/16 10:33 AM, Jonathan Marler wrote:

On Wednesday, 8 June 2016 at 13:32:00 UTC, Mike Parker wrote:

Why would we change over when Apache is working quite happily to serve
up static content?


I've heard that same argument as the reason people don't use the D
language.  Why would I change over to D when C/C++ is working quite
happily?

If the official D website doesn't feel like migrating it's own
infrastructure to use D, why would anyone else?  Of course apache works
(so does C++), but choosing not to put in the time to switch says a lot
to the rest of the world.



The concern trolling on this forum has been escalating lately. It's good 
that people are noticing D more!


-Steve


Re: dlang.org using apache?

2016-06-08 Thread Mike Parker via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 14:33:50 UTC, Jonathan Marler wrote:

On Wednesday, 8 June 2016 at 13:32:00 UTC, Mike Parker wrote:
Why would we change over when Apache is working quite happily 
to serve up static content?


I didn't say that. Rikki did :)


If the official D website doesn't feel like migrating it's own 
infrastructure to use D, why would anyone else?  Of course 
apache works (so does C++), but choosing not to put in the time 
to switch says a lot to the rest of the world.


Really? I just don't see it as that big of a deal. Again, three 
subdomains are using D right now. So it's not like it's not being 
used at all. Moving the website to D just hasn't been a priority 
(nor should it be, IMO). Anyone in the community who *does* feel 
it's important is certainly free to put together a prototype and 
pitch it to the core team. I would ask their thoughts about it 
first, though, before embarking on such a project.


Re: dlang.org using apache?

2016-06-08 Thread Ola Fosheim Grøstad via Digitalmars-d-learn

On Wednesday, 8 June 2016 at 14:33:50 UTC, Jonathan Marler wrote:

On Wednesday, 8 June 2016 at 13:32:00 UTC, Mike Parker wrote:
Why would we change over when Apache is working quite happily 
to serve up static content?


I've heard that same argument as the reason people don't use 
the D language.  Why would I change over to D when C/C++ is 
working quite happily?


If the official D website doesn't feel like migrating it's own 
infrastructure to use D, why would anyone else?  Of course 
apache works (so does C++), but choosing not to put in the time 
to switch says a lot to the rest of the world.


Well, if this is the only area where it happens then it's ok.

But DMD also doesn't use the GC because it doesn't perform well 
enough. Stuff like this adds up.


So I agree with you in essence, sending the message that there 
are things to avoid is not good in the long run. It might be 
better to take a slight performance hit and use your own stuff 
and post a list of things you are working on to improve it.


I like the "are we fast yet" websites that various project put 
up, displaying improvements over time.