Image of D code on Norwegian IT news site

2016-08-31 Thread simendsjo via Digitalmars-d
An article about how outsourcing reduces the need for Norwegian 
developers. No links to D other than the image on top though. I 
wonder what they searched for to find this image.


http://www.digi.no/artikler/rader-norske-it-folk-til-a-droppe-programmering/279380



Re: alias overloading strange error

2015-07-31 Thread simendsjo via Digitalmars-d-learn

On Friday, 31 July 2015 at 10:56:33 UTC, vitus wrote:

//Why expression 'foobar(1);' doesn't work?


void foo()(){}
void bar(int){}

alias foobar = foo;
alias foobar = bar;

void main(){
.foobar(1); //OK
foobar(1);  //Error: overload alias 'foo' is not a variable

}


foo is a template, while bar is a function. I would have thought 
the `.foobar(1)` should have failed too... Must be some strange 
lookup rules I don't know about (or a dmd bug).

`alias foobar = foo!();` should make it work in both cases though.


No Unix socket support?

2015-07-29 Thread simendsjo via Digitalmars-d-learn
Is there no Unix socket support in Phobos? Or vibe? Or any other 
library?

I've found some discussions:
* https://issues.dlang.org/show_bug.cgi?id=9384
* 
http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/10870/


, but it seems there are no support yet.


Re: GC stats

2015-07-26 Thread simendsjo via Digitalmars-d-learn

On Sunday, 26 July 2015 at 14:16:46 UTC, Gary Willoughby wrote:

On Saturday, 25 July 2015 at 17:43:44 UTC, Martin Nowak wrote:
On Saturday, 25 July 2015 at 17:34:26 UTC, Márcio Martins 
wrote:
What I want is a clean non-intrusive way to log when a 
collection happened, how long my threads were stopped, how 
much total memory and how many blocks were recovered. i.e. 
how much garbage was created in between collections. Are 
there any hooks on the runtime?


http://dlang.org/changelog.html#gc-options
https://github.com/D-Programming-Language/druntime/blob/1e25749cd01ad08dc08319a3853fbe86356c3e62/src/rt/config.d#L14


I thought there is a recently added compiler option that 
profiles the GC and creates a report now?


Should be included in 2.068 I think:
https://github.com/D-Programming-Language/druntime/blob/1e25749cd01ad08dc08319a3853fbe86356c3e62/src/rt/profilegc.d#L3


Why hide a trusted function as safe?

2015-07-26 Thread simendsjo via Digitalmars-d-learn
Is there a reason why you would hide the fact that a function is 
trusted rather than safe? Technically it doesn't matter, right? 
To me, it seems like this would give wrong assumptions to the 
caller.


The reason I ask is because I found the following in 
std.concurrency:


@property Tid thisTid() @safe
{
// TODO: remove when concurrency is safe
auto trus = delegate() @trusted
{
if( thisInfo.ident != Tid.init )
return thisInfo.ident;
thisInfo.ident = Tid( new MessageBox );
return thisInfo.ident;
};

return trus();
}



Re: Experience upgrading template code from 2.065 to 2.067

2015-07-23 Thread simendsjo via Digitalmars-d

On Thursday, 23 July 2015 at 13:20:32 UTC, Nicholas Wilson wrote:

On Wednesday, 22 July 2015 at 15:50:13 UTC, simendsjo wrote:


// 1
template Tmlp(T) {}
// 2
template Tmpl(alias T) {}


I'm assuming thats a typo


Yes. I just wrote the code in the post without trying to compile 
it. I'm not as good at caching typos as the compiler.


Re: Rant after trying Rust a bit

2015-07-23 Thread simendsjo via Digitalmars-d

On Thursday, 23 July 2015 at 16:22:30 UTC, QAston wrote:
(... snip ...)

That's what I think simendsjo meant about ugliness.


Someone else wrote about the ugliness, not me.


Experience upgrading template code from 2.065 to 2.067

2015-07-22 Thread simendsjo via Digitalmars-d
I updated a small template-heavy experimental library mostly for 
compile-time introspection I write some time ago. The last time I 
updated the code was probably using 2.065, but might also have 
been as old as 2.063.


The code doesn't use much of the standard library, mostly parts 
of std.traits and std.typetuple.TypeTuple. While upgrading, I 
only encountered a single bug 
(https://issues.dlang.org/show_bug.cgi?id=14820), which might 
have been there for a long time as I didn't check when it was 
introduced - I hit it when adding additional unittests when I got 
weird compile-time errors.


There was however a breaking change that caused most of my 
templates to fail. My templates supports both built-in types, 
user-defined types and values. In order to do this, both 
templates of `T` and `alias T` has to be created. In previous 
versions of the compiler, user-defined types always picked the 
`alias T` version first, while the newest compiler picks `T` for 
all types.  I found the old behavior pretty weird, so I'm all in 
favor of the change though.


// 1
template Tmlp(T) {}
// 2
template Tmpl(alias T) {}

struct S {}
Tmpl!S; // 2 on 2.065 (/2.063?), 1 on 2.067

There's still an odd difference between built-in and user-defined 
types:


template OnlyAlias(alias T) {}
struct S {}
OnlyAlias!S; // works
OnlyAlias!int; // doesn't work

I also had to make some dub related changes and a simple import 
because `chain` moved from `std.algorithm` to `std.range`.


Just a little experience-report for upgrading between compiler 
versions. I'm one of the people that is pro breaking-changes.  
Keep in mind that this is a small project of just 4351 LOC where 
a lot is tests and documentation and nearly no use of phobos or 
druntime.


Anyway - happy to see breaking changes that improves the language.



Rant after trying Rust a bit

2015-07-22 Thread simendsjo via Digitalmars-d

Long rant ahead - a bit dipsy..

TL;DR: Rust has momentum, manpower and tooling. Tooling matters.  
Safe defaults.  Ergonomics like expressions and deconstructing 
rocks.


I'm reluctantly confessing that I've had a small affair with Rust 
recently. While I think D is a really good language, there are 
several things I don't agree upon. Some are caused by historical 
reasons, some are caused by the lack of peer review. Lets look at 
a couple of things I think looks exiting about Rust after a bit 
experimentation.


Manpower

Silly stating this as why I have been playing with Rust, but it's 
probably one of the main reasons. Rust has momentum and a lot of 
manpower and well as some big compinies behind it. It should be 
of secondary importance, but this is something that really shows 
in the quality of Rust.


I've been using D on and off since 2007, and the lack of manpower 
shows in every aspect of the language, design and ecosystem. Rust 
has a pretty nice ecosystem and tools given its very young age.


Cargo
-
Rust has a default package manager much like Dub. The main 
difference is that Cargo has been endorsed by the Rust team and 
is an official product. This means it works very well with the 
compiler and feels like an integrated part of the language. Dub, 
on the other hand, is a product from the outside, and 
unfortunately, it feels this way too. Having Dub become the 
endorsed package manager for D sounds like a very good idea for 
me. In order to do this, some breaking changes might be necessary 
(I haven't used much D or Dub recently though..). If so, a good 
time to introduce breaking changes would be before integrating it 
into the core D ecosystem.


The effects of Cargo is very visible by looking on the amount of 
libraries on https://crates.io as opposed to 
http://code.dlang.org.


While code.dlang.org has 530 packages, crates.io has 2610 
packages, and this is even if Rust is very new. Dubs repository 
website is a lot better than Rusts though :)


Traits
--
I think the ability to express an interface without buying into 
inheritance is the right move. The alternative in D is specifying 
the behavior as a template and verifying the contract in a 
unittest for the type.


Algebraic data types

Haven't looked into `Algebraic!`, so I won't start bashing D here 
:) But given the lack of pattern matching, I doubt it will be as 
pretty as Rust.


Macros
--
I haven't written more than extremely simple macros in Rust, but 
having macros that is possible for tools to understand is a win.  
Templates and string mixins is often used for this purpose, but 
trying to build tools when string mixins exists is probably 
extremely hard. If D had hygenic macros, I expect several 
features could be expressed with this instead of string mixins, 
making tooling easier to implement.


Safe by default
---
D is often said being safe by default, but D still has default 
nullable references and mutable by default. I don't see it being 
possible to change at this stage, but expressing when I want to 
be unsafe rather than the opposite is very nice. I end up typing 
a lot more in D than Rust because of this.


Pattern matching

Ooooh... I don't know what to say.. D should definitely look into 
implementing some pattern matching! final switch is good for 
making sure all values are handled, but deconstructing is just so 
ergonomic.


Expressions
---
This probably also falls in the too late category, but 
statements-as-expressions is really nice. `auto a = if ...` - 
why not?


Borrowing
-
This is probably the big thing that makes Rust really different.  
Everything is a resource, and resources have an owner and a 
lifetime. As a part of this, you can either have multiple aliases 
with read-only references, or a single reference with a writeable 
reference. I won't say I have a lot of experience with this, but 
it seems like it's not an extremely unergonomic trade-off. I 
cannot even remotely imagine the amount of possible compiler 
optimizations possible with this feature.




Why have I been looking at Rust?

I haven't been using D in production since 2008, which was an 
utterly disaster. I did some work on the native mysql client, but 
that was mostly making the code more D than C. Some small 
experimentations thereafter.


The constant breakage in the language and standard library 
haven't been an real issue for me as I haven't used it in 
production - the problem when I used it was partly the phobos vs 
tango with incompatible runtimes together with an extremely buggy 
compiler. On the breaking part, the real issue is the We're not 
going to break any code! stance, while each release still breaks 
every codebase. The effect is that a lot of really long-term 
necessary breaking changes is never accepted - the only breaking 
changes is the unintended breaking changes! I'm in the break-it 
camp. If you don't mind living with 

Re: Rant after trying Rust a bit

2015-07-22 Thread simendsjo via Digitalmars-d

On Wednesday, 22 July 2015 at 19:52:34 UTC, Alex Parrill wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:

Traits
--
...


You can make a `conformsToSomeInterface!T` template, and use 
`static assert`. D ranges, and the upcoming std.allocator, 
already use this sort of 'interfaces without polymorphism'.


Ex. `static assert(isInputRange!(MyCoolRange));`


Exactly. D is a lot more flexible, but looking just at
MyCoolRange, you cannot actually see it conforms to InputRange
without looking at the unittests (or wherever else the static
assert is inserted).

On Wednesday, 22 July 2015 at 19:52:34 UTC, Alex Parrill wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:

Borrowing
-
...


Look into `std.typecons.Unique`, though I've seen people 
posting that they don't like it (I haven't used it much; I had 
one use case for it, which was sending it through 
`std.concurrency.send`, but it doesn't work with that function).


I haven't actually tried to recreate the stuff that Rust does with
types in D. I expect some of it is possible, but the addition is
things like Unique (which I haven't tried). And this escalates.
You end up with `Unique!(NonNull!(MyClass))` and probably even
more type decorators.

On Wednesday, 22 July 2015 at 19:52:34 UTC, Alex Parrill wrote:
Yes, D's community is pretty small. It's not something you can 
just code; you have to market the language. And it's the 
community that creates the many tools and packages.


If I'm not mistaken, people of the D community have tried to
market the language quite heavily. I don't know why more people
haven't joined, and it's even more baffeling to see the comments
on Reddit calling D related posts spam and speaking negatively of
the marketing on a site where upvotes dictates the ranking on the
front page.



Re: Rant after trying Rust a bit

2015-07-22 Thread simendsjo via Digitalmars-d

On Wednesday, 22 July 2015 at 19:41:16 UTC, Jack Stouffer wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:
I've been using D on and off since 2007, and the lack of 
manpower shows in every aspect of the language, design and 
ecosystem. Rust has a pretty nice ecosystem and tools given 
its very young age.


Only one way to fix this. Volunteer.


Yes, I agree. I haven't done much good for the D community,
although I believe some of the code I've written for mysql native
is in production.

Let me add a point for Rust somewhat related :)

Community
-
The community is nice, helpful and doesn't condecent people.

On Wednesday, 22 July 2015 at 19:41:16 UTC, Jack Stouffer wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:

Expressions
---
This probably also falls in the too late category, but 
statements-as-expressions is really nice. `auto a = if ...` - 
why not?


Don't quite know what you mean here.


When everything is an expressions, you can write things like
auto a = if(e) c else d;

In D you have to write
type a = invalid_value;
if(e) a = c;
else  a = d;
assert(a != invalid_value);


On Wednesday, 22 July 2015 at 19:41:16 UTC, Jack Stouffer wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:

(... snip [regarding phobos/tango runtime incompatibility] ...)
The tango vs Phobos issue has been mostly settled after the 
transition from d1 to d2, and the complier is a lot better now 
than it was.


There are probably nothing in newer times that can be credited as
much pain as the incompatible runtimes of phobos and tango, but
I've still encountered a lot of compiler and phobos bugs. Yes,
it's just every 500 or so lines now, but I've only encountered
a couple of bugs in the C# compiler and a couple more in the .Net
library in several years - again credited to a lot more manpower
available.

On Wednesday, 22 July 2015 at 19:41:16 UTC, Jack Stouffer wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:
On the breaking part, the real issue is the We're not going 
to break any code! stance,


Who, in the leadership or a contributor, has ever said this.


I'm pretty sure Walter Bright has said this on a lot of occations.
He seemed to believe a failure of adoption of D was due to the
constant breaking changes, which might be true.

On Wednesday, 22 July 2015 at 19:41:16 UTC, Jack Stouffer wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:
Rust has a default package manager much like Dub. The main 
difference is that Cargo has been endorsed by the Rust team 
and is an official product. (... snip ...)
Dub is endorsed by the leadership and is included in the same 
Github organization as the complier and the standard library


I didn't know that. Very nice. I hope it's in a clean state when
it gets pulled in.

On Wednesday, 22 July 2015 at 19:41:16 UTC, Jack Stouffer wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:
While code.dlang.org has 530 packages, crates.io has 2610 
packages, (... snip ...)

I attribute this to hype. (... snip ...)


Yes, but the hype is probably driving even more developers to the
language, and I believe a large user-base is of paramount
importance for a language to become good.

On Wednesday, 22 July 2015 at 19:41:16 UTC, Jack Stouffer wrote:

On Wednesday, 22 July 2015 at 18:47:33 UTC, simendsjo wrote:

Macros
--
(... snip ...)


Maybe tooling would become easier to write, but in my personal 
experience, macros are much harder for programmers to 
understand than mixins, and much easier to abuse.


I disagree. String mixins are much easier to abuse than hygenic
macros. String mixins allows anything, and while it offers
infinite possibilities, it also encourage abuse.



Re: Rant after trying Rust a bit

2015-07-22 Thread simendsjo via Digitalmars-d

On Wednesday, 22 July 2015 at 19:54:05 UTC, Dicebot wrote:

Traits system is awesome and pure win.


Agreed.


Pattern matching is not  that game changing but helps often
enough to feel important.


The fact that you can use pattern matching many places makes it
very much a win.

if Some(InnerClass::SomeType(value)) = some_call() {
// here you can use `value`
}

Borrowship system is damn smart but totally impractical for 
most real-world cases.


I haven't used Rust enough to really have a voice on the subject.
It looks like a pardigm shift, and it might only take some getting
used to, but it might also be very difficult to use. There are
some big stuff written in Rust though - the rust compiler and the
servo browser engine. The fact that it makes a lot of errors
impossible is the exiting thing for me.


Macros are utterly horrible and pretty much unusable outside
of advanced library internals.


Not sure what you are referencing here. Macros expand to code. If
you compare this to string mixins, they are a lot easier for tool
writers, but a lot less powerful.

Recently I attended local Rust meetup for curious newcomers - 
it was very interesting to observe reaction of unbiased devs 
not familiar with D at all. General reaction was this is 
awesome interesting language that I would never use for any 
production system unless I am crazy or can throw away money 
like crazy. Because, well, productivity.


I'm having some problems interpreting this. This is people in
a Rust meetup - in other words, early adopters. And they thing
D is crazy becuse productivity? I don't understand what you
mean.

D has done many things wrong, but there is one right thing that 
totally outshines it all - it is cost-effective and pragmatical 
tool for a very wide scope of applications.


Yes, D is pragmatic and extremely powerful and meldable to every
usecase.



Re: Rant after trying Rust a bit

2015-07-22 Thread simendsjo via Digitalmars-d

On Wednesday, 22 July 2015 at 20:59:11 UTC, Adam D. Ruppe wrote:

On Wednesday, 22 July 2015 at 20:43:04 UTC, simendsjo wrote:

When everything is an expressions, you can write things like
auto a = if(e) c else d;

In D you have to write
type a = invalid_value;
if(e) a = c;
else  a = d;
assert(a != invalid_value);



That's what the ternary expression is for:

auto a = e ? c : d;


Though the ternary is unnecessary with statements as 
expressions, common cases like this are handled.


:) The example was written to save space. I recon you understand 
what I mean.


Re: So what exactly is coming with extended C++ support?

2014-09-30 Thread simendsjo via Digitalmars-d
On 09/30/2014 05:32 PM, po wrote:
 On Tuesday, 30 September 2014 at 14:19:51 UTC, Araq wrote:
 It doesn't mention anything about moving C++ into C#.
 Even with IL2CPP, C# has fundamental design trade offs that make it
 slower than C++(GC is just one of them), so it wouldn't make much
 sense to port engine code to C# unless they wanted it to run slower.

 What are these fundamental design trade offs?
 
 -GC
 -no meta programming vs meta programming
(...)

C# has wonderful meta-programming facilities: Generics! (/me run and hides)


[OT] Memory usage and Web (WAS: Re: Digger 1.0)

2014-09-23 Thread simendsjo via Digitalmars-d-announce
On 09/23/2014 04:48 PM, Joakim wrote:
 On Monday, 22 September 2014 at 13:23:33 UTC, simendsjo wrote:
 My guess is the average for developers is ~8GB. 2GB RAM is really not
 enough for pretty much anything these days - the browser alone easily
 chews 3-4GB on moderate use.
 
 You have to admit that this is ridiculous.  I updated to the 64-bit
 Chrome on Windows when it came out and it is a huge memory hog.  Web
 browsers have grown out of control.

It's well beyond rediculous. After I log into my graphical environment
with everything started, ~200MB is used. Launch a browser, and suddenly
~3800MB is used. If it wasn't for everyone hailing the inner platform
effect (usually seen as a bad thing) as the best thing since sliced
bread, many laptops would probably not ship with 4GB standard. But if
your parents want Facebook and Instagram, you better give them a pretty
beefy computer.

Oh... And the CPU requirements is pretty steep too - even my Lenovo T520
(Core i7) is really slow at browsing the web!

Oh.. And did I forget? You have to run a dynamic programming language
that pushes most mistakes easily caught at compile-time to runtime errors.

I obviously don't think The Web™ has made the right choices.
The amount of Javascript hype I see makes me quite ill. An OS? Really?
In Javascript? Seriously?



Re: Library Typedefs are fundamentally broken

2014-09-23 Thread simendsjo via Digitalmars-d
On 09/23/2014 08:05 PM, ketmar via Digitalmars-d wrote:
 On Tue, 23 Sep 2014 16:15:19 +
 Adam D. Ruppe via Digitalmars-d digitalmars-d@puremagic.com wrote:
 
 struct HMENU { void* _; alias _ this; }

 Don't even have to import a Phobos module for it!
 remember my uuugly on Typedef! and __MODULE__? well, i was wrong, it
 was just ugly. and now i found really uuugly thing. please, even long
 Typedef! stinks less than this poor uuugly thing.
 

I disagree and think this code is idiomatic - it only uses regular
features. If you mean `_`, that usually means I don't care or Anything.

But looking at Typedef!, it uses Proxy! rather than just alias. Haven't
dived into Proxy, so the semantics might be quite different, perhaps subtly.


Re: Digger 1.0

2014-09-22 Thread simendsjo via Digitalmars-d-announce
On 09/22/2014 12:50 PM, Nick Treleaven wrote:
(...)
 Sometimes my Windows machine with 2 GB RAM gets OOM when trying to link
 phobos.lib (I have to close most programs and start again), it would be
 nice if there was a way to continue a failed build without starting from
 scratch.

My guess is the average for developers is ~8GB. 2GB RAM is really not
enough for pretty much anything these days - the browser alone easily
chews 3-4GB on moderate use. I recommend you just upgrade your computer
(or compile on a better iron).



Re: Digger 1.0

2014-09-22 Thread simendsjo via Digitalmars-d-announce
On 09/22/2014 07:28 PM, ketmar via Digitalmars-d-announce wrote:
 On Mon, 22 Sep 2014 15:24:55 +0200
 simendsjo via Digitalmars-d-announce
 digitalmars-d-announce@puremagic.com wrote:
 
 My guess is the average for developers is ~8GB. 2GB RAM is really not
 enough for pretty much anything these days - the browser alone easily
 chews 3-4GB on moderate use. I recommend you just upgrade your
 computer (or compile on a better iron).
 are your primary language is java? i'm asking just out of curiousity.
 

C#. Visual Studio requires quite a bit of memory; but template-heavy D
isn't exactly light on memory either.


Re: core.stdcpp

2014-08-29 Thread simendsjo via Digitalmars-d-announce
On 08/29/2014 07:07 PM, Sean Kelly wrote:
 On Wednesday, 27 August 2014 at 18:06:00 UTC, Daniel Murphy wrote:
 eles  wrote in message news:rixtiaiokrukvqjsf...@forum.dlang.org...

 One such platform exists and is the embedded system, others are the
 linux kernel and the like, and even others are writing D compiler
 back-ends and, yes, druntimes (well, exactly the part that it is
 called phobos-runtime above).

 An embedded system that can support all of D but doesn't have a
 cruntime?  I don't believe it.  If it has a cruntime then providing
 bindings is a non-issue, and if it can't support all of D then
 supporting only a subset (and then being free to exclude core.stdc) is
 inevitable.
 
 There was a D runtime years ago created as a separate project
 around the time that Druntime had its beginnings (as Ares) that
 had no dependencies on standard C.  The creator went by Maide in
 IRC, and she was doing some really cool stuff with it that made D
 work kind of like ObjectiveC.  I don't think it's in development
 any more, but it's probably possible to track it down with enough
 googling.

It's still available at dsource: http://www.dsource.org/projects/ares


Re: RFC: std.json sucessor

2014-08-25 Thread simendsjo via Digitalmars-d
On 08/25/2014 09:35 PM, Walter Bright wrote:
 On 8/23/2014 6:32 PM, Brad Roberts via Digitalmars-d wrote:
 I'm not convinced that using an adapter algorithm won't be just as fast.
 Consider your own talks on optimizing the existing dmd lexer.  In
 those talks
 you've talked about the evils of additional processing on every byte. 
 That's
 what you're talking about here.  While it's possible that the inliner
 and other
 optimizer steps might be able to integrate the two phases and remove some
 overhead, I'll believe it when I see the resulting assembly code.
 
 On the other hand, deadalnix demonstrated that the ldc optimizer was
 able to remove the extra code.
 
 I have a reasonable faith that optimization can be improved where
 necessary to cover this.

I just happened to write a very small script yesterday and tested with
the compilers (with dub --build=release).

dmd: 2.8 mb
gdc: 3.3 mb
ldc  0.5 mb

So ldc can remove quite a substantial amount of code in some cases.


std.stdio.tmpfile() return shared(_IO_FILE)* and not File

2014-08-24 Thread simendsjo via Digitalmars-d-learn
Using DMD 2.066 on GNU/Linux x86_64.

This is strange:

import std.stdio;
void main() {
auto f = tmpfile();
pragma(msg, typeof(f)); // shared(_IO_FILE)*
}

But stdio.d looks like the following:
static File tmpfile() @safe

What is going on here?


Re: std.stdio.tmpfile() return shared(_IO_FILE)* and not File

2014-08-24 Thread simendsjo via Digitalmars-d-learn
On 08/24/2014 07:56 PM, simendsjo wrote:
 Using DMD 2.066 on GNU/Linux x86_64.
 
 This is strange:
 
 import std.stdio;
 void main() {
 auto f = tmpfile();
 pragma(msg, typeof(f)); // shared(_IO_FILE)*
 }
 
 But stdio.d looks like the following:
 static File tmpfile() @safe
 
 What is going on here?
 

Oh, and ldc 0.14 and gdc 4.9.1 has the same result, so it's not a
backend thing at least.


Re: std.stdio.tmpfile() return shared(_IO_FILE)* and not File

2014-08-24 Thread simendsjo via Digitalmars-d-learn
On 08/24/2014 08:09 PM, anonymous wrote:
 On Sunday, 24 August 2014 at 17:55:05 UTC, simendsjo wrote:
 Using DMD 2.066 on GNU/Linux x86_64.

 This is strange:

 import std.stdio;
 void main() {
 auto f = tmpfile();
 pragma(msg, typeof(f)); // shared(_IO_FILE)*
 }

 But stdio.d looks like the following:
 static File tmpfile() @safe

 What is going on here?
 
 You're calling `core.stdc.stdio.tmpfile`. There is no
 `std.stdio.tmpfile`, it's `std.stdio.File.tmpfile`.

Thanks.

So std.stdio.tmpfile() returns shared(_IO_FILE)* and
std.stdio.File.tmpfile() returns File.

Talk about confusing. If I want something from pure C libraries, I would
use core.stdc.


File.tmpfile() cannot be used as a pipe?

2014-08-24 Thread simendsjo via Digitalmars-d-learn
I don't know the arguments for my process before reading some of stdin.
I was thinking I could solve this by creating a temporary file as a
stdin buffer while I found out the correct argument and could launch
the process. Unfortunately, this fails.

Error: 'object.Exception@std/stdio.d(2070): Enforcement failed'.

The enforcment that fails:
enforce(f._p  f._p.handle);
in LockingTextWriters ctor where f is the passed in File.

Test code:

import std.stdio, std.process;
void main() {
auto f = File.tmpfile();
f.write(works);
auto pid = spawnProcess([echo], f);
f.write(fails);
}


Re: File.tmpfile() cannot be used as a pipe?

2014-08-24 Thread simendsjo via Digitalmars-d-learn
On 08/24/2014 09:03 PM, simendsjo wrote:
 I don't know the arguments for my process before reading some of stdin.
 I was thinking I could solve this by creating a temporary file as a
 stdin buffer while I found out the correct argument and could launch
 the process. Unfortunately, this fails.
 
 Error: 'object.Exception@std/stdio.d(2070): Enforcement failed'.
 
 The enforcment that fails:
 enforce(f._p  f._p.handle);
 in LockingTextWriters ctor where f is the passed in File.
 
 Test code:
 
 import std.stdio, std.process;
 void main() {
 auto f = File.tmpfile();
 f.write(works);
 auto pid = spawnProcess([echo], f);
 f.write(fails);
 }
 

Never mind. I just found that I can set up a pipe
  auto f = pipe()
and then use f.readEnd


Re: BitC, Rust, dog food and more

2014-08-21 Thread simendsjo via Digitalmars-d
On 08/21/2014 09:39 AM, eles wrote:
 On Sunday, 25 March 2012 at 17:31:45 UTC, bearophile wrote:
 
 I think that one of the most important things to underscore is that
 we would have never found these things so early unless we had written
 the Rust compiler in Rust itself. It forces us to use the language
 constantly, and we quickly find pain points. I highly encourage all
 languages to do the same; it's a great way to find and shake out
 design issues early.

 Eating your own dog food is quite important for a language, especially
 if it's a low-level language. D has chosen the pragmatic approach of
 using almost-C++ as its implementation language, but this has caused
 (and it is causing) some disadvantages too.
 
 Time to ask this again?

AFAIK, ddmd is well underway and is pretty much in an alpha-state now.

Here's an announcement from July:
http://forum.dlang.org/thread/cmeqwpzglxjksmiek...@forum.dlang.org#post-lqlsp1:246f:241:40digitalmars.com


Re: Counting D contributors

2014-08-18 Thread simendsjo via Digitalmars-d
On 08/18/2014 11:58 PM, Ali Çehreli wrote:
 On 08/18/2014 01:16 PM, Jonathan M Davis wrote:
 
 for whatever reason, Kenji isn't listed, and he's obviously a
 big contributor.
 
 Kenji cannot be captured by tools written by mortals. :p
 
 Ali
 

LOL! We need a Kenji Hara facts page like this:
http://meta.stackexchange.com/questions/9134/jon-skeet-facts


Re: [Mono-D] v2.1.18 Parser/Completion/General fixesimprovements

2014-08-13 Thread simendsjo via Digitalmars-d-announce
On 08/13/2014 04:16 PM, Alex wrote:
(...)
 You should've noticed that the installation instruction stuff has been
 moved to
 the D wiki - http://wiki.dlang.org/Mono-D
(...)

Is it just me, or is there something very strange going on with the
wiki? Seems a lot of CSS isn't applied on that page and the front page -
No logo, login, edit etc etc (navigation at the bottom).
Other pages looks fine though.

Just my browser, or is anyone else experiencing the same issue?



Re: [Mono-D] v2.1.18 Parser/Completion/General fixesimprovements

2014-08-13 Thread simendsjo via Digitalmars-d-announce
On 08/13/2014 10:45 PM, Dicebot wrote:
 On Wednesday, 13 August 2014 at 20:27:42 UTC, Orvid King wrote:
 Can confirm. It was OK just a few hours ago though

 It's working fine for me using Opera, although the CSS may very well
 be cached for me...
 
 It has recovered ;)

Not for me. Doesn't work in firefox either (and I'm pretty sure I
haven't visited the wiki ever with firefox).


Re: Google definitely biased…

2014-08-13 Thread simendsjo via Digitalmars-d
On 08/13/2014 09:12 AM, Paulo Pinto wrote:
 On Wednesday, 13 August 2014 at 04:08:25 UTC, Ola Fosheim Gr wrote:
 On Tuesday, 12 August 2014 at 11:09:37 UTC, Paulo Pinto wrote:

 I can think of very few successful programming languages in the
 market without corporate backing.

 Got popular without corporate backing: algol, basic, bcpl, haskell,
 lisp, php, python, prolog...

 
 Algol - Development was paid by Elliott Brothers, Ltd.
 
 Basic - Corporate backing from all companies producing home computers in
 the early 80's. Microsoft was started by writing Basic interpreters.
 
 
 Lisp - Development was paid by Xerox PARC, Lisp Machines, Symbiotics,
 Texas Instruments, ...
 
 BCPL - Early development paid by MIT, further uses in Amiga OS
 (Commodore), Xerox PARC, ...
 
 Haskell - Many researchers are on Microsoft Research payroll
 
 Python - Zope, Google, Dropbox and all the companies paying the core
 developers salaries
 
 PHP - Zend and all the ISP that only allow PHP as only scripting
 language on their servers
 
 Prolog - I like it a lot, but popular?!? Anyway DEC, Turbo Prolog, LPA
 Prolog
 
 
 
 

D - backed by Facebook .. ok, only a couple of hundred $ :)


safe pure unittest

2014-08-13 Thread simendsjo via Digitalmars-d-learn
This is the first time I've seen attributes on unittests:
https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179

Has this always been supported? I guess it's good practice to add these
on unittests too, but does people even know about this feature? And are
there any cons to doing this?


Re: safe pure unittest

2014-08-13 Thread simendsjo via Digitalmars-d-learn
On 08/13/2014 02:50 PM, Dicebot wrote:
 On Wednesday, 13 August 2014 at 12:26:02 UTC, simendsjo wrote:
 This is the first time I've seen attributes on unittests:
 https://github.com/D-Programming-Language/phobos/pull/2349/files#diff-ba05e420ac1da65db044e79304d641b6R179


 Has this always been supported? I guess it's good practice to add these
 on unittests too, but does people even know about this feature? And are
 there any cons to doing this?
 
 unittest block is effectively just a special function declaration so all
 function attributes are applicable and act in a similar way.
 
 It is an extremely important idiom when you wan't to ensure specific
 properties of templated function that may be valid or not depending on
 template arguments. For example, function with output range may be @nogc
 or not depending if used output range type triggers GC. But you can mark
 with @nogc unittest that uses it with dummy output range to ensure that
 _nothing else_ allocated.

Thanks.

The unittest documentation notes that unittests are functions in one of
the sentences, but nothing regarding attributes (except for private) is
mentioned: http://dlang.org/unittest.html


Re: Best practices for testing functions that opens files

2014-08-06 Thread simendsjo via Digitalmars-d-learn
On 08/06/2014 01:22 AM, splatterdash wrote:
 Hi all,
 
 Is there a recommended way to test functions that opens and iterates
 over files? The unittest block seems more suited for testing functions
 whose input and output can be defined in the program itself. I'm
 wondering if there is a better way to test functions that open files
 with specific formats.
 
 Thanks before :).

Split it to several functions:

  ubyte[] readFile(string file) {...}

  MyFormat parseData(ubyte[] data) { ... }

This way you have very little logic where the files are read, and you
can easily unittest your parsing.


Re: monodevelop mono-d versions

2014-08-01 Thread simendsjo via Digitalmars-d-learn
On 08/01/2014 03:15 PM, Dicebot wrote:
 (...) or use /opt/ bundle by simendsjo

By Alexander Bothe. The files are just hosted at my domain.


Re: assume, assert, enforce, @safe

2014-07-31 Thread simendsjo via Digitalmars-d
On 07/31/2014 12:01 AM, Walter Bright wrote:
(...)
 2. The compiler can make use of assert expressions to improve
 optimization, even in -release mode.
(...)

Does this mean that assertions used for optimization will be left in
-release? There's plenty of times where I've had an old incorrect
assertion in my code after a refactoring - sometimes in seldom used paths.

If the compiler would aggressively optimize my code based on some wrong
assumptions I give it, it would be very useful if that assumption would
stay in the code to trigger an assertion.


Re: DConf 2014 Keynote: High Performance Code Using D by Walter Bright

2014-07-20 Thread simendsjo via Digitalmars-d-announce
On 07/19/2014 08:37 PM, Andrei Alexandrescu wrote:
 On 7/16/14, 3:22 AM, bearophile wrote:
 Andrei Alexandrescu:
 http://www.reddit.com/r/programming/comments/2aruaf/dconf_2014_keynote_high_performance_code_using_d/



 Despite Walter is used to pipeline programming, so the next step is to
 also handle failures and off-band messages in a functional way (without
 exceptions and global error values) with two parallel pipelines, here
 named Railway-Oriented Programming. This is one of the simplest
 introductions (and he can skip the slides 19-53) that I have found of
 this topic (that in the Haskell community is explained on the base of
 monads):

 http://www.slideshare.net/ScottWlaschin/railway-oriented-programming
 
 Just read the slides, very interesting.
(...)

Didn't look at the slides, but I remember finding the following article
a very nice introduction:
http://fsharpforfunandprofit.com/posts/recipe-part2/

(...)


Re: DSnips - making D coding awesome in Vim (with GIFs!)

2014-07-18 Thread simendsjo via Digitalmars-d-announce
On 07/17/2014 10:57 PM, Kiith-Sa wrote:
 DSnips is a set of UltiSnips snippets for D (now with GIFs showing each
 snippet in action (image-heavy))
 
 https://github.com/kiith-sa/DSnips
 
 This is an attempt to overhaul the D snippets I got merged to UltiSnips
 (now a separate vim-snippets repository), as the previous snippets had
 quite a few bugs. The snippets should now be easy to use together/chain
 (e.g. an imp (import) snippet places the cursor on the beginning of
 the next line so imp can be used for another import, wrap in
 try/catch places the cursor to be ready to add more catch blocks,
 module license can be replaced by using another snippet inside it, etc.
 
 There are some rather intelligent snippets, e.g. an operator builder
 for opBinary/opUnary/opOpAssign that will generate the skeleton for all
 operators typed in by the user, automatic DDoc Params: generation from
 function parameters, etc.
 
 I want to eventually try to merge this back to the default repository,
 but I'd like some comments/criticism/ideas first. Should any snippets be
 removed? Added? Any problems with the current snippets? (the wrap in
 try/catch in the previous version had issues with wrapping indented
 text, for example)

This looks great! A lot better than my non-pythonized snippets :)


Re: Proposal for design of 'scope' (Was: Re: Opportunities for D)

2014-07-15 Thread simendsjo via Digitalmars-d
On 07/15/2014 08:42 AM, Jacob Carlborg wrote:
 On 14/07/14 18:16, H. S. Teoh via Digitalmars-d wrote:
 
 Mine is here:

 http://wiki.dlang.org/User:Quickfur/DIP_scope
 
 From the DIP:
 
 The 'scope' keyword has been around for years, yet it is barely
 implemented and it's unclear just what it's supposed to mean
 
 I don't know if it's worth clarify but scope currently has various
 features.
 
 1. Allocate classes on the stack: scope bar = new Bar()
 2. Forcing classes to be allocated on the stack: scope class Bar {}
 3. The scope-statement: scope(exit) file.close()
 4. Scope parameters. This is the part that is unclear what is means/is
 supposed to mean in the current language
 

Isn't both 1 and 2 deprecated?


Re: This week's pull stats

2014-07-14 Thread simendsjo via Digitalmars-d
On 07/14/2014 08:55 AM, Walter Bright wrote:
 On 7/13/2014 10:32 PM, Brad Roberts via Digitalmars-d wrote:
 I'm playing with the idea of a once a week sort of status email.
 
 Seems like a fun idea!
 
 
 Pull creators this week:

 +--+---++--+
 | username | total | closed | open |
 +--+---++--+
 | 9rnsr|22 | 20 |2 |
 
 Kenji tops the list!
 

You're saying it like it's unexpected :)


Re: DConf 2014 Day 2 Talk 6: Debugging in D by Iain Buclaw

2014-07-11 Thread simendsjo via Digitalmars-d-announce
On 07/11/2014 05:48 PM, Andrei Alexandrescu wrote:
 Upvote!!
 
 http://www.reddit.com/r/programming/comments/2afm4x/dconf_2014_day_2_talk_6_debugging_in_d_by_iain/
 
 
 https://www.facebook.com/dlang.org/posts/882826745064341
 
 https://twitter.com/D_Programming/status/487623887187083264
 
 
 Andrei

Not on HN?


Re: Using D

2014-07-11 Thread simendsjo via Digitalmars-d
On 07/11/2014 05:30 PM, Chris wrote:
(...)
 Believe me, D's supposed sluggishness as regards GC is
 not so important for most applications. I dare say 90% of all
 applications are fine with the current GC.
(...)

I agree with this. The bottlenecks i my applications are MySQL and
Microsoft Office (Excel, Powerpoint, or even just plain COM). The same
bottlenecks as I get when using C#. Of course, it depends a lot on what
you do, but for my use (and yours, and probably many others), the GC
performance is something you can probably safely ignore.

A little anecdote.. I once got a 20% speed increase in Python by
moving a variable instantiation outside a tight loop.
  i = 0
  # loop here
i = something

rather than
  # loop here
i = something

The compiler wasn't smart enough to do this.


Re: Using D

2014-07-11 Thread simendsjo via Digitalmars-d
On 07/11/2014 05:43 PM, simendsjo wrote:
 On 07/11/2014 05:30 PM, Chris wrote:
 (...)
 Believe me, D's supposed sluggishness as regards GC is
 not so important for most applications. I dare say 90% of all
 applications are fine with the current GC.
 (...)
 
(...)

Oh, and a little GC.disable()/GC.enable() goes a long way. Only had to
do this a couple of times though.



Re: Using D

2014-07-11 Thread simendsjo via Digitalmars-d
On 07/11/2014 06:28 PM, Russel Winder via Digitalmars-d wrote:
 On Fri, 2014-07-11 at 17:43 +0200, simendsjo via Digitalmars-d wrote:
 […]
 A little anecdote.. I once got a 20% speed increase in Python by
 moving a variable instantiation outside a tight loop.
   i = 0
   # loop here
 i = something

 rather than
   # loop here
 i = something
 
 This is interesting. I can believe there is some performance benefit,
 but I am not sure I believe 20% improvement. If you can send me the code
 you were using, I would like to do some benchmarking on this.

Yes, I was very perplexed when I was profiling and finally found the
main offender. Unfortunately I don't have the code - it was a project
done for a past employer back in 2006/2007 (Python 2.4 IIRC).

 The compiler wasn't smart enough to do this.
 
 The Python compiler cannot and will never be able to do any such thing.
 Indeed if it did any such thing, it would be an error since it
 significantly changes the semantics of the program. Thus not doing this
 is not the fault of the compiler.  The fact that you were able to do
 this and it appeared to give you the same results just means that the
 change in program semantics did not affect your computation. Which is
 good, but not something the compiler could determine.

I think of this as a fault in the compiler. It was quite obvious (to me)
that nothing else relied on the value so the value didn't have to be
created on each iteration.



Re: Older versions of dmd

2014-07-11 Thread simendsjo via Digitalmars-d
On 07/11/2014 08:45 PM, H. S. Teoh via Digitalmars-d wrote:
 On Fri, Jul 11, 2014 at 05:51:05PM +, Justin Whear via Digitalmars-d 
 wrote:
 On Fri, 11 Jul 2014 17:44:28 +, Frustrated wrote:

 So why isn't there a link to previous versions of dmd? I have a
 regression I need to test out but can't find 2.064!

 I'd recommend taking a look at digger (https://github.com/CyberShadow/
 Digger).  Not only can it automatically build old versions of D, it
 also has a bisect feature for bug hunting.
 
 Whoa. This must be another one of those well-guarded secrets about D.
 Why isn't it on a prominent page on dlang.org??! I don't know how many
 times I got frustrated trying to narrow down a dmd bug, because git
 bisect in dmd alone can only go back so far, before phobos/druntime stop
 compiling, which throws off the whole process.
 
 
 T
 

Here's the well-kept secret: http://dconf.org/2014/talks/panteleev.html
The best thing is that there's no video links, so it's really a secret!
A bit googe-fu leads you here: https://www.youtube.com/watch?v=5iXRFlKvEY0


Re: DConf 2014 Day 2 Talk 4: Reducing D Bugs by Vladimir Panteleev

2014-07-10 Thread simendsjo via Digitalmars-d-announce
On 07/10/2014 11:34 AM, Dicebot wrote:
 On Thursday, 10 July 2014 at 05:27:56 UTC, simendsjo wrote:
 On 07/10/2014 01:22 AM, Nordlöw wrote:
 On Wednesday, 9 July 2014 at 18:26:53 UTC, simendsjo wrote:
 Would it make sense to add them to the dtools repository?

 It's already included there as a submodule :)

 Hidden in plain sight.
 
 Wait what? Are you speaking about
 https://github.com/D-Programming-Language/tools ?

I was mostly thinking about the lack of visibility on the wiki and
homepage. And while dustmite is there, digger is not.


Re: Concatenates int

2014-07-10 Thread simendsjo via Digitalmars-d-learn
On 07/10/2014 02:22 PM, Rikki Cattermole wrote:
 On 11/07/2014 12:11 a.m., Sean Campbell wrote:
 i have the ints 4, 7, 0 and 1 how can i Concatenate them into four
 thousand seven hundred and one.
 
 If we talking at compile time definition:
 
 int myint = 4_7_0_1;
 
 Would work.
 However I'll assume its at runtime you really want this.
 
 I.e. converting a string to an integer.
 
 int myint = to!int(4 ~ 7 ~ 0 ~ 1);
 
 Now they are not strings, and the positions of 10^ doesn't change then:
 
 int myint = (1000 * 4) + (100 * 7) + 1;

D also has the pow operator, so you can write this as:

int i = 4*10^^3 + 7*10^^2 + 0*10^^1 + 1*10^^0;



Re: Insert a char in string

2014-07-10 Thread simendsjo via Digitalmars-d-learn
On 07/10/2014 06:05 PM, Alexandre wrote:
 I have a string X and I need to insert a char in that string...
 
 auto X = 100;
 
 And I need to inser a ',' in position 3 of this string..., I try to use
 the array.insertInPlace, but, not work...
 
 I try this:
 auto X = 100;
 auto N = X.insertInPlace(1,'0');

Do you really want to insert a comma in the string, or do you want to
format a number as 100,000,000,000.00?


Re: Insert a char in string

2014-07-10 Thread simendsjo via Digitalmars-d-learn
On 07/10/2014 09:58 PM, Alexandre wrote:
 basically format
 I read a cobol struct file...
 
 From pos X to Y I have a money value... but, this value don't have any
 format..
 
 0041415
 
 The 15 is the cents... bascally I need to put the ( comma ), we use
 comma to separate the cents, here in Brazil...
 
 On Thursday, 10 July 2014 at 19:33:15 UTC, simendsjo wrote:
 On 07/10/2014 06:05 PM, Alexandre wrote:
 I have a string X and I need to insert a char in that string...

 auto X = 100;

 And I need to inser a ',' in position 3 of this string..., I try to use
 the array.insertInPlace, but, not work...

 I try this:
 auto X = 100;
 auto N = X.insertInPlace(1,'0');

 Do you really want to insert a comma in the string, or do you want to
 format a number as 100,000,000,000.00?
 

I'm not sure what you're trying to do though.
Do you need to fix the file by adding a comma at appropriate places? Or
read it into D and write it to the console with your currency format?
This is one way of reading in the values using slices and std.conv:

import std.stdio, std.conv;
void main() {
immutable input = 0041415;
double amount = input[0..$-2].to!double();
amount += input[$-2..$].to!double() / 100;
writeln(amount);
}



Re: Using enum constant from different modules

2014-07-10 Thread simendsjo via Digitalmars-d-learn
On 07/10/2014 10:47 PM, Marc Schütz schue...@gmx.net wrote:
 On Thursday, 10 July 2014 at 20:27:39 UTC, Jacob Carlborg wrote:
 Here's a code example:

 module main;

 import foo;

 enum Get = GET;

 void bar (string a)
 {
 assert(a is Get);
 }

 void main ()
 {
 asd();
 }

 module foo;

 import main;

 void asd()
 {
 bar(Get);
 }

 Running the above code will cause an assert error in the function
 bar. But if I move the function asd into the main module and
 completely skip the foo module the assert passes.

 I don't know if I'm thinking completely wrong here but this seems like
 a bug to me.
 
 No, this is equivalent to:
 
 void bar (string a)
 {
 assert(a is GET);
 }
 
 void asd()
 {
 bar(GET);
 }
 
 Enums behave as if their values are copy-n-pasted everywhere they are
 used (you probably know that).
 
 The compiler probably conflates the two identical strings when they're
 in the same module. This is safe for immutable data. I'm sure there's
 something in the spec about it...

Strings behaves a bit odd with is(). The following passes:

import std.stdio;
void f(string a, string b) {
assert(a is b); // also true
}
void main() {
string a = aoeu;
string b = aoeu;
assert(a is b); // true
f(a, b);
writeln(passed);
}

changing a and b to enum gives the same results.


Re: Using enum constant from different modules

2014-07-10 Thread simendsjo via Digitalmars-d-learn
On 07/11/2014 01:08 AM, sigod wrote:
 On Thursday, 10 July 2014 at 20:59:17 UTC, simendsjo wrote:
 Strings behaves a bit odd with is(). The following passes:

 import std.stdio;
 void f(string a, string b) {
 assert(a is b); // also true
 }
 void main() {
 string a = aoeu;
 string b = aoeu;
 assert(a is b); // true
 f(a, b);
 writeln(passed);
 }
 
 ```d
 import std.stdio;
 void f(string a, string b) {
writeln(a: , a.ptr, , b: , b.ptr);
assert(a is b); // also true
 }
 void main() {
string a = aoeu;
string b = aoeu;
writeln(a: , a.ptr, , b: , b.ptr);
assert(a is b); // true
f(a, b);
writeln(passed);
 }
 ```
 
 Output:
 ```
 a: 4210A0, b: 4210A0
 a: 4210A0, b: 4210A0
 passed
 ```
 
 Seems legit to me.

I forgot to check for compiler optimizations (even without -O).

immutable(int)[] a = [1];
immutable(int)[] b = [1];
assert(a is b); // fails as .ptr is different.

So it looks like string literals is cached by the compiler and reused.
Changing aoeu to 10.to!string for instance breaks this optimization.

But the fact that immutable(char)[] behaves different from
immutable(int)[] is a bit strange.


Re: DConf 2014 Day 2 Talk 4: Reducing D Bugs by Vladimir Panteleev

2014-07-09 Thread simendsjo via Digitalmars-d-announce
On 07/09/2014 06:00 PM, Andrei Alexandrescu wrote:
 http://www.reddit.com/r/programming/comments/2a8xf4/dconf_2014_day_2_talk_4_reducing_d_bugs_by/
 
 
 https://www.facebook.com/dlang.org/posts/881813965165619
 
 https://news.ycombinator.com/newest (please find and vote quickly)
 
 https://twitter.com/D_Programming/status/486902390399180801
 
 
 Andrei

Great talk! I didn't even know most of those tools existed!

Would it make sense to add them to the dtools repository?


Re: DConf 2014 Day 2 Talk 4: Reducing D Bugs by Vladimir Panteleev

2014-07-09 Thread simendsjo via Digitalmars-d-announce
On 07/10/2014 01:22 AM, Nordlöw wrote:
 On Wednesday, 9 July 2014 at 18:26:53 UTC, simendsjo wrote:
 Would it make sense to add them to the dtools repository?
 
 It's already included there as a submodule :)

Hidden in plain sight.


Re: shorter alternative of constructor with parameter

2014-06-23 Thread simendsjo via Digitalmars-d
On 06/22/2014 09:58 PM, Kapps wrote:
 On Sunday, 22 June 2014 at 11:50:31 UTC, Shammah Chancellor wrote:
 I can't support this proposal.   Adds more syntax to a language that
 is already becoming cramped.  I also don't see the purpose of having
 simple constructors like this?  Are you going to add (n choose k)
 simple constructors to a class?   I could get behind field initializer
 syntax ala C# with modeling the syntax we have for structures.

 new Person() {name: Bob};

 -Shammah
 
 In theory, 'with' could be used for that if it returned the expression
 passed in:
 auto a = with(new Person()) {
 Name = Bob;
 Age = 27;
 }

I had to test that syntax. I got it working with these versions:
C c; with(c = new C()) {
i = 10;
}

C d = new C(); with(d) {
i = 20;
}

I really like the C# object initializer syntax, so your version would be
much appreciated. Or if with could create objects in outer scope like this

with(auto c = new C()) {
i = 30;
}



Re: rehabilitating Juno

2014-06-21 Thread simendsjo via Digitalmars-d-learn
On 06/21/2014 06:40 AM, Jesse Phillips wrote:
 On Thursday, 19 June 2014 at 15:24:41 UTC, Jesse Phillips wrote:
 Once I get some examples compiling again in 32bit, it should be easier
 for you to play around with COM in D.
 
 I've pushed changes which get the library building and examples working.
 Let me know if there is any other direction I can provide. And if your
 curious you can check the commit history to see what changes where needed.
 
 https://github.com/JesseKPhillips/Juno-Windows-Class-Library

This is great. I used Juno back in 2007 for working with Excel, and it
worked great. Nice to see the library getting an update for D2.
I remember seeing some slides on another COM library for D2 a while ago.
Was that effort ever open-sourced?


Re: DConf Day 1 Talk 6: Case Studies in Simplifying Code with Compile-Time Reflection by Atila Neves

2014-06-16 Thread simendsjo via Digitalmars-d-announce
On 06/16/2014 07:27 PM, Andrei Alexandrescu wrote:
 https://news.ycombinator.com/newest

Why not put DConf 2014 in the title too?



Re: A Perspective on D from game industry

2014-06-16 Thread simendsjo via Digitalmars-d
On 06/15/2014 11:16 PM, Abdulhaq wrote:
 On Sunday, 15 June 2014 at 20:10:34 UTC, Walter Bright wrote:
 On 6/15/2014 9:20 AM, Xinok wrote:
 Given that he lives in Italy, it's safe to assume that English is not
 his first
 language. But rather than consider what he has to say or dispute his
 arguments,
 you completely dismissed his point of view because his level of
 writing doesn't
 meet your standards.

 Xinok does have a point that we all should be aware of.

 I've found a very strong correlation between poor writing skills and
 disorganized thinking.

 (Your point about non-native English speakers is well taken, one must
 not confuse unfamiliarity with English with disorganized thinking.)

 I'm hardly the only one. If one wants their views to be taken
 seriously, pay attention to spelling, grammar, paragraphs, organized
 writing, etc. There's an awful lot of stuff to read on the internet,
 and poor writing often elicits a meh, I'll skip this one and move on
 reaction.
 
 True but if I'm going to judge a comment by the way it's written I'll
 take a second language piece over a foul and insulting rant any day of
 the week.

And my guess is the people doing the insults never use another language
than their native language on a day-to-day basis. Not being a native
English speaker myself, I too got offended by this rant. It's naive to
assume everyone should be as fluent in English as native speakers. Some
countries are even dubbing all English shows and movies, so they're not
exposed to much English outside some forums - where many people might
not be native speakers themselves and thus learning you faulty grammar.
Luckily most people understands this issue.


Re: foreach

2014-06-12 Thread simendsjo via Digitalmars-d
On 06/12/2014 05:00 PM, Manu via Digitalmars-d wrote:
 I often find myself wanting to write this:
   foreach(; 0..n) {}
 In the case that I just want to do something n times and I don't
 actually care about the loop counter, but this doesn't compile.
 
 You can do this:
   for(;;) {}
 
 If 'for' lets you omit any of the loop terms, surely it makes sense
 that foreach would allow you to omit the first term as well?
 I see no need to declare a superfluous loop counter when it is unused.
 

_ is an often used identifier for i don't care in many languages. The
following works:
  foreach(_; 0..n)


Re: foreach

2014-06-12 Thread simendsjo via Digitalmars-d
On 06/12/2014 05:46 PM, monarch_dodra wrote:
 On Thursday, 12 June 2014 at 15:09:51 UTC, simendsjo wrote:

 _ is an often used identifier for i don't care in many languages. The
 following works:
   foreach(_; 0..n)
 
 One issue is that _ is still an actual identifier, with normal name
 collision rules. So that works only once. When you nest your loops,
 you'll end up having conflicts, and name your i don't care variable
 things such as _, __, ___, _1, _2 etc...
 
 It actually happens quite often I find.
 

Yeah, not good. Does any sane person use _ as a variable identifier and
then reference it? A breaking change would be a special rule so _ can
never be used and is allowed to shadow. Of course - this could break
existing code, so it will never happen :)


Re: Basics of calling C from D

2014-06-11 Thread simendsjo via Digitalmars-d-learn
On 06/11/2014 03:54 PM, Adam D. Ruppe wrote:
 On Wednesday, 11 June 2014 at 13:52:09 UTC, belkin wrote:
 Question: How do I use it from D?
 
 Write the prototype in your D file with extern(C):
 extern(C) int factorial(int n);
 
 then just call the function normally in D. Make sure you include all the
 C object files when you compile the D program too so it all links together.

I believe the correct answer should be Buy my book!.


Re: Basics of calling C from D

2014-06-11 Thread simendsjo via Digitalmars-d-learn
On 06/11/2014 04:22 PM, Adam D. Ruppe wrote:
 On Wednesday, 11 June 2014 at 14:11:04 UTC, simendsjo wrote:
 I believe the correct answer should be Buy my book!.
 
 ah, of course! I should just make a .sig file lol
 
 http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book
 
 
 chapter 4 talks about this kind of thing :P

Yeah, I was skimming through that chapter just minutes before I saw this
post :) I must say I really like your writing-style as well as the
down-to-earth and precise and concise presentation of the material. So
kudos to you!

Really looking forward to reading some of the more advanced material as
well as seeing your dconf presentation.


Re: Real time captioning of D presentations

2014-06-03 Thread simendsjo via Digitalmars-d-announce
On 06/03/2014 08:23 AM, Martin Drasar via Digitalmars-d-announce wrote:
 On 3.6.2014 7:55, simendsjo via Digitalmars-d-announce wrote:
 Or because somebody in the production studio decided the music and sound
 effects needed to be at least 2x louder than the dialog. 
 (...)

 I was about to say the exact same thing. I always have to turn the
 volume way down to not blow the roof when some sudden sound effect is
 played, but then I can't hear the voice. I even use subtitles for my
 native tongue if the movie has a lot of sound effects. I'm having a
 really hard time understanding the rationale behind this - is it to
 deafen viewers? To show that it's far from reality so people don't get
 confused mixing fiction with reality?
 
 It's not about deafening the viewer, it's about the costs. The sound is
 prepared for theatres with lots of HQ hardware and for 5.1 sound at
 minimum. The voice goes mostly to the central channel, effects on sides.
 When you have a 5.1 setup, you can turn the volume up on the central and
 down on sides and you will get reasonably sounding movies.
 
 However, nobody in the industry wants to spend money on converting the
 audio from 5.1 to 2, so it's usually left up to a player and it ends how
 you describe it. Also ripped movies suffer from these problems a lot.
 
 Martin
 

I had no idea, thanks. I just thought someone had the idiotic idea it
would be a nice idea to have sound effects a lot louder than voice :)


Re: Real time captioning of D presentations

2014-06-02 Thread simendsjo via Digitalmars-d-announce
On 06/03/2014 06:51 AM, Nick Sabalausky wrote:
 On 6/2/2014 5:16 PM, Jonathan M Davis via Digitalmars-d-announce wrote:
 On Mon, 02 Jun 2014 10:00:17 -0700
 Walter Bright via Digitalmars-d-announce
 digitalmars-d-announce@puremagic.com wrote:

 Captioning also helps people who aren't native english speakers.

 And native English speakers as well. It's not all that infrequent that
 I end
 up temporarily turning on subtitles in a movie that I'm watching,
 because the
 actor didn't say the line clearly enough.
 
 Or because somebody in the production studio decided the music and sound
 effects needed to be at least 2x louder than the dialog. 
(...)

I was about to say the exact same thing. I always have to turn the
volume way down to not blow the roof when some sudden sound effect is
played, but then I can't hear the voice. I even use subtitles for my
native tongue if the movie has a lot of sound effects. I'm having a
really hard time understanding the rationale behind this - is it to
deafen viewers? To show that it's far from reality so people don't get
confused mixing fiction with reality?



Re: D Users Survey: Primary OS?

2014-05-30 Thread simendsjo via Digitalmars-d
On 05/29/2014 05:53 PM, Tom Browder via Digitalmars-d wrote:
 Has anyone done a survey of the primary OS of D users?
 
 I (a D newbie) use Debian Linux (64-bit), but I get the feeling that
 many (if not most) users are on some version of Windows.
 
 Thanks.
 
 Best regards,
 
 -Tom
 

Arch Linux x86_64


Re: D Users Survey: Primary OS?

2014-05-30 Thread simendsjo via Digitalmars-d
On 05/30/2014 10:52 AM, Philippe Sigaud via Digitalmars-d wrote:
 Linux 64bits here also.
 
 In fact, contrary to the OP belief, it's mainly a Linux crowd here.
 People using Windows regularly complain about it, saying we don't see
 the way some tools are missing or not working as well on Windows.
 

I haven't used Windows in a while, but this is in sync with what I
remember from the experience. D worked(/works?) better on GNU/Linux.


Re: Adam D. Ruppe's D Cookbook now available!

2014-05-29 Thread simendsjo via Digitalmars-d-announce
On 05/29/2014 11:51 AM, Jacob Carlborg wrote:
 On 2014-05-28 20:14, Walter Bright wrote:
 http://www.packtpub.com/discover-advantages-of-programming-in-d-cookbook/book



 http://www.amazon.com/D-Cookbook-Adam-D-Ruppe/dp/1783287217

 http://www.reddit.com/r/programming/comments/26pn00/d_cookbook_officially_published_consists_of_d/



 After watching Adam's most excellent presentation at Dconf, I'm sure the
 book will be great! My copy gets here on Friday.
 
 I've already bought the ebook version.
 

Ditto. Just had time to look at the ToC though. Really looking forward
to reading it (and all the dconf talks)


Re: Dconf 2014 talks - when to be available

2014-05-28 Thread simendsjo via Digitalmars-d-announce
On 05/28/2014 05:54 AM, Saurabh Das wrote:
 On Tuesday, 27 May 2014 at 23:48:44 UTC, currysoup wrote:
 On Tuesday, 27 May 2014 at 23:08:01 UTC, Leandro Lucarella wrote:
 Ali Çehreli, el 27 de May a las 10:40 me escribiste:
 On 05/27/2014 09:18 AM, Suliman wrote:

  apparently to stay on top of reddit for awhile.
  Explain plz

 A benefit of releasing the presentations slowly is to enable
 constant exposure to DConf in the coming weeks, as opposed to making
 all of them available and potentially watch interest die in a few
 days.

 I think they should be uploaded all ASAP and then you can do official
 announcements in reddit or wherever you thinks it's best to promote the
 language. But really, introducing artificial waiting time for people
 ALREADY interested and using the language in the name of marketing is
 really annoying!

 I agree 100%. Educating people currently interested is as
 important as marketing.
 
 I actually prefer the slow release of the videos - it gives me enough
 time to digest each talk and discuss it before the next one grabs mine
 and everyone else's attention. I think releasing one video every few
 days leads to much more in-depth discussion on the forum as well.

Agree. I find it nice to have each video gaining some time in the
spotlight and the discussions that follow. Even though I'm so exited I
actually want all the videos at once!


Re: Dev. Collaboration

2014-05-27 Thread simendsjo via Digitalmars-d
On 05/27/2014 02:12 AM, chuck wrote:
 Would anyone be interested in a collaboration forum? I am thinking of
 starting one on Proboards to aid in development/collaboration between
 developers on D and libraries/bindings. Reading through the posts, I
 have seen that several people have created small projects that do the
 same thing (I have seen multiple for MySql alone, none of which has
 really gained true traction).
 
 So here is what I propose:
 1) The forum will be host different aspects of development
 (Database/bindings, Phobos development, networking tools, etc.).
 
 2) Form dev. committees to fill the most useful tasks in the group of
 choice. For example, focusing on doing one thing quickly and sustainably
 rather than burning out creating a project alone that will be difficult
 to maintain afterwords.
 
 3) This should help increase the number of code examples, increasing the
 visibility of D to anyone interested. Hopefully, this will also increase
 the community.

I think it's a great idea - DETF (D Engineering Task Force).
For this to succeed, I think connecting to existing communication
channels is very important. This means NNTP/mailing list, github,
auto-tester, dub, wiki (with DIPS) etc etc.
Setting up some new PHP forums will only split the community.


Vibe.d featured on HN frontpage - upvote to give some exposure

2014-05-26 Thread simendsjo via Digitalmars-d
https://hn.algolia.com/#!/story/forever/0/Asynchronous%20I%2FO%20that%20doesn%E2%80%99t%20get%20in%20your%20way%2C%20written%20in%20D


Re: Separate Piping of dmd stdout and stderr through ddemangle

2014-05-22 Thread simendsjo via Digitalmars-d-learn
On 05/22/2014 11:29 AM, Nordlöw wrote:
 Is there a Bash way to pipe stdout and stderr *separately* through
 ddemangle?
 
 I'm aware of
 
 21
 
 but this removes separation of stdout and stderr.

21 means redirect file handle 2 to the same as file handle 1.
So it will redirect stderr to stdout. I'm not exactly sure what you want
to do though, so this might not be the answer you are looking for.


Re: Learn D in x minutes

2014-05-14 Thread simendsjo via Digitalmars-d
On 05/14/2014 10:11 AM, Martin Nowak wrote:
 On Wednesday, 14 May 2014 at 07:36:57 UTC, Joseph Rushton Wakeling wrote:
 On Wednesday, 14 May 2014 at 07:04:24 UTC, w0rp wrote:
 I'm unsure about the learn x in y minutes tutorials, but I did
 however think this was very neat. http://tryhaskell.org/

 A friend and former colleague of mine wrote that. Great guy. :-)
 
 http://drepl.dawg.eu

Very cool! Maybe it should default to using the most recent variable?
_mod2.a in the example below.

D int a = 10:
= a
D int a = 5;
= a
D a
= _mod1.a at /tmp/drepl.13YxH8/_mod1.d(3) conflicts with _mod2.a at
/tmp/drepl.13YxH8/_mod2.d(3)
D _mod1.a
= 10
D _mod2.a
= 5


Re: Livestreaming DConf?

2014-05-12 Thread simendsjo via Digitalmars-d-announce
On 05/11/2014 11:15 PM, John Carter via Digitalmars-d-announce wrote:
 The timezones being so different, I'm not sure livestreaming will help
 me... But I do plan to watch any videos of it as soon as they are up.

It's the same problem for all Europeans (and many other), including me.
I'm also looking forward to the videos, but I think livestreaming is a
good thing for those who are able to follow them.


Re: Tkd – Cross platform GUI toolkit based on Tcl/Tk

2014-05-09 Thread simendsjo via Digitalmars-d-announce
On 05/08/2014 06:05 PM, Andrei Alexandrescu wrote:
 
 https://hn.algolia.com/#!/story/forever/0/Tkd

I'm unable to find the HN link. This search shows the reddit link and a
link straight to the forum. I even tried to go through several pages of
newest on HN doing a search for tkd without any luck. Did it get
deleted..?


Re: Tkd – Cross platform GUI toolkit based on Tcl/Tk

2014-05-09 Thread simendsjo via Digitalmars-d-announce
On 05/09/2014 11:32 AM, Andrej Mitrovic via Digitalmars-d-announce wrote:
 On 5/9/14, simendsjo via Digitalmars-d-announce
 digitalmars-d-announce@puremagic.com wrote:
 I'm unable to find the HN link. This search shows the reddit link and a
 link straight to the forum. I even tried to go through several pages of
 newest on HN doing a search for tkd without any luck. Did it get
 deleted..?
 
 We should just link to the post with some remove me characters. E.g.:
 
 https://remove_menews.ycombinator.com/item?id=7716010
 
 You copy-paste the URL, and that should avoid any issues with
 hotlinking, wouldn't it?
 

Thanks. There's no tracking info in the url, so it it's probably the
best way as long as the search site doesn't work as intended.


Re: Tkd – Cross platform GUI toolkit based on Tcl/Tk

2014-05-09 Thread simendsjo via Digitalmars-d-announce
On 05/09/2014 06:09 PM, Andrei Alexandrescu wrote:
 On 5/9/14, 2:44 AM, simendsjo wrote:
 On 05/09/2014 11:32 AM, Andrej Mitrovic via Digitalmars-d-announce wrote:
 On 5/9/14, simendsjo via Digitalmars-d-announce
 digitalmars-d-announce@puremagic.com wrote:
 I'm unable to find the HN link. This search shows the reddit link and a
 link straight to the forum. I even tried to go through several pages of
 newest on HN doing a search for tkd without any luck. Did it get
 deleted..?

 We should just link to the post with some remove me characters. E.g.:

 https://remove_menews.ycombinator.com/item?id=7716010

 You copy-paste the URL, and that should avoid any issues with
 hotlinking, wouldn't it?


 Thanks. There's no tracking info in the url, so it it's probably the
 best way as long as the search site doesn't work as intended.
 
 I thought they track the referrer, no?

But if you go directly through the browser, no referrer is added.

 Anyhow if I go to https://hn.algolia.com/#!/story/forever/0/Tkd the
 story is the second hit.

Ah, I see why I was confused now. Your entry links to the reddit
announcement, not the forums.


Re: Report generator for D

2014-05-06 Thread simendsjo via Digitalmars-d
On 05/06/2014 08:08 AM, Rikki Cattermole wrote:
 On Tuesday, 6 May 2014 at 04:34:26 UTC, Sergey wrote:
  Please, help...

 I want to use D (Vibe.d) to create a web client to access the database
 of medical institutions. Tell me, please, what about the reports
 (report generator)? I need to upload reports in DOC and XLS.

 Thanks in advance.

 Regards, Sergey
 
 I'm afraid I don't believe there to be any libraries for dealing
 with those formats.
 But via a quick google search I did find a (paid) library that
 you could easily bind to via extern(C) [0].
 I also found another library [1] for word documents and
 supposedly excel.
 
 I don't know what the quality is for either. Also if you want to
 do a shared library binding instead of static you may want to
 check out derelict-util.
 
 [0] http://www.libxl.com/
 [1] http://libopc.codeplex.com/

There is also using COM directly, which I've used previously. It's quite
tedious, but it works.
For D1 there's also Juno: http://www.dsource.org/projects/juno
Not sure if someone has updated it for D2.