Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Martin Nowak via Digitalmars-d

On 01/10/2015 01:36 PM, Martin Nowak wrote:


The idea isn't bad, but the performance will suck. This is generally
known as N+1 query, only that this is even worse, as each field is
queried individually.

Here is a sketch for an optimal solution. I'm actually eagerly waiting
that someone finally implements it.

http://dpaste.dzfl.pl/cd375ac594cf


I also added a where clause, with a very simple expression template capture.

http://dpaste.dzfl.pl/cd375ac594cf#line-140



Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Jacob Carlborg via Digitalmars-d

On 2015-01-10 07:46, DaveG wrote:

Let me preface this by saying I only have a general conceptual
understanding of compilers and know nothing about actual implementation.

One common problem with Object-Relational Mapping (ORM) is what data to
load and when. There is basically 2 options:
1. Load everything: This certainly works, but is very inefficient,
particularly when you have a large number of fields or, even worse, have
a derived field that causes a join on one or more tables. If you need
all the data this is fine, but most of the time only a small subset is
actually used. (lazy loading can mitigate some issues, but introduces
other problems)
2. Specify what fields to populate: This can work, but makes more work
for the user, adds complexity to user code, and often introduces bugs
particularly over time as code changes. Implementation details are
leaking into the interface.

Basically, I'm looking for a way to look ahead to see what properties
on an object are actually referenced (or not referenced) so we know what
data needs to be loaded. Simple analysis for things like unused scope
variables already exist, but this is needed for properties on each
instance of a class (or struct). I guess this would require the compiler
to make 2 passes once to trace each object and a second to do something
with the data collected. This would potential cost a lot in compilation
time so there would probably need to be some sort of annotation on the
definition to indicate this type of check is necessary.

I might be crazy, but it seems like the compiler has all the information
necessary to figure this out and it would make user code simpler, less
error prone, and more efficient. So does anybody have any idea on how to
actually achieve this?


I'm not exactly sure if this is what you want but you can implement the 
opDispatch [1] method in a class or struct. This method will be called 
if no other method exists with the same name. There's also something 
called alias this [2] that allows you to do something similar.


class Foo
{
void foo () {}
void opDispatch (string name)() {}
}

auto f = new Foo;
f.foo(); // will call foo
f.bar(); // will be lowered to f.opDispatch!(bar)();

If you're implementing an ORM I would recommend executing queries 
lazily. You can do something like this:


class Person : ORM.Base
{
String name;
Int age;

// this method returns a range/proxy that implements the range api [3]
static ORM.Range!(Person) all () {}
}

String would look something like this:

struct String
{
alias get this;

// this method will fetch the data from the database
private string get ();
}

Using the interface would look something like this:

auto p = Person.all(); // no database query has been performed yet

// the range interface makes it possible to use a foreach
// when starting the foreach loop is when the first query will happen
foreach (e ; p)
{
// this call will trigger a call to the get method in String
// via the alias this
string name = e.name;
writeln(name);
}

[1] http://dlang.org/operatoroverloading.html#dispatch
[2] http://dlang.org/class.html#alias-this
[3] http://dlang.org/phobos/std_range.html#isInputRange

--
/Jacob Carlborg


Re: For those ready to take the challenge

2015-01-10 Thread via Digitalmars-d-learn

On Friday, 9 January 2015 at 17:18:43 UTC, Adam D. Ruppe wrote:
Huh, looking at the answers on the website, they're mostly 
using regular expressions. Weaksauce. And wrong - they don't 
find ALL the links, they find the absolute HTTP urls!


Yeah... Surprising, since languages like python includes a HTML 
parser in the standard library.


Besides, if you want all resource links you have to do a lot 
better, since the following attributes can contain resource 
addresses: href, src, data, cite, xlink:href…


You also need to do entity expansion since the links can contain 
html entities like amp;.


Depressing.


Re: Game development

2015-01-10 Thread ketmar via Digitalmars-d
On Sat, 10 Jan 2015 15:17:17 +
dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:

 On Friday, 9 January 2015 at 06:17:28 UTC, ketmar via
 Digitalmars-d wrote:
  On Thu, 08 Jan 2015 22:27:53 +0100
  Joseph Rushton Wakeling via Digitalmars-d
 
  if he is intelligent enough, he will understand that nobody can 
  talk
  for the whole community, so in the worst case he will ignore 
  myself
  personally. if he is not intelligent enough... oh, well, as 
  nobody else
  wants to be a judge, i will be one. i don't feel wrong calling 
  someone
  timewaster if he *is* one. and i can smell 'em from a 
  distance.
 
 Ketmar the teenage albino freak wasting time replying to time
 wasters.
i'm proud of having my own fanclub.


signature.asc
Description: PGP signature


Re: 4x4

2015-01-10 Thread Iain Buclaw via Digitalmars-d
On 8 January 2015 at 21:16, Andrei Alexandrescu via Digitalmars-d
digitalmars-d@puremagic.com wrote:
 On 1/8/15 11:48 AM, Johannes Pfau wrote:

 Am Thu, 08 Jan 2015 10:50:10 -0800
 schrieb Andrei Alexandrescu seewebsiteforem...@erdani.org:

 On 1/8/15 9:16 AM, Kiith-Sa wrote:


 This is a problem with naming, not with DDox. It would look bad
 regardless of generator, or regardless of documentation at all. You
 could make it look slightly less bad, but you might end up hurting
 other documentation. (I'm not implying  it should be renamed (bad
 reason for breaking compatibility), but I see no point in changing
 doc generation just because of some bad naming.)


 Sigh. No matter how I look at it, the same name repeated FOUR times
 only evokes Java's factory factory etc. -- Andrei


 These 4x digest variants never occur in real code though:

 http://dlang.org/library/std/digest/digest/digest.digest.html is a
 class member function. You never use the full name,
 it's always instance.digest()

 http://dlang.org/library/std/digest/digest/digest.html could be used
 with the full name. But ironically the name is not used outside of
 std.digest so it's usually not necessary to use the full name.

 So it doesn't look nice in the docs but it's not a huge problem when
 writing code.


 This is a matter common with words that are both noun and verb. Let's have
 a Digest object that digests stuff. I think the review should have prompted
 a name change. -- Andrei




Something that I noticed, having blue as the class=prettyprint
lang-d colour was not a good idea for all things (see the copyright
information at the bottom).

http://dlang.org/library/std/math/tan.html


Re: For those ready to take the challenge

2015-01-10 Thread Tobias Pankrath via Digitalmars-d-learn

On Saturday, 10 January 2015 at 15:13:27 UTC, Adam D. Ruppe wrote:
On Saturday, 10 January 2015 at 12:34:42 UTC, Tobias Pankrath 
wrote:
Since it is a comparison of languages it's okay to match the 
original behaviour.


I don't think this is really a great comparison of languages 
either though because it is gluing together a couple library 
tasks. Only a few bits about the actual language are showing 
through.



In the given regex solutions, C++ has an advantage over C 
wherein the regex structure can be freed automatically in a 
destructor and a raw string literal in here, but that's about 
all from the language itself. The original one is kinda long 
because he didn't use a http get library, not because the 
language couldn't do one.


There are bits where the language can make those libraries 
nicer too: dom.d uses operator overloading and opDispatch to 
support things like .attribute and also .attr.X and .style.foo 
and element[selector].addClass(foo) and so on implemented 
in very very little code - I didn't have to manually list 
methods for the collection or properties for the attributes - 
...but a library *could* do it that way and get similar results 
for the end user; the given posts wouldn't show that.


I agree and one of the answers says:

I think the no third-party assumption is a fallacy. And is a 
specific fallacy that afflicts C++ developers, since it's so 
hard to make reusable code in C++. When you are developing 
anything at all, even if it's a small script, you will always 
make use of whatever pieces of reusable code are available to 
you.


The thing is, in languages like Perl, Python, Ruby (to name a 
few), reusing
someone else's code is not only easy, but it is how most people 
actually write code most of the time.


I think he's wrong, because it spoils the comparison. Every 
answer should delegate those tasks to a library that Stroustroup 
used as well, e.g. regex matching, string to number conversion 
and some kind of TCP sockets. But it must do the same work that 
he's solution does: Create and parse HTML header and extract the 
html links, probably using regex, but I wouldn't mind another 
solution.


Everyone can put a libdo_the_stroustroup_thing on dub and then 
call do_the_stroustroup_thing() in main. To compare what the 
standard libraries (and libraries easily obtained or quasi 
standard) offer is another challenge.




Re: For those ready to take the challenge

2015-01-10 Thread Paulo Pinto via Digitalmars-d-learn
On Saturday, 10 January 2015 at 15:52:21 UTC, Tobias Pankrath 
wrote:

...

The thing is, in languages like Perl, Python, Ruby (to name a 
few), reusing
someone else's code is not only easy, but it is how most 
people actually write code most of the time.


I think he's wrong, because it spoils the comparison. Every 
answer should delegate those tasks to a library that 
Stroustroup used as well, e.g. regex matching, string to number 
conversion and some kind of TCP sockets. But it must do the 
same work that he's solution does: Create and parse HTML header 
and extract the html links, probably using regex, but I 
wouldn't mind another solution.


Everyone can put a libdo_the_stroustroup_thing on dub and then 
call do_the_stroustroup_thing() in main. To compare what the 
standard libraries (and libraries easily obtained or quasi 
standard) offer is another challenge.


I disagree.

The great thing about comes with batteries runtimes is that I 
have the guarantee the desired features exist in all platforms 
supported by the language.


If the libraries are dumped into a repository, there is always a 
problem if the library works across all OS supported by the 
language or even if they work together at all. Specially if they 
depend on common packages with incompatible versions.


This is the cause of so many string and vector types across all 
C++ libraries as most of those libraries were developed before 
C++98 was even done.


Or why C runtime isn't nothing more than a light version of UNIX 
as it was back in 1989, without any worthwhile feature since 
then, besides some extra support for numeric types and a little 
more secure libraries.


Nowadays, unless I am doing something very OS specific, I hardly 
care which OS I am using, thanks to such comes with batteries 
runtimes.



--
Paulo


Re: For those ready to take the challenge

2015-01-10 Thread via Digitalmars-d-learn
On Saturday, 10 January 2015 at 15:52:21 UTC, Tobias Pankrath 
wrote:
I think he's wrong, because it spoils the comparison. Every 
answer should delegate those tasks to a library that 
Stroustroup used as well, e.g. regex matching, string to number 
conversion and some kind of TCP sockets. But it must do the 
same work that he's solution does: Create and parse HTML header 
and extract the html links, probably using regex, but I 
wouldn't mind another solution.


The challenge is completely pointless. Different languages have 
different ways of hacking together a compact incorrect solution. 
How to directly translate a C++ hack into another language is a 
task for people who are drunk.


For the challenge to make sense it would entail parsing all legal 
HTML5 documents, extracting all resource links, converting them 
into absolute form and printing them one per line. With no 
hickups.




ddox question

2015-01-10 Thread Andrei Alexandrescu via Digitalmars-d
In the ddox-generated documentation the heading is e.g. Module 
std.container. I wanted to style std.container in code font, but 
can't find where that text is generated. I've searched dlang.org/ and 
dub/, no avail.


Andrei


Re: Game development

2015-01-10 Thread Mike Parker via Digitalmars-d

On 1/10/2015 12:28 AM, Ras wrote:

On Friday, 9 January 2015 at 13:22:14 UTC, Mike Parker wrote:

On 1/9/2015 2:35 PM, Ras wrote:



No i dont. I want to use D language for as much as possible. The reason
I want to use C++ for the engine is that it always has full support for
DirectX.


D has built-in support for COM and can interop with DX just fine.


So how can I get started with Directx programming in D? Could you give
me a link to maybe a binding or some projects on github?


You can find bindings for DX 9  10 as part of the Win32 API bindings at 
[1]. Some work was done on a DX 11 binding for the Aurora graphics 
project [2], but I don't know how complete it is. If you need DX 11, 
though, it should serve as a good starting point.


[1] 
https://github.com/CS-svnmirror/dsource-bindings-win32/tree/master/directx

[2] https://github.com/auroragraphics/directx


Re: For those ready to take the challenge

2015-01-10 Thread Nordlöw

On Friday, 9 January 2015 at 17:15:43 UTC, Adam D. Ruppe wrote:

import arsd.dom;
import std.net.curl;
import std.stdio, std.algorithm;

void main() {
	auto document = new Document(cast(string) 
get(http://www.stroustrup.com/C++.html;));

writeln(document.querySelectorAll(a[href]).map!(a=a.href));
}

Or perhaps better yet:

import arsd.dom;
import std.net.curl;
import std.stdio;

void main() {
	auto document = new Document(cast(string) 
get(http://www.stroustrup.com/C++.html;));

foreach(a; document.querySelectorAll(a[href]))
writeln(a.href);
}

Which puts each one on a separate line.


Both these code examples triggers the same assert()

dmd: expression.c:3761: size_t StringExp::length(int): Assertion 
`encSize == 1 || encSize == 2 || encSize == 4' failed.


on dmd git master. Ideas anyone?


Re: core.atomic: atomicFence, atomicLoad, atomicStore

2015-01-10 Thread John Colvin via Digitalmars-d-learn

On Saturday, 10 January 2015 at 12:16:24 UTC, ref2401 wrote:
I learned how 'atomicOp' and 'cas' work and why i need them 
from the following sources:

http://ddili.org/ders/d.en/concurrency_shared.html (Ali's book)
http://www.informit.com/articles/article.aspx?p=1609144 
(Andrei's book)


Can anybody tell me how 'atomicFence', 'atomicLoad' and 
'atomicStore' work and what do i need them for? Unfortunately 
official documentation didn't make it clear for me.


I seem to be posting this a few times a week now: 
http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-1-of-2 
and 
http://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-2-of-2


Although we don't have std::atomic in D, the same principles 
apply to using core.atomic.atomicLoad and friends.


Re: For those ready to take the challenge

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 10 January 2015 at 17:23:31 UTC, Ola Fosheim Grøstad 
wrote:
For the challenge to make sense it would entail parsing all 
legal HTML5 documents, extracting all resource links, 
converting them into absolute form and printing them one per 
line. With no hickups.


Though, that's still a library thing rather than a language thing.

dom.d and the Url struct in cgi.d should be able to do all that, 
in just a few lines even, but that's just because I've done a 
*lot* of web scraping with the libs before so I made them work 
for that.


In fact let me to do it. I'll use my http2.d instead of 
cgi.d, actually, it has a similar Url struct just more focused on 
client requests.



import arsd.dom;
import arsd.http2;
import std.stdio;

void main() {
auto base = Uri(http://www.stroustrup.com/C++.html;);
// http2 is a newish module of mine that aims to imitate
// a browser in some ways (without depending on curl btw)
auto client = new HttpClient();
auto request = client.navigateTo(base);
auto document = new Document();

// and http2 provides an asynchonous api but you can
// pretend it is sync by just calling waitForCompletion
auto response = request.waitForCompletion();

// parseGarbage uses a few tricks to fixup invalid/broken 
HTML
// tag soup and auto-detect character encodings, 
including when

// it lies about being UTF-8 but is actually Windows-1252
document.parseGarbage(response.contentText);

// Uri.basedOn returns a new absolute URI based on 
something else

foreach(a; document.querySelectorAll(a[href]))
writeln(Uri(a.href).basedOn(base));
}


Snippet of the printouts:

[...]
http://www.computerhistory.org
http://www.softwarepreservation.org/projects/c_plus_plus/
http://www.morganstanley.com/
http://www.cs.columbia.edu/
http://www.cse.tamu.edu
http://www.stroustrup.com/index.html
http://www.stroustrup.com/C++.html
http://www.stroustrup.com/bs_faq.html
http://www.stroustrup.com/bs_faq2.html
http://www.stroustrup.com/C++11FAQ.html
http://www.stroustrup.com/papers.html
[...]

The latter are relative links that it based on and the first few 
are absolute. Seems to have worked.



There's other kinds of links than just a[href], but fetching them 
is as simple as adding them to the selector or looping for them 
too separately:


foreach(a; document.querySelectorAll(script[src]))
writeln(Uri(a.src).basedOn(base));

none on that page, no links either, but it is easy enough to do 
with the lib.




Looking at the source of that page, I find some invalid HTML and 
lies about the character set. How did Document.parseGarbage do? 
Pretty well, outputting the parsed DOM tree shows it 
auto-corrected the problems I see by eye.


Re: Game development

2015-01-10 Thread via Digitalmars-d
On Saturday, 10 January 2015 at 15:44:32 UTC, ketmar via 
Digitalmars-d wrote:

On Sat, 10 Jan 2015 15:17:17 +
dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:

Ketmar the teenage albino freak wasting time replying to time
wasters.

i'm proud of having my own fanclub.


When I was young and being on a network meant a BBS, the usual 
reply was RTFM. I guess the modern age version of RTFM is to 
dump a URL:


http://dlang.org/cpp_interface

Unforunately, dlang.org lacks a proper C++ binding tutorial, so I 
guess this RTFM might turn into a WTF! WTFM!.




Re: NaCl/Emscripten

2015-01-10 Thread Martin Nowak via Digitalmars-d

On 01/09/2015 10:28 AM, Manu via Digitalmars-d wrote:

I'm looking at another potential opportunity to get D into the office,
but the target's for this particular project are NaCL and/or
Emscripten.

I was gonna start hacking around to see what the limitations are with
Emscripten on D code tonight. Has anyone done any serious
investigation here?

NaCl is a more useful target, but I think that will rely on a special
build of LDC... has there been discussion about that before? Can any
of the LDC guys chime in on the possibility?



It would require some druntime work for the libc differences (newlib vs. 
glibc). That's similar to the ongoing Android/X86 work 
https://github.com/D-Programming-Language/druntime/pull/1069.


Re: For those ready to take the challenge

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 10 January 2015 at 15:52:21 UTC, Tobias Pankrath 
wrote:
But it must do the same work that he's solution does: Create 
and parse HTML header and extract the html links, probably 
using regex, but I wouldn't mind another solution.


Yeah, that would be best. BTW interesting line here:

   s  GET   http://; + server + / + file   
HTTP/1.0\r\n;

s  Host:   server  \r\n;

Why + instead of ? C++'s usage of  is totally blargh to me 
anyway, but seeing both is even stranger.


Weird language, weird library.

Everyone can put a libdo_the_stroustroup_thing on dub and then 
call do_the_stroustroup_thing() in main. To compare what the 
standard libraries (and libraries easily obtained or quasi 
standard) offer is another challenge.


Yeah.


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Jacob Carlborg via Digitalmars-d

On 2015-01-10 14:19, Martin Nowak wrote:


I'd simple produce multiple rows, the principle remains the same.


Ok, I think I understand the code now. You managed to register the 
fields at compile time. Pretty neat. I thought the query would need to 
be delayed to the first call to opDispatch.



The example already uses Variant.


Yes, but when you get the value out of the of the variant. I think one 
also needs to be able to check if a field was is null or not. Or am I 
missing something?


--
/Jacob Carlborg


Re: @api: One attribute to rule them All

2015-01-10 Thread via Digitalmars-d

On Friday, 9 January 2015 at 16:14:01 UTC, Zach the Mystic wrote:
If solving the problem at the level of the command line with 
the help of the existing 'export' attribute is more flexible 
and robust, then I'm all for it. The first thing to find out is 
if anyone will have a problem overloading the meaning of 
'export' for this purpose. I can't think of a reason they 
would, unless people are currently using 'export' in some niche 
way which would be ruined by the new flag.


This DIP is of relevance:
http://wiki.dlang.org/DIP45


Re: Why doesn't mktspec() use clock_gettime?

2015-01-10 Thread Mike Wey via Digitalmars-d

On 01/10/2015 08:16 AM, ketmar via Digitalmars-d wrote:

On Fri, 09 Jan 2015 19:17:49 -0800
Andrei Alexandrescu via Digitalmars-d digitalmars-d@puremagic.com
wrote:


On 1/9/15 6:13 PM, weaselcat wrote:

On Saturday, 10 January 2015 at 02:03:17 UTC, Andrei Alexandrescu wrote:

cc Sean Kelly

https://github.com/D-Programming-Language/druntime/blob/master/src/core/sync/config.d#L28


Looks like that use has been disable with static if (false). What was
the reason?

A coworker spent a few hours debugging a matter that pointed to this
issue. He removed the false and replaced CLOCK_REALTIME with
CLOCK_MONOTONIC in our druntime tree.

Any insight into the matter? How should we address it by supporting
multiple clock types portably?


Thanks,

Andrei


https://github.com/D-Programming-Language/druntime/commit/998739c


Thanks. What library would that be? Is it unavailable on some platforms?
If always available, couldn't we just link with it? -- Andrei

on older GNU/Linux systems it requires -lrt. it doesn't with relatively
new glibc (something that is 1.5 year old is ok, AFAIR), and i see no
reasons to be conservative here, but...



And on Linux we already link with librt anyway.

--
Mike Wey


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Jacob Carlborg via Digitalmars-d

On 2015-01-10 13:36, Martin Nowak wrote:


The idea isn't bad, but the performance will suck. This is generally
known as N+1 query, only that this is even worse, as each field is
queried individually.


Since the all method was called I would assume all rows in the person 
table are fetched in one single query. Although I don't know if that 
will work if not the whole row should be loaded.



Here is a sketch for an optimal solution. I'm actually eagerly waiting
that someone finally implements it.

http://dpaste.dzfl.pl/cd375ac594cf


How would you handled fetching multiple rows and a foreach loop, i.e. my 
example?


Perhaps a detail but using a wrapped type instead of the raw types in 
Person you could handle things like null in the database.


--
/Jacob Carlborg


Re: For those ready to take the challenge

2015-01-10 Thread bearophile via Digitalmars-d-learn

Adam D. Ruppe:


Don't use git master :P


Is the issue in Bugzilla?

Bye,
bearophile


Re: For those ready to take the challenge

2015-01-10 Thread Daniel Kozak via Digitalmars-d-learn
Vladimir Panteleev via Digitalmars-d-learn píše v So 10. 01. 2015 v
07:42 +:
 On Saturday, 10 January 2015 at 02:10:04 UTC, Jesse Phillips 
 wrote:
  On Friday, 9 January 2015 at 13:50:29 UTC, eles wrote:
  https://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro
 
  Link to answer in D:
  http://codegolf.stackexchange.com/a/44417/13362
 
 I think byLine is not necessary. By default . will not match line 
 breaks.
 
 One statement solution:
 
 import std.net.curl, std.stdio;
 import std.algorithm, std.regex;
 
 void main() {
   get(http://www.stroustrup.com/C++.html;)
   .matchAll(`a.*?href=(.*)`)
   .map!(m = m[1])
   .each!writeln();
 }
 
 Requires Phobos PR#2024 ;)
Oh here is it, I was looking for each. I think it is allready in a
phobos but I can not find. Now I know why :D



Re: Utah Valley University is a sponsor of DConf 2015

2015-01-10 Thread Walter Bright via Digitalmars-d-announce

On 1/9/2015 10:37 PM, Ali Çehreli wrote:

I encourage everyone to apply for visa as soon as possible. US visa process can
be frustratingly delayed depending on many unknown factors.


We've lost speakers in the past due to visa delays. I agree that it's never too 
early to get this done.




core.atomic: atomicFence, atomicLoad, atomicStore

2015-01-10 Thread ref2401 via Digitalmars-d-learn
I learned how 'atomicOp' and 'cas' work and why i need them from 
the following sources:

http://ddili.org/ders/d.en/concurrency_shared.html (Ali's book)
http://www.informit.com/articles/article.aspx?p=1609144 (Andrei's 
book)


Can anybody tell me how 'atomicFence', 'atomicLoad' and 
'atomicStore' work and what do i need them for? Unfortunately 
official documentation didn't make it clear for me.


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Martin Nowak via Digitalmars-d

On 01/10/2015 11:20 AM, Jacob Carlborg wrote:

On 2015-01-10 07:46, DaveG wrote:

I might be crazy, but it seems like the compiler has all the information
necessary to figure this out and it would make user code simpler, less
error prone, and more efficient. So does anybody have any idea on how to
actually achieve this?


I'm not exactly sure if this is what you want but you can implement the
opDispatch [1] method in a class or struct. This method will be called
if no other method exists with the same name. There's also something
called alias this [2] that allows you to do something similar.

class Foo
{
 void foo () {}
 void opDispatch (string name)() {}
}

auto f = new Foo;
f.foo(); // will call foo
f.bar(); // will be lowered to f.opDispatch!(bar)();

If you're implementing an ORM I would recommend executing queries
lazily. You can do something like this:

class Person : ORM.Base
{
 String name;
 Int age;

// this method returns a range/proxy that implements the range api [3]
 static ORM.Range!(Person) all () {}
}

String would look something like this:

struct String
{
 alias get this;

 // this method will fetch the data from the database
 private string get ();
}

Using the interface would look something like this:

auto p = Person.all(); // no database query has been performed yet

// the range interface makes it possible to use a foreach
// when starting the foreach loop is when the first query will happen
foreach (e ; p)
{
 // this call will trigger a call to the get method in String
 // via the alias this
 string name = e.name;
 writeln(name);
}


The idea isn't bad, but the performance will suck. This is generally 
known as N+1 query, only that this is even worse, as each field is 
queried individually.


Here is a sketch for an optimal solution. I'm actually eagerly waiting 
that someone finally implements it.


http://dpaste.dzfl.pl/cd375ac594cf


Re: For those ready to take the challenge

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 10 January 2015 at 12:34:42 UTC, Tobias Pankrath 
wrote:
Since it is a comparison of languages it's okay to match the 
original behaviour.


I don't think this is really a great comparison of languages 
either though because it is gluing together a couple library 
tasks. Only a few bits about the actual language are showing 
through.



In the given regex solutions, C++ has an advantage over C wherein 
the regex structure can be freed automatically in a destructor 
and a raw string literal in here, but that's about all from the 
language itself. The original one is kinda long because he didn't 
use a http get library, not because the language couldn't do one.


There are bits where the language can make those libraries nicer 
too: dom.d uses operator overloading and opDispatch to support 
things like .attribute and also .attr.X and .style.foo and 
element[selector].addClass(foo) and so on implemented in very 
very little code - I didn't have to manually list methods for the 
collection or properties for the attributes - ...but a library 
*could* do it that way and get similar results for the end user; 
the given posts wouldn't show that.


Traits and functions

2015-01-10 Thread Bauss via Digitalmars-d-learn
Is there a way to get all functions within a module using traits? 
I tried allMembers and it seem to work, but I can't use 
getFunctionAttributes with it and if I use getAttributes then 
it won't find any applied attributes.


What I do is having a package module with a staic constructor 
which loops through allMembers and then I want to find 
functions with a specific attribute. All the members are imported 
using public imports. However it can find the specific functions, 
but it does not find the attributes.


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Martin Nowak via Digitalmars-d

On 01/10/2015 01:52 PM, Jacob Carlborg wrote:

On 2015-01-10 13:36, Martin Nowak wrote:


The idea isn't bad, but the performance will suck. This is generally
known as N+1 query, only that this is even worse, as each field is
queried individually.


Since the all method was called I would assume all rows in the person
table are fetched in one single query. Although I don't know if that
will work if not the whole row should be loaded.


For row or document oriented databases you want to query all fields in 
parallel. For columnar stores it might be possible to efficiently query 
specific fields for many documents.





Here is a sketch for an optimal solution. I'm actually eagerly waiting
that someone finally implements it.

http://dpaste.dzfl.pl/cd375ac594cf


How would you handled fetching multiple rows and a foreach loop, i.e. my
example?


I'd simple produce multiple rows, the principle remains the same.


Perhaps a detail but using a wrapped type instead of the raw types in
Person you could handle things like null in the database.


The example already uses Variant.


Re: For those ready to take the challenge

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 10 January 2015 at 13:22:57 UTC, Nordlöw wrote:

on dmd git master. Ideas anyone?


Don't use git master :P

Definitely another regression. That line was just pushed to git 
like two weeks ago and the failing assertion is pretty obviously 
a pure dmd code bug, it doesn't know the length of char 
apparently.


Re: An idea for commercial support for D

2015-01-10 Thread Joakim via Digitalmars-d

On Friday, 9 January 2015 at 18:01:50 UTC, anonymous wrote:

On Friday, 9 January 2015 at 06:43:01 UTC, Joakim wrote:

On Tuesday, 6 January 2015 at 22:37:40 UTC, anonymous wrote:

[...]
As far as I know there are companies that employ developers 
to work on open source software, with their patches 
open-sourced immediately. I'm assuming the employer can 
direct where exactly the effort goes. That's essentially it, 
no?


A few companies may do that, but he referred to paying for 
fixes you want right away but getting patches other companies 
paid for for free.  I don't know of any commercial support 
model where that happens.


When two companies hire two different guys to work on the same 
OSS project, each company pays for the patches of their guy, 
while getting the patches of the other guy for free.


We were talking about commercial support models, so presumably he 
was talking about a single support company that will both fix 
your problem on demand for money and give you other such fixes 
for free.  I pointed out that they usually use support 
subscriptions, where it's more accurate to say that you're paying 
for all those other fixes too, just less than the ones you 
directly asked for.


As for outside companies, as long as they release their fixes, 
sure, you get them.  But that's also true in the hybrid model 
I've laid out, after the funding/time limit has passed, ie you'll 
eventually get outside fixes you didn't pay for.


For example, I just googled paid linux developers and came 
across an article [1] that states:
Within that field Red Hat topped that chart with 12% followed 
by Inte with 8% IBM and Novell with 6% each and Oracle 3%. 
Despite the clear commercial rivalry between those players 
central kernel development worked well Corbet noted.


Now it might be that they hold back patches for some time to 
gain an advantage over the competition. But it's my uneducated 
impression that they don't.


These consulting companies likely don't hold back many patches, 
because the GPL requires that they give them to at least their 
customers who deploy the software.  But the companies deploying 
the software in their own offices can hold back the patches.



[...]

Yes, _anything_ you pay for is a competitive advantage for you.
He seems to think only the direct features of your product are 
your competitive advantage, but indirect costs like this also 
affect the price and overall quality of your product, at least 
relative to other products in the market, which are just as 
important.

[...]
Businesses generally don't sink money into stuff that provides 
them no competitive advantage.  Therefore, the 
counter-proposal is pure fantasy.


I would have guessed that business is happy to invest when the 
return is right. Business wouldn't say no to making more money 
just because someone else makes more money, too, would they? Of 
course, strategic considerations have to be factored in there. 
Like harming or benefitting a competitor. But also brand image 
and whatever else.


You maximize your return by keeping the patches to yourself, at 
least for a while.  So yes, they may invest, but they may not 
release right away.



[...]
The win for the customer is that they're getting a patch that 
would not otherwise exist, not sure what's more clear than 
that.


Sure, but this is all about how it's a bigger win than 
open-sourcing the patch right away.


I'm just countering your claim that there is no win for the 
customer in the hybrid model.  It is also a bigger win than 
open-sourcing right away.



[...]
I'm not sure exactly what you by mean by competitors buying 
patches collectively.  If you mean that all the companies pool 
together and fund OSS development, how do you keep some 
outlier from not contributing any money, using the resulting 
OSS code, then undercutting you on price?


I assumed that the competitors know each other. That would make 
it an all-or-none deal. And the obvious choice would be to 
split the cost. When there may be serious unkown competition, 
it becomes unfeasible, I guess.


Paid closed-source patches are simply another way of splitting 
the cost between customers, where you make sure there are no 
holdouts, because they don't get the patch unless they pay.



[...]
I don't know what the minor/occasional contributors think, so 
who knows how they'd react to such a move, but D could well 
afford to lose them if it gets several paid devs and some new 
OSS contributors from the resulting larger D community in 
return. :) The cost-benefit on that is a no-brainer, you have 
to go paid.


The 'if' is the thing. Lose too many volunteers while 
attracting not enough business and whoops you're going in the 
wrong direction.


If they're minor/occasional contributors as you said, they won't 
make much of a difference.



Also, personally I like volunteerism. But that's just me.


D has gotten very far as a volunteer project.  But it has 
essentially no uptake in medium to 

Re: For those ready to take the challenge

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 10 January 2015 at 15:24:45 UTC, bearophile wrote:

Is the issue in Bugzilla?



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


Re: NaCl/Emscripten

2015-01-10 Thread via Digitalmars-d
There are also other compilers from C++ to Javascript, Mandreel 
and Cheerp.


Cheerp claims to support the builtin Javascript garbage collector:

«Dynamic memory management. C++ objects are translated directly 
to JS objects, without the proxy of an emulated, flat memory 
space. Allow your applications to exploit the JavaScript VM 
garbage collector and co-exist with fair, on-demand memory 
allocation.»


http://www.leaningtech.com/cheerp/blog/

So if Cheerp is ready for production (I don't know if it is), it 
might be a better fit for D.


Re: For those ready to take the challenge

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 10 January 2015 at 15:24:45 UTC, bearophile wrote:

Is the issue in Bugzilla?


I don't know, bugzilla is extremely difficult to search.

I guess I'll post it again and worst case it will be closed as a 
duplicate.


Re: Game development

2015-01-10 Thread dajones via Digitalmars-d
On Saturday, 10 January 2015 at 15:44:32 UTC, ketmar via 
Digitalmars-d wrote:

On Sat, 10 Jan 2015 15:17:17 +
dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:


On Friday, 9 January 2015 at 06:17:28 UTC, ketmar via
Digitalmars-d wrote:
 On Thu, 08 Jan 2015 22:27:53 +0100
 Joseph Rushton Wakeling via Digitalmars-d

 if he is intelligent enough, he will understand that nobody 
 can talk
 for the whole community, so in the worst case he will ignore 
 myself
 personally. if he is not intelligent enough... oh, well, as 
 nobody else
 wants to be a judge, i will be one. i don't feel wrong 
 calling someone
 timewaster if he *is* one. and i can smell 'em from a 
 distance.


Ketmar the teenage albino freak wasting time replying to time
wasters.

i'm proud of having my own fanclub.


You are **proud** to draw the attention of nerdy middle aged 
men...


jeez I though I had problems.


Re: DConf 2015 Call for Submissions is now open

2015-01-10 Thread Iain Buclaw via Digitalmars-d-announce
On 9 January 2015 at 00:32, Walter Bright via Digitalmars-d-announce
digitalmars-d-announce@puremagic.com wrote:
 On 1/8/2015 8:42 AM, Jonathan M Davis via Digitalmars-d-announce wrote:

 On Thursday, January 08, 2015 10:31:37 Iain Buclaw via
 Digitalmars-d-announce wrote:

 On 6 January 2015 at 23:24, Andrei Alexandrescu via
 Digitalmars-d-announce digitalmars-d-announce@puremagic.com wrote:

 Hello,


 Exciting times! DConf 2015 will take place May 27-29 2015 at Utah Valley
 University in Orem, UT.


 Awesome, that runs over my birthday (28th). My friends and family
 won't be too pleased. :-)


 Just get them to help chip in for the airfare and hotel costs for your
 birthday present. ;)


 Or they can come to the conference, too!


In any event, are you doing flash talks this year?  I don't think I
could find something to spend more than 15 minutes talking about this
year.

Iain


Re: @api: One attribute to rule them All

2015-01-10 Thread Atila Neves via Digitalmars-d

Very interesting, looking forward to reading the DIP.

Atila

On Friday, 9 January 2015 at 11:40:28 UTC, Dicebot wrote:
I think that push for more inference / WPO is an important goal 
for D. However I had somewhat more radical and generic changes 
in mind, ones that don't add new keywords or semantics but 
rather strictly define what existing ones mean. This was 
supposed to be turned into a DIP at some point (possibly after 
consulting with Walter) but here is the draft outline:


- separate compilation in basic C sense becomes illegal
- minimal legal unit of separate compilation is defined as 
static library
- any time library gets built, it _must_ be distributed with 
matching .di interfaces. If there are original .d files 
imported, one must not try to link prebuilt library.

- .di generation is split in two modes:
1) 'minimal' (API) which only writes exported symbols and 
ignores even public ones. All inferred attributes gets written 
explicitly there. This is what gets recommended for public 
distribution (even if it is source-only distribution) and what 
defines stable API.
2) 'full' mode which is similar to existing .di generation 
but with all attributes explicitly written to all functions. It 
is approach recommended for creating intermediate built 
artifacts (such as dub building of dependencies).


Stability of (1) headers can be validated mechanically by 
compiler / external tool in such scenario. As you may notice no 
new keywords / language concepts are proposed, it is only about 
more strict definition of standard development flow. It also 
opens well-defined borderline for any WPO.


Needs a lot of work before any serious destruction of course 
but should give some overall feeling of what I am going at.




Re: For those ready to take the challenge

2015-01-10 Thread Tobias Pankrath via Digitalmars-d-learn

On Friday, 9 January 2015 at 17:18:43 UTC, Adam D. Ruppe wrote:
Huh, looking at the answers on the website, they're mostly 
using regular expressions. Weaksauce. And wrong - they don't 
find ALL the links, they find the absolute HTTP urls!


Since it is a comparison of languages it's okay to match the 
original behaviour.


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Jacob Carlborg via Digitalmars-d

On 2015-01-10 13:36, Martin Nowak wrote:


I'm actually eagerly waiting that someone finally implements it.


There are two ORM libraries at code.dlang.org [1] [2]. Although  I don't 
know how usable they are.


[1] http://code.dlang.org/packages/hibernated
[2] http://code.dlang.org/packages/dvorm

--
/Jacob Carlborg


Re: Game development

2015-01-10 Thread dajones via Digitalmars-d

On Friday, 9 January 2015 at 06:17:28 UTC, ketmar via
Digitalmars-d wrote:

On Thu, 08 Jan 2015 22:27:53 +0100
Joseph Rushton Wakeling via Digitalmars-d


if he is intelligent enough, he will understand that nobody can 
talk
for the whole community, so in the worst case he will ignore 
myself
personally. if he is not intelligent enough... oh, well, as 
nobody else
wants to be a judge, i will be one. i don't feel wrong calling 
someone
timewaster if he *is* one. and i can smell 'em from a 
distance.


Ketmar the teenage albino freak wasting time replying to time
wasters.


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread DaveG via Digitalmars-d

On Saturday, 10 January 2015 at 13:19:19 UTC, Martin Nowak wrote:

On 01/10/2015 01:52 PM, Jacob Carlborg wrote:

On 2015-01-10 13:36, Martin Nowak wrote:

The idea isn't bad, but the performance will suck. This is 
generally
known as N+1 query, only that this is even worse, as each 
field is

queried individually.


Since the all method was called I would assume all rows in 
the person
table are fetched in one single query. Although I don't know 
if that

will work if not the whole row should be loaded.


The issue is not with the rows returned, but the columns (or 
object properties - which may map to multiple tables or be 
derived in some other way). Which rows need to returned is 
determined by some type of filtering mechanism, which is not an 
issue because that (logically) has to be explicit. The issue is 
determining which properties (for each row) actually need to be 
returned without the need to explicitly request them (the data is 
already implicit within the user code itself).




Here is a sketch for an optimal solution. I'm actually 
eagerly waiting

that someone finally implements it.

http://dpaste.dzfl.pl/cd375ac594cf


Martin, that is brilliant! It seemed like all the pieces where 
there, I just couldn't put them together. I'm glad I'm not the 
only one thinking about this.


I have never been able to find an ORM (in any language) that 
comes close to working for us. We are currently looking into 
switching off PHP and the front runner is C# because it's a safe 
bet, we run Windows, and some people are sold on the concept of 
Entity Framework. Entity is (or was) built in to the .NET so they 
could theoretically do some neat tricks like compile query logic 
at compilation, and infer what data is actually needed by the 
program (the issue being discussed). Turns out they do query 
caching, but that's about it.


I'm not sure I can sell the idea of D (this is a very small and 
conservative group). I would also have to sell the idea of 
writing an ORM which is certainly not on the roadmap, but this 
will certainly help my argument.


Oh, we will also need a good SQL Server library which, to my 
knowledge, D is lacking. This is going to be a hard sell...



-Dave


Re: For those ready to take the challenge

2015-01-10 Thread MattCoder via Digitalmars-d-learn

On Friday, 9 January 2015 at 13:50:29 UTC, eles wrote:

https://codegolf.stackexchange.com/questions/44278/debunking-stroustrups-debunking-of-the-myth-c-is-for-large-complicated-pro


From the link: Let's show Stroustrup what small and readable 
program actually is.


Alright, there are a lot a examples in many languagens, but those 
examples doesn't should handle exceptions like the original code 
does?


Matheus.


Is anyone working on a D source code formatting tool?

2015-01-10 Thread Walter Bright via Digitalmars-d

Has someone made a dfmt, like http://gofmt.com/ ?


Discussion on groupBy

2015-01-10 Thread Andrei Alexandrescu via Digitalmars-d
groupBy is an important primitive for relational algebra queries on 
data. Soon to follow are operators such as aggregate() which is a sort 
of reduce() but operating on ranges of ranges. With those in tow, a 
query such as


SELECT COUNT(*), SUM(x) FROM data GROUP BY userid

can be expressed as:

data
  .groupBy!((a, b) = a.userid == b.userid)
  .aggregate(count, (a, b) = a.x + b.x);

We're working the kinks out groupBy now. Those interested please follow 
at https://issues.dlang.org/show_bug.cgi?id=13936.



Thanks,

Andrei


Re: For those ready to take the challenge

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d-learn
On Saturday, 10 January 2015 at 19:17:22 UTC, Ola Fosheim Grøstad 
wrote:

Nice and clean code; does it expand html entities (amp)?


Of course. It does it both ways:

spana amp;/span

span.innerText == a 

span.innerText = a \ b;
assert(span.innerHTML == a quot; b);

parseGarbage also tries to fix broken entities, so like  
standing alone it will translate to amp; for you. there's also 
parseStrict which just throws an exception in cases like that.


That's one thing a lot of XML parsers don't do in the name of 
speed, but I do since it is pretty rare that I don't want them 
translated. One thing I did for a speedup though was scan the 
string for  and if it doesn't find one, return a slice of the 
original, and if it does, return a new string with the entity 
translated. Gave a surprisingly big speed boost without costing 
anything in convenience.


The HTML5 standard has improved on HTML4 by now being explicit 
on how incorrect documents shall be interpreted in section 8.2. 
That ought to be sufficient, since that is what web browsers 
are supposed to do.


http://www.w3.org/TR/html5/syntax.html#html-parser


Huh, I never read that, my thing just did what looked right to me 
over hundreds of test pages that were broken in various strange 
and bizarre ways.


Re: Is anyone working on a D source code formatting tool?

2015-01-10 Thread Meta via Digitalmars-d

On Saturday, 10 January 2015 at 21:17:29 UTC, Meta wrote:
On Saturday, 10 January 2015 at 20:54:56 UTC, Jacob Carlborg 
wrote:

On 2015-01-10 21:17, Walter Bright wrote:

Has someone made a dfmt, like http://gofmt.com/ ?


I have thought about it a couple of times but never started. 
It would be really nice to have.


https://github.com/Hackerpilot/dfix


Ah, never mind me. Although the functionality between dfix and a 
dfmt is probably quite similar.


Re: Is anyone working on a D source code formatting tool?

2015-01-10 Thread Meta via Digitalmars-d
On Saturday, 10 January 2015 at 20:54:56 UTC, Jacob Carlborg 
wrote:

On 2015-01-10 21:17, Walter Bright wrote:

Has someone made a dfmt, like http://gofmt.com/ ?


I have thought about it a couple of times but never started. It 
would be really nice to have.


https://github.com/Hackerpilot/dfix


Re: D idioms list

2015-01-10 Thread Walter Bright via Digitalmars-d-announce

On 1/10/2015 1:28 PM, weaselcat wrote:

Sorry for the off-topic noise, but where will you be publishing your articles
since Dr.Dobbs has closed?

Sorry if you have answered this elsewhere.


It's a good question. Dr. Dobb's has graciously given me permission to republish 
them, and I'll post them on http://digitalmars.com/articles. As you can see, 
I've already done a few of them. Lots more to go.


Any upgrades planned for D forums?

2015-01-10 Thread bitwise via Digitalmars-d

I'm curious if there are any upgrades coming in the near future.

As a D-Newbie, I find myself combing these forums regularly to 
try and get up to speed on what's going on, but there are several 
things making it difficult.


-I have a valid email address in the box up there^, but I don't 
receive notifications when people respond to my posts here.


-The way quotes are displayed is tough on the eyes. Rather than 
having the quotes grayed out and crowded by angle brackets, I 
would prefer something like stackoverflow where the text was 
black, but on a gray background, possibly with black outlines for 
nested quotes.


-Looking at code here is brutal. Lines wrap way too short, no 
syntax highlighting. https://highlightjs.org/ supports syntax 
highlighting for the D language and is very easy to implement. 
And a scrollable area for code would be nice. I suppose code 
sections could be signalled by leading a line with 4 spaces like 
SO, or with [code] tags.


-editing and delete posts after posting would be nice, but I 
assume this would be quite a bit more difficult than the above 
suggestions.




Phobos Contributor Tutorial

2015-01-10 Thread via Digitalmars-d

Hi,

with one phobos PR accepted any a second one submitted, I feel it 
is about time I write a tutorial. No, seriously, I spend some 
time to get started. Others might have a rough time, too. So here 
is a draft of a contributor tutorial. Posix based.


https://gist.github.com/kuettler/e907e51c14f7255e3489#file-phobos_contributor_tutorial-md

All of it is taken from the wiki, of course.


Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-10 Thread Laeeth Isharc via Digitalmars-d-learn
Small recommendation (apart from the reserved word issue which 
you fixed): it's generally considered good D style to give 
structs and classes names that start with capital letters, 
JustLikeThis.  So, I suggest Node rather than node.


Very minor point, and of course, your code is yours to style as 
you wish, but it can be helpful to meet the standard style 
conventions in order to make it as easy as possible for 
everyone else to understand.



Thanks for the reminder.  I use D Style when I am writing 
properly, but haven't yet internalized it for a quick example and 
old habits die hard.


Re: Discussion on groupBy

2015-01-10 Thread Laeeth Isharc via Digitalmars-d
On Saturday, 10 January 2015 at 20:19:14 UTC, Andrei Alexandrescu 
wrote:
groupBy is an important primitive for relational algebra 
queries on data. Soon to follow are operators such as 
aggregate() which is a sort of reduce() but operating on ranges 
of ranges. With those in tow, a query such as


SELECT COUNT(*), SUM(x) FROM data GROUP BY userid

can be expressed as:

data
  .groupBy!((a, b) = a.userid == b.userid)
  .aggregate(count, (a, b) = a.x + b.x);

We're working the kinks out groupBy now. Those interested 
please follow at https://issues.dlang.org/show_bug.cgi?id=13936.


That's great to hear.

One factor slowing D adoption might be the difference between 
being given a complete solution (finished Ikea furniture item) 
and being handed some raw metal blocks and being told to use the 
milling machine yourself.  The amount of work involves to make 
the minimal useful solution is actually quite small, but on the 
one hand the larger part of the benefit accrues to others (which 
holds some people back), and on the other ability follows a power 
law, and there are many more script kiddies than Adam Ruppe types 
in the world.


So small frictions have cumulatively large consequences.

I think the std.algorithm stuff will come in as very handy as 
building blocks for an implementation of Pandas like 
functionality in D.  Since it seems that parsing data - both 
stuctured and unstructured - is in a bull market, this ought to 
be interesting.


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d
On Saturday, 10 January 2015 at 20:51:44 UTC, Jacob Carlborg 
wrote:
That would be FreeTDS [1] with D bindings [2]. Unless Microsoft 
have headers available for interfacing with SQL Server.


You can use ODBC if it is a Windows program. If you want to talk 
to  SQL Server from a Linux program though, FreeTDS is what 
you'll want.


Re: Wrapping a C library with its own GC + classes vs refcounted structs

2015-01-10 Thread Laeeth Isharc via Digitalmars-d-learn

Hi Aldanor.

I wrote a slightly longer reply, but mislaid the file somewhere.

I guess your question might relate to wrapping the HDF5 library - 
something that I have already done in a basic way, although I 
welcome your project, as no doubt we will get to a higher quality 
eventual solution that way.


One question about accurately representing the HDF5 object 
hierarchy.  Are you sure you wish to do this rather than present 
a flattened approach oriented to what makes sense to make things 
easy for the user in the way that is done by h5py and pytables?


In terms of the actual garbage generated by this library - there 
are lots of small objects.  The little ones are things like a 
file access attribute, or a schema for a dataset.  But really the 
total size taken up by the small ones is unlikely to amount to 
much for scientific computing or for quant finance if you have a 
small number of users and are not building some kind of public 
web server.  I think it should be satisfactory for the little 
objects just to wrap the C functions with a D wrapper and rely on 
the object destructor calling the C function to free memory.  On 
the rare occasions when not, it will be pretty obvious to the 
user and he can always call destroy directly.


For the big ones, maybe reference counting brings enough value to 
be useful - I don't know.  But mostly you are either passing data 
to HDF5 to write, or you are receiving data from it.  In the 
former case you pass it a pointer to the data, and I don't think 
it keeps it around.  In the latter, you know how big the buffer 
needs to be, and you can just allocate something from the heap of 
the right size (and if using reflection, type) and use destroy on 
it when done.


So I don't have enough experience yet with either D or HDF5 to be 
confident in my view, but my inclination is to think that one 
doesn't need to worry about reference counting.  Since objects 
are small and there are not that many of them, relying on the 
destructor to be run (manually if need be) seems likely to be 
fine, as I understand it.  I may well be wrong on this, and would 
like to understand the reasons if so.







Laeeth.


Re: endsWith - for a string vs an array of strings

2015-01-10 Thread bearophile via Digitalmars-d-learn

Laeeth Isharc:

I understand from previous discussion there is some difficulty 
over immutability.  I did not quite figure out what the 
solution was in this case:


import std.array;
import std.string;
import std.stdio;
void main(string[] args)
{
string[] test=[1,two,three!];
auto a=arghtwo.endsWith(test);
writefln(%s,a);
}






This does not compile...


Take a look at your error messages:

std.algorithm.endsWith(alias pred = a == b, Range, 
Needles...)(Range doesThisEnd, Needles withOneOfThese)


Needles is not an array type, it's a type tuple, so 
withOneOfThese doesn't accept an array of strings.


This is correct:

auto a = arghtwo.endsWith(1,two,three!);

In D there is a feature that allows a function to accept both an 
array of items and items, but it's not used here by endsWith, for 
reasons I don't understand (other people can answer this).


So if you really want to pack the strings in some kind of unity, 
you can do this as workaround:


void main() {
import std.stdio, std.array, std.string, std.typetuple;

alias test = TypeTuple!(1, two, three!);
auto b = arghtwo.endsWith(test[]);
b.writeln;
}


Bye,
bearophile


Re: Game development

2015-01-10 Thread ketmar via Digitalmars-d
On Sat, 10 Jan 2015 16:03:22 +
dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:

 On Saturday, 10 January 2015 at 15:44:32 UTC, ketmar via 
 Digitalmars-d wrote:
  On Sat, 10 Jan 2015 15:17:17 +
  dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:
 
  On Friday, 9 January 2015 at 06:17:28 UTC, ketmar via
  Digitalmars-d wrote:
   On Thu, 08 Jan 2015 22:27:53 +0100
   Joseph Rushton Wakeling via Digitalmars-d
  
   if he is intelligent enough, he will understand that nobody 
   can talk
   for the whole community, so in the worst case he will ignore 
   myself
   personally. if he is not intelligent enough... oh, well, as 
   nobody else
   wants to be a judge, i will be one. i don't feel wrong 
   calling someone
   timewaster if he *is* one. and i can smell 'em from a 
   distance.
  
  Ketmar the teenage albino freak wasting time replying to time
  wasters.
  i'm proud of having my own fanclub.
 
 You are **proud** to draw the attention of nerdy middle aged 
 men...
ah, sure. it's always funny to see some old jerk having nothing more to
do than running around whining how old is he. i'm enjoying collecting
perverts, you know.


signature.asc
Description: PGP signature


Re: D idioms list

2015-01-10 Thread weaselcat via Digitalmars-d-announce

On Saturday, 10 January 2015 at 20:37:04 UTC, Walter Bright wrote:

On 1/8/2015 2:21 AM, ponce wrote:

I've started a list of curated D tips and tricks here:
http://p0nce.github.io/d-idioms/

Anything that you wished you learned earlier at one point in 
the D world is

welcome to be added or suggested.



My contribution:

http://digitalmars.com/articles/b68.html

(Member function pointers in D)


Sorry for the off-topic noise, but where will you be publishing 
your articles since Dr.Dobbs has closed?


Sorry if you have answered this elsewhere.


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread DaveG via Digitalmars-d
On Saturday, 10 January 2015 at 18:31:18 UTC, Paolo Invernizzi 
wrote:

On Saturday, 10 January 2015 at 17:31:42 UTC, DaveG wrote:
On Saturday, 10 January 2015 at 13:19:19 UTC, Martin Nowak 
wrote:
Here is a sketch for an optimal solution. I'm actually 
eagerly waiting that someone finally implements it.


http://dpaste.dzfl.pl/cd375ac594cf


I would also have to sell the idea of writing an ORM which is 
certainly not on the roadmap, but this will certainly help my 
argument.


Maybe not, something simpler than a full ORM should be 
compelling also.


I guess you know about the ORM Vietnam [1], but also this [2] 
can be of some help in selling a simple D solution.


I would like to see, someday, something in D that:

 - can check at compile time the syntax of SQL;
 - can check at compile time the SQL query statement against 
the current DB schema;
 - can read the output of a DB schema dump at CT, and parse it 
into what is needed for the previous points (more complicated);


The first point should be easy today, the second and the last 
one involve more work...


[1] 
http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx

[2] http://wozniak.ca/what-orms-have-taught-me-just-learn-sql
---
Paolo


I have no intention of writing anything as massive as Entity 
Framework or Hibernate. We have been successful over the past 4 
years with just a small collection of functions to reduce some of 
the pain (and redundancy) in writing a lot of dynamic SQL. Now 
that we have an opportunity to start fresh we have a chance to do 
something better.


The traditional problems with ORMs in general are well known and 
these are the reasons why I have never used one in production.


1. Complexity. You basically need to learn an entire new language 
(sometimes literally). This is an investment which can be worth 
it if the abstraction is successful. The following problems are 
why I think the investment is not worth it.


2. Limitations. Unfortunately too often you need to drop in to 
SQL to really get things done. This alone is a non-starter. If I 
need to bypass the abstraction to do anything really interesting 
or complex, it has failed. Sometimes (usually) this is for 
performance, other times it's because there is simply no way (or 
it's too complicated) to express what I want through the 
abstraction.


3. Compilation/Translation. The time to translate commands to SQL 
(or whatever backend) can be a high price. Most ORMs do some type 
of caching now which is generally sufficient. In D most of the 
work can be done at compile time which is even better.


4. Unnecessary Data. Greedy data retrieval is way to common, the 
default is usually to get everything. For small queries and data 
sets you can write it off as not a problem, but when your model 
gets large and interconnects, this can be catastrophic. Again, 
thanks Martin for the clever basis for a solution in D.


5. DB Performance. The efficiency of the SQL that is actually 
generated. People seem to focus on this because the generated SQL 
is generally quite verbose. Interestingly, in my experience, this 
is often the smallest performance problem because the query 
optimizer (at least in SQL Server with good indexes and 
statistics) will generate the same execution plan regardless. 
This is also a code gen problem that can be tweaked without 
breaking user code.


You may have noticed that 4 of 5 problems are about performance. 
That's because, at least in our case, it is that important and it 
is that much of a problem. Current ORMs often look great, but in 
my experience, the price is always to high. Some micro-ORMs 
avoid the performance problems, but they do so by sacrificing 
most of the features (you still have to write raw SQL for 
example). Some of the problems are inherit to solution and cannot 
be solved, but they can be reduced.


For a long time I thought some of these problems where 
fundamental and had basically written off the concept of ORMs 
[see: Vietnam of Computer Science]. The good news is most of the 
problems appear to be solvable.
#1 is unavoidable obviously there will be something new (whether 
it's a DSL or just an API)

#2 is really dependent on the other problems and implementation.
#3 is just implementation.
#4 has a conceptual solution, now it's just implementation.
#5 does not have a solution because it will depend on the 
backend, but I think it's reasonable to expect a solution that 
works for almost all cases. It will be impossible to know without 
testing.


One final note. You may have noticed I didn't mention the schema 
syncing problem (keeping database and code in sync). There was a 
time I would have said that was essential and while it would be 
nice in a perfect world, I'm comfortable keeping them in sync 
manually (or semi-manual with scripts). I can generate a bunch of 
classes from an existing database fairly easily and when I change 
a table I can manually update a class. If I was writing SQL 
directly 

Re: Is anyone working on a D source code formatting tool?

2015-01-10 Thread Jacob Carlborg via Digitalmars-d

On 2015-01-10 21:17, Walter Bright wrote:

Has someone made a dfmt, like http://gofmt.com/ ?


I have thought about it a couple of times but never started. It would be 
really nice to have.


--
/Jacob Carlborg


Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Jacob Carlborg via Digitalmars-d

On 2015-01-10 18:31, DaveG wrote:


Oh, we will also need a good SQL Server library which, to my knowledge,
D is lacking. This is going to be a hard sell...


That would be FreeTDS [1] with D bindings [2]. Unless Microsoft have 
headers available for interfacing with SQL Server.


[1] http://www.freetds.org/
[2] https://github.com/jacob-carlborg/dstep

--
/Jacob Carlborg


Re: Is anyone working on a D source code formatting tool?

2015-01-10 Thread weaselcat via Digitalmars-d

On Saturday, 10 January 2015 at 20:18:03 UTC, Walter Bright wrote:

Has someone made a dfmt, like http://gofmt.com/ ?


Uncrustify claims D support.
http://uncrustify.sourceforge.net/


Re: endsWith - for a string vs an array of strings

2015-01-10 Thread FG via Digitalmars-d-learn

On 2015-01-10 at 21:58, bearophile wrote:

Needles is not an array type, it's a type tuple, so withOneOfThese doesn't 
accept an array of strings. [...]
So if you really want to pack the strings in some kind of unity, you can do 
this as workaround: [...]


I would suggest create a function that does the same thing as endsWith(Range, 
Needles...) but instead of Needles expanded as a list of arguments it takes in 
a range of them. In fact I was surprised that there was no such function in 
std.algorithm present. Therefore I have written endsWithAny for this purpose a 
moment ago. Is it any good? Please correct if necessary.




import std.array;
import std.string;
import std.stdio;
import std.range;

uint endsWithAny(alias pred = a == b, Range, Needles)(Range haystack, Needles 
needles)
if (isBidirectionalRange!Range  isInputRange!Needles 
is(typeof(.endsWith!pred(haystack, needles.front)) : bool))
{
foreach (i, e; needles)
if (endsWith!pred(haystack, e))
return i + 1;
return 0;
}


void main(string[] args)
{
string[] test = [1, two, three!];
auto a = arghtwo.endsWithAny(test);
writefln(%s, a);
}

unittest
{
string[] hs = [no-one, thee, there were three, two];
string[] tab = [one, two, three];
assert(endsWithAny(hs[0], tab) == 1);
assert(endsWithAny(hs[1], tab) == 0);
assert(endsWithAny(hs[2], tab) == 3);
assert(endsWithAny(hs[3], tab) == 2);
}


Re: Phobos Contributor Tutorial

2015-01-10 Thread Craig Dillabaugh via Digitalmars-d
On Saturday, 10 January 2015 at 19:08:07 UTC, Ulrich Küttler 
wrote:

Hi,

with one phobos PR accepted any a second one submitted, I feel 
it is about time I write a tutorial. No, seriously, I spend 
some time to get started. Others might have a rough time, too. 
So here is a draft of a contributor tutorial. Posix based.


https://gist.github.com/kuettler/e907e51c14f7255e3489#file-phobos_contributor_tutorial-md

All of it is taken from the wiki, of course.


Thanks for taking the time to put that together. By it is taken 
from the Wiki did you mean individual parts are taken from the 
wiki, or the whole thing?


If you compiled a bunch of steps from the Wiki, perhaps you could 
add what you've done to the Wiki, might get more views there.


endsWith - for a string vs an array of strings

2015-01-10 Thread Laeeth Isharc via Digitalmars-d-learn
I understand from previous discussion there is some difficulty 
over immutability.  I did not quite figure out what the solution 
was in this case:


import std.array;
import std.string;
import std.stdio;
void main(string[] args)
{
string[] test=[1,two,three!];
auto a=arghtwo.endsWith(test);
writefln(%s,a);
}

This does not compile...

test.d(7): Error: template std.algorithm.endsWith cannot deduce 
function from argument types !()(string, string[]), candidates 
are:
/usr/include/dmd/phobos/std/algorithm.d(6143):
std.algorithm.endsWith(alias pred = a == b, Range, 
Needles...)(Range doesThisEnd, Needles withOneOfThese) if 
(isBidirectionalRange!Range  Needles.length  1  
is(typeof(.endsWith!pred(doesThisEnd, withOneOfThese[0])) : bool) 
 is(typeof(.endsWith!pred(doesThisEnd, 
withOneOfThese[1..__dollar])) : uint))
/usr/include/dmd/phobos/std/algorithm.d(6210):
std.algorithm.endsWith(alias pred = a == b, R1, R2)(R1 
doesThisEnd, R2 withThis) if (isBidirectionalRange!R1  
isBidirectionalRange!R2  
is(typeof(binaryFun!pred(doesThisEnd.back, withThis.back)) : 
bool))
/usr/include/dmd/phobos/std/algorithm.d(6237):
std.algorithm.endsWith(alias pred = a == b, R, E)(R 
doesThisEnd, E withThis) if (isBidirectionalRange!R  
is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool))



Thanks.


Laeeth.


Re: Discussion on groupBy

2015-01-10 Thread Orvid King via Digitalmars-d

On Saturday, 10 January 2015 at 20:19:14 UTC, Andrei
Alexandrescu wrote:
groupBy is an important primitive for relational algebra 
queries on data. Soon to follow are operators such as 
aggregate() which is a sort of reduce() but operating on ranges 
of ranges. With those in tow, a query such as


SELECT COUNT(*), SUM(x) FROM data GROUP BY userid

can be expressed as:

data
 .groupBy!((a, b) = a.userid == b.userid)
 .aggregate(count, (a, b) = a.x + b.x);

We're working the kinks out groupBy now. Those interested 
please follow at https://issues.dlang.org/show_bug.cgi?id=13936.


It would be interesting if we could make it possible to do a 
translation between D and SQL, similar to how LINQ is implemented 
internally, but preferably have it done at compile-time rather 
than at runtime.


Re: Phobos Contributor Tutorial

2015-01-10 Thread via Digitalmars-d
On Saturday, 10 January 2015 at 19:24:03 UTC, Craig Dillabaugh 
wrote:
Thanks for taking the time to put that together. By it is 
taken from the Wiki did you mean individual parts are taken 
from the wiki, or the whole thing?


I got it together (to the extend that I did) using the wiki. The 
information is all there. Actually, the wiki contains a lot more 
and this is where it gets a little complicated. It is not that 
easy to create your first PR.


Now, I am all for putting the thing in the wiki, posting it on 
all the right forms, extending and correcting it, as long as it 
is useful. Right now it is not to be taken too seriously.


Re: D idioms list

2015-01-10 Thread Walter Bright via Digitalmars-d-announce

On 1/8/2015 2:21 AM, ponce wrote:

I've started a list of curated D tips and tricks here:
http://p0nce.github.io/d-idioms/

Anything that you wished you learned earlier at one point in the D world is
welcome to be added or suggested.



My contribution:

http://digitalmars.com/articles/b68.html

(Member function pointers in D)


Re: Is anyone working on a D source code formatting tool?

2015-01-10 Thread Walter Bright via Digitalmars-d

On 1/10/2015 12:17 PM, Walter Bright wrote:

Has someone made a dfmt, like http://gofmt.com/ ?


Next question - standalone tool, or built in to dmd (like Ddoc)?

BTW, I think dfmt would be a significant win for D:

1. people expect this sort of thing these days
2. it tends to end bikeshedding arguments about the right way to format things
3. it'll help standardize the format of D code in the D repositories
4. it's simply nice and convenient!
5. it's a great first step when you're faced with fixing someone else's crap 
code

I don't think it'll be hard to do as a builtin feature of dmd.

My only concern about it is if dfmt is changed, then we get faced with a 
blizzard of changes in the D github repositories.


Re: Any upgrades planned for D forums?

2015-01-10 Thread Tobias Pankrath via Digitalmars-d

On Saturday, 10 January 2015 at 22:29:42 UTC, bitwise wrote:

I'm curious if there are any upgrades coming in the near future.


Although this is not directly an answer to your question, I just 
want to make sure you are aware of it:


The forum is a front-end to a newsgroup. A news reader or email 
client might have the features you want (including custom styling 
to your preferences).


Re: For those ready to take the challenge

2015-01-10 Thread Vladimir Panteleev via Digitalmars-d-learn

On Saturday, 10 January 2015 at 14:56:09 UTC, Adam D. Ruppe wrote:

On Saturday, 10 January 2015 at 13:22:57 UTC, Nordlöw wrote:

on dmd git master. Ideas anyone?


Don't use git master :P


Do use git master. The more people do, the fewer regressions will 
slip into the final release.


You can use Dustmite to reduce the code to a simple example, and 
Digger to find the exact pull request which introduced the 
regression. (Yes, shameless plug, preaching to the choir, etc.)


Re: DConf 2015 Call for Submissions is now open

2015-01-10 Thread Andrei Alexandrescu via Digitalmars-d-announce

On 1/10/15 8:15 AM, Iain Buclaw via Digitalmars-d-announce wrote:

In any event, are you doing flash talks this year?  I don't think I
could find something to spend more than 15 minutes talking about this
year.


Yes. -- Andrei



Re: DConf 2015 Call for Submissions is now open

2015-01-10 Thread Walter Bright via Digitalmars-d-announce

On 1/10/2015 9:50 AM, Andrei Alexandrescu wrote:

On 1/10/15 9:49 AM, Andrei Alexandrescu wrote:

On 1/10/15 8:15 AM, Iain Buclaw via Digitalmars-d-announce wrote:

In any event, are you doing flash talks this year?  I don't think I
could find something to spend more than 15 minutes talking about this
year.


Yes. -- Andrei


I should add that gdc is a topic of much interest so pretty much anything you
say would be interesting. I compel you to prepare a full talk. -- Andrei



I agree. There's no way you don't have interesting things to talk about! For 
example, what is your process for integrating dmd changes into gdc? What are the 
advantages/disadvantages of gdc? What are the biggest challenges you face 
working on gdc? What's the hardest problem you solved with gdc? How can others 
help out? Etc.


Re: Is anyone working on a D source code formatting tool?

2015-01-10 Thread Tobias Pankrath via Digitalmars-d

On Saturday, 10 January 2015 at 22:11:55 UTC, Walter Bright wrote:

On 1/10/2015 12:17 PM, Walter Bright wrote:

Has someone made a dfmt, like http://gofmt.com/ ?


Next question - standalone tool, or built in to dmd (like Ddoc)?

My only concern about it is if dfmt is changed, then we get 
faced with a blizzard of changes in the D github repositories.


Build it into DMD with an option to change files in place or dump 
them to stdout. I do think though, this would require a pragma or 
a special comment to disable it for parts of code. There will 
always be the case where the standard is wrong.


Re: DConf 2015 Call for Submissions is now open

2015-01-10 Thread Andrei Alexandrescu via Digitalmars-d-announce

On 1/10/15 9:49 AM, Andrei Alexandrescu wrote:

On 1/10/15 8:15 AM, Iain Buclaw via Digitalmars-d-announce wrote:

In any event, are you doing flash talks this year?  I don't think I
could find something to spend more than 15 minutes talking about this
year.


Yes. -- Andrei


I should add that gdc is a topic of much interest so pretty much 
anything you say would be interesting. I compel you to prepare a full 
talk. -- Andrei




Re: Is it possible to collect object usage information during compilation?

2015-01-10 Thread Paolo Invernizzi via Digitalmars-d

On Saturday, 10 January 2015 at 17:31:42 UTC, DaveG wrote:
On Saturday, 10 January 2015 at 13:19:19 UTC, Martin Nowak 
wrote:
Here is a sketch for an optimal solution. I'm actually eagerly 
waiting that someone finally implements it.


http://dpaste.dzfl.pl/cd375ac594cf


I would also have to sell the idea of writing an ORM which is 
certainly not on the roadmap, but this will certainly help my 
argument.


Maybe not, something simpler than a full ORM should be compelling 
also.


I guess you know about the ORM Vietnam [1], but also this [2] can 
be of some help in selling a simple D solution.


I would like to see, someday, something in D that:

 - can check at compile time the syntax of SQL;
 - can check at compile time the SQL query statement against the 
current DB schema;
 - can read the output of a DB schema dump at CT, and parse it 
into what is needed for the previous points (more complicated);


The first point should be easy today, the second and the last one 
involve more work...


[1] 
http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx

[2] http://wozniak.ca/what-orms-have-taught-me-just-learn-sql
---
Paolo



Re: For those ready to take the challenge

2015-01-10 Thread via Digitalmars-d-learn

On Saturday, 10 January 2015 at 17:39:17 UTC, Adam D. Ruppe wrote:
Though, that's still a library thing rather than a language 
thing.


It is a language-library-platform thing, things like how 
composable the eco system is would be interesting to compare. But 
it would be unfair to require a minimalistic language to not use 
third party libraries. One should probably require that the 
library used is generic (not a spider-framework), not using FFI, 
mature and maintained?



document.parseGarbage(response.contentText);

// Uri.basedOn returns a new absolute URI based on 
something else

foreach(a; document.querySelectorAll(a[href]))
writeln(Uri(a.href).basedOn(base));
}



Nice and clean code; does it expand html entities (amp)?

The HTML5 standard has improved on HTML4 by now being explicit on 
how incorrect documents shall be interpreted in section 8.2. That 
ought to be sufficient, since that is what web browsers are 
supposed to do.


http://www.w3.org/TR/html5/syntax.html#html-parser


Re: Phobos Contributor Tutorial

2015-01-10 Thread Vlad Levenfeld via Digitalmars-d
On Saturday, 10 January 2015 at 19:08:07 UTC, Ulrich Küttler 
wrote:

Hi,

with one phobos PR accepted any a second one submitted, I feel 
it is about time I write a tutorial. No, seriously, I spend 
some time to get started. Others might have a rough time, too. 
So here is a draft of a contributor tutorial. Posix based.


https://gist.github.com/kuettler/e907e51c14f7255e3489#file-phobos_contributor_tutorial-md

All of it is taken from the wiki, of course.


Thanks! This is very useful.


Re: GSOC - Holiday Edition

2015-01-10 Thread Craig Dillabaugh via Digitalmars-d




8) Russel Winder and QML ... see #4.


Should we drop QML support from our GSOC due to:

http://forum.dlang.org/thread/hapeegrotkazppwdn...@forum.dlang.org





Re: Any upgrades planned for D forums?

2015-01-10 Thread bitwise via Digitalmars-d
Guess it's not so great when your OS doesn't have a package 
manager that uses signed packages though.

: )


Welll Some people seem to love the terminal, but in all 
honesty, if it wasnt' for Mono-D, I would not have taken the time 
to learn D.




Re: Any upgrades planned for D forums?

2015-01-10 Thread bitwise via Digitalmars-d
Welll Some people seem to love the terminal, but in all 
honesty, if it wasnt' for Mono-D, I would not have taken the 
time to learn D.


Not to say that I'm not glad I did learn D, but I don't imagine 
anyone wanting to learn D would just take it on full throttle 
without first experimenting with it in their spare(most likely 
limited) time.


As far as the above suggestions go, I would ask if I could 
contribute the changes myself, but where it would take me hours, 
or possibly days to get involved with the source for the D forum, 
there is probably someone out there who's got it opened on their 
other monitor right now =)


Re: Game development

2015-01-10 Thread ketmar via Digitalmars-d
On Sat, 10 Jan 2015 23:13:28 +
dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:

 On Saturday, 10 January 2015 at 20:59:20 UTC, ketmar via 
 Digitalmars-d wrote:
  On Sat, 10 Jan 2015 16:03:22 +
  dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:
  
  You are **proud** to draw the attention of nerdy middle aged 
  men...
  ah, sure. it's always funny to see some old jerk having nothing 
  more to
  do than running around whining how old is he. i'm enjoying 
  collecting
  perverts, you know.
 
 So lets get this straight...
 
 1. I reply to you for maybe the third time and you think I am 
 your own personal fan club.
 2. You are proud to draw the attention of old men because it's 
 fun to listen to them moan.
 3. You enjoy collecting perverts.
 
 I'm almost too embarrassed to troll someone who seems unable to 
 shoot anything but his own foot.
 
 *almost* :-)
ah, so that was trolling? i'm so sorry... i was thinking that you're
just a lonely old man and have noone to talk with. or i just can't
realise that shitting their own pants is what they call trolling this
times... o tempora, o mores...


signature.asc
Description: PGP signature


Re: Any upgrades planned for D forums?

2015-01-10 Thread weaselcat via Digitalmars-d

On Saturday, 10 January 2015 at 22:29:42 UTC, bitwise wrote:

...
-The way quotes are displayed is tough on the eyes. Rather than 
having the quotes grayed out and crowded by angle brackets, I 
would prefer something like stackoverflow where the text was 
black, but on a gray background, possibly with black outlines 
for nested quotes.


Overall I find the site kind of tough on my eyes, I use a stylish 
theme to help.


https://userstyles.org/styles/65395/dlang-org-dark-theme


Re: Any upgrades planned for D forums?

2015-01-10 Thread weaselcat via Digitalmars-d

On Saturday, 10 January 2015 at 23:18:25 UTC, bitwise wrote:
Userstyles is a site for Stylish themes, it's an open source 
extension for most browsers released under GPLv3.


So is Filezilla...but would you care to download a copy? ;)

http://sourceforge.net/projects/filezilla/files/FileZilla_Client/3.10.0/


Sure!
pacman -S filezilla

Guess it's not so great when your OS doesn't have a package 
manager that uses signed packages though.

: )


Re: Traits and functions

2015-01-10 Thread Ali Çehreli via Digitalmars-d-learn

On 01/10/2015 08:21 AM, Bauss wrote:

Is there a way to get all functions within a module using traits? I
tried allMembers and it seem to work, but I can't use
getFunctionAttributes with it and if I use getAttributes then it
won't find any applied attributes.

What I do is having a package module with a staic constructor which
loops through allMembers and then I want to find functions with a
specific attribute. All the members are imported using public imports.
However it can find the specific functions, but it does not find the
attributes.


The following program prints both the function attributes and user 
defined attributes e.g. of foo():


module deneme;

import std.string;
import std.traits;

struct MyAttr
{}

@MyAttr
void foo(int i, double d) pure @nogc nothrow @property
{}

void main()
{
foreach (m; __traits(allMembers, deneme)) {
pragma(msg, format(module member: %s, m));

static if (mixin (isCallable! ~ m)) {
pragma(msg, format(%s is callable, m));

foreach (funcAttr;
 mixin (format(__traits(getFunctionAttributes, 
%s), m))) {

pragma(msg, format(  function attribute: %s, funcAttr));
}

foreach (attr; mixin (format(__traits(getAttributes, %s), 
m))) {

static if (is (attr == MyAttr)) {
pragma(msg, format(  uda: %s, attr.stringof));
}
}
}
}
}

Ali



Re: endsWith - for a string vs an array of strings

2015-01-10 Thread bearophile via Digitalmars-d-learn

Laeeth Isharc:

In D there is a feature that allows a function to accept both 
an array of items and items,


yes - it is funny there is not an overloading that accepts 
arrays


I meant this D feature:


void foo(T)(T[] items...) {
import std.stdio;
items.writeln;
}
void main() {
foo(red, green, blue);
foo([red, green, blue]);
auto a = [red, green, blue];
foo(a);
}


Bye,
bearophile


Re: NaCl/Emscripten

2015-01-10 Thread via Digitalmars-d
On Sunday, 11 January 2015 at 01:05:59 UTC, Manu via 
Digitalmars-d wrote:
The thing about cheerp vs emscripten, is that while cheerp 
produces
code that is more like javascript, emscripten produces asm.js, 
which

is lightning fast by comparison.
If there's actual work being done, then emscripten is the 
choice, if

it's just as a substitute for writing js code, because it's a
nightmare, then cheerp is probably better.


You are probably right about throughput which I would expect to 
be better with Emscripten than Cheerp, although keep in mind that 
only Firefox converts asm.js directly to asm without the regular 
JIT. IE and Chrome uses the regular JIT AFAIK.


With asm.js you are also stuck with a fixed size heap and if you 
manage to implement GC on asm.js, you get the freeze... Then you 
have interop with JS. Not sure if you can interact with 
Worker-threads within asm.js?


I had not heard of Cheerp until today, but it looks interesting 
to me.




Re: Is this visible to all?

2015-01-10 Thread MattCoder via Digitalmars-d
On Sunday, 11 January 2015 at 03:36:20 UTC, Andrei Alexandrescu 
wrote:
Some links on github are only visible to admins/committers. Is 
this available to all?


https://github.com/pulls?user=D-Programming-Language


Yes!

Matheus.


Re: multidimensional interface generator

2015-01-10 Thread bearophile via Digitalmars-d

Vlad Levenfeld:

	auto tex1 = ℕ[0..100].by (ℕ[0..100]).map!((i,j) = (i+j)%2? 
red: yellow).Texture;
	auto tex2 = ℕ[0..50].by (ℕ[0..50]).map!((i,j) = (i+j)%2? 
blue: green).grid (100,100).Texture;


tex1[50..75, 25..75] = tex2[0..25, 0..50];


The library seems nice, but I don't like Unicode identifiers.



mostly workarounds for dmd bugs;


Are those bugs in Bugzilla?

Bye,
bearophile


Re: Is anyone working on a D source code formatting tool?

2015-01-10 Thread Shammah Chancellor via Digitalmars-d

On 2015-01-10 20:17:34 +, Walter Bright said:


Has someone made a dfmt, like http://gofmt.com/ ?


No, I was planning on working on one if we ever got libd parsing 100% 
of the code.Unfortunately I haven't had a lot of time to work on 
these sorts of things lately.


-Shammah



Re: multidimensional interface generator

2015-01-10 Thread Vlad Levenfeld via Digitalmars-d

On Saturday, 10 January 2015 at 22:56:28 UTC, bearophile wrote:

The library seems nice, but I don't like Unicode identifiers.
Understandable, I'll change N to Nat and R to Real or something 
and just make unicode aliases in my own code.



Are those bugs in Bugzilla?


They are, I tag them with // BUG followed by the url to the 
bugzilla issue, so when I get an email about a fix I can grep for 
them and clean up.


Re: Discussion on groupBy

2015-01-10 Thread Laeeth Isharc via Digitalmars-d
It would be interesting if we could make it possible to do a 
translation between D and SQL, similar to how LINQ is 
implemented internally, but preferably have it done at 
compile-time rather than at runtime.


Have you seen Hibernated?
https://github.com/buggins/hibernated


Re: Wrapping a C library with its own GC + classes vs refcounted structs

2015-01-10 Thread aldanor via Digitalmars-d-learn

On Saturday, 10 January 2015 at 20:55:05 UTC, Laeeth Isharc wrote:

Hi Aldanor.

I wrote a slightly longer reply, but mislaid the file somewhere.

I guess your question might relate to wrapping the HDF5 library 
- something that I have already done in a basic way, although I 
welcome your project, as no doubt we will get to a higher 
quality eventual solution that way.


One question about accurately representing the HDF5 object 
hierarchy.  Are you sure you wish to do this rather than 
present a flattened approach oriented to what makes sense to 
make things easy for the user in the way that is done by h5py 
and pytables?


In terms of the actual garbage generated by this library - 
there are lots of small objects.  The little ones are things 
like a file access attribute, or a schema for a dataset.  But 
really the total size taken up by the small ones is unlikely to 
amount to much for scientific computing or for quant finance if 
you have a small number of users and are not building some kind 
of public web server.  I think it should be satisfactory for 
the little objects just to wrap the C functions with a D 
wrapper and rely on the object destructor calling the C 
function to free memory.  On the rare occasions when not, it 
will be pretty obvious to the user and he can always call 
destroy directly.


For the big ones, maybe reference counting brings enough value 
to be useful - I don't know.  But mostly you are either passing 
data to HDF5 to write, or you are receiving data from it.  In 
the former case you pass it a pointer to the data, and I don't 
think it keeps it around.  In the latter, you know how big the 
buffer needs to be, and you can just allocate something from 
the heap of the right size (and if using reflection, type) and 
use destroy on it when done.


So I don't have enough experience yet with either D or HDF5 to 
be confident in my view, but my inclination is to think that 
one doesn't need to worry about reference counting.  Since 
objects are small and there are not that many of them, relying 
on the destructor to be run (manually if need be) seems likely 
to be fine, as I understand it.  I may well be wrong on this, 
and would like to understand the reasons if so.







Laeeth.
Thanks for the reply. Yes, this concerns my HDF5 wrapper project; 
the main concern is not that the memory consumption of course, 
but rather explicitly controlling lifetimes of the objects 
(especially objects like files -- so you are can be sure there 
are no zombie handles floating around). Most of the time when 
you're doing some operations on an HDF5 file you want all handles 
to get closed by the time you're done (i.e. by the time you leave 
the scope) which feels natural (e.g. close groups, links etc). 
Some operations in HDF5, particularly those related to 
linking/unlinking/closing may behave different if an object has 
any chilld objects with open handles. In addition to that, the C 
HDF5 library retains the right to reuse both the memory and id 
once the refcount drops to zero so it's best to be precise about 
that and keep a registry of weak references to all C ids that D 
knows about (sort of the same way as h5py does in Python).




Re: Any upgrades planned for D forums?

2015-01-10 Thread bitwise via Digitalmars-d

Filters or some form of moderation would also be nice.


Re: Game development

2015-01-10 Thread dajones via Digitalmars-d
On Sunday, 11 January 2015 at 00:44:00 UTC, ketmar via 
Digitalmars-d wrote:

On Sat, 10 Jan 2015 23:13:28 +
dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:

On Saturday, 10 January 2015 at 20:59:20 UTC, ketmar via 
Digitalmars-d wrote:

 On Sat, 10 Jan 2015 16:03:22 +
 dajones via Digitalmars-d digitalmars-d@puremagic.com 
 wrote:
 
 You are **proud** to draw the attention of nerdy middle 
 aged men...
 ah, sure. it's always funny to see some old jerk having 
 nothing more to
 do than running around whining how old is he. i'm enjoying 
 collecting

 perverts, you know.

So lets get this straight...

1. I reply to you for maybe the third time and you think I am 
your own personal fan club.
2. You are proud to draw the attention of old men because it's 
fun to listen to them moan.

3. You enjoy collecting perverts.

I'm almost too embarrassed to troll someone who seems unable 
to shoot anything but his own foot.


*almost* :-)

ah, so that was trolling?


You keep taking the bait.



i'm so sorry... i was thinking that you're
just a lonely old man and have noone to talk with.


When you have self professed fantasies about collecting dirty old 
men you will probably start imagining them everywhere you go.




or i just can't
realise that shitting their own pants is what they call 
trolling this

times... o tempora, o mores...


shitting their own pants

Your wit knows no bounds.


Re: Any upgrades planned for D forums?

2015-01-10 Thread bitwise via Digitalmars-d
Overall I find the site kind of tough on my eyes, I use a 
stylish theme to help.


https://userstyles.org/styles/65395/dlang-org-dark-theme


I am getting more and more weary of downloading software these 
days unless it's very well known. I almost got infected by 
malware yesterday by SourceForge of all places..


Re: Game development

2015-01-10 Thread dajones via Digitalmars-d
On Saturday, 10 January 2015 at 20:59:20 UTC, ketmar via 
Digitalmars-d wrote:

On Sat, 10 Jan 2015 16:03:22 +
dajones via Digitalmars-d digitalmars-d@puremagic.com wrote:


You are **proud** to draw the attention of nerdy middle aged 
men...
ah, sure. it's always funny to see some old jerk having nothing 
more to
do than running around whining how old is he. i'm enjoying 
collecting

perverts, you know.


So lets get this straight...

1. I reply to you for maybe the third time and you think I am 
your own personal fan club.
2. You are proud to draw the attention of old men because it's 
fun to listen to them moan.

3. You enjoy collecting perverts.

I'm almost too embarrassed to troll someone who seems unable to 
shoot anything but his own foot.


*almost* :-)



Re: Traits and functions

2015-01-10 Thread Bauss via Digitalmars-d-learn

On Saturday, 10 January 2015 at 23:23:52 UTC, Ali Çehreli wrote:

On 01/10/2015 08:21 AM, Bauss wrote:
Is there a way to get all functions within a module using 
traits? I

tried allMembers and it seem to work, but I can't use
getFunctionAttributes with it and if I use getAttributes 
then it

won't find any applied attributes.

What I do is having a package module with a staic constructor 
which
loops through allMembers and then I want to find functions 
with a
specific attribute. All the members are imported using public 
imports.
However it can find the specific functions, but it does not 
find the

attributes.


The following program prints both the function attributes and 
user defined attributes e.g. of foo():


module deneme;

import std.string;
import std.traits;

struct MyAttr
{}

@MyAttr
void foo(int i, double d) pure @nogc nothrow @property
{}

void main()
{
foreach (m; __traits(allMembers, deneme)) {
pragma(msg, format(module member: %s, m));

static if (mixin (isCallable! ~ m)) {
pragma(msg, format(%s is callable, m));

foreach (funcAttr;
 mixin 
(format(__traits(getFunctionAttributes, %s), m))) {
pragma(msg, format(  function attribute: %s, 
funcAttr));

}

foreach (attr; mixin 
(format(__traits(getAttributes, %s), m))) {

static if (is (attr == MyAttr)) {
pragma(msg, format(  uda: %s, 
attr.stringof));

}
}
}
}
}

Ali


Thank you this was exactly what I was looking for!


Re: NaCl/Emscripten

2015-01-10 Thread Manu via Digitalmars-d
On 11 January 2015 at 01:31, via Digitalmars-d
digitalmars-d@puremagic.com wrote:
 There are also other compilers from C++ to Javascript, Mandreel and Cheerp.

 Cheerp claims to support the builtin Javascript garbage collector:

 «Dynamic memory management. C++ objects are translated directly to JS
 objects, without the proxy of an emulated, flat memory space. Allow your
 applications to exploit the JavaScript VM garbage collector and co-exist
 with fair, on-demand memory allocation.»

 http://www.leaningtech.com/cheerp/blog/

 So if Cheerp is ready for production (I don't know if it is), it might be a
 better fit for D.

The thing about cheerp vs emscripten, is that while cheerp produces
code that is more like javascript, emscripten produces asm.js, which
is lightning fast by comparison.
If there's actual work being done, then emscripten is the choice, if
it's just as a substitute for writing js code, because it's a
nightmare, then cheerp is probably better.



Is this visible to all?

2015-01-10 Thread Andrei Alexandrescu via Digitalmars-d
Some links on github are only visible to admins/committers. Is this 
available to all?


https://github.com/pulls?user=D-Programming-Language

Andrei


Re: Is this visible to all?

2015-01-10 Thread Adam D. Ruppe via Digitalmars-d

 i can see it


Re: Thoughts on replacement languages (Reddit + D)

2015-01-10 Thread MattCoder via Digitalmars-d
PS: I'm not posting this to see any flamewar between languages 
there, but maybe some could enlighten the discussion with some 
nice facts.


Matheus.


  1   2   >