Re: Visual Studio Code code-d serve-d beta release

2017-08-05 Thread Dmitry via Digitalmars-d-announce

On Saturday, 5 August 2017 at 22:43:31 UTC, WebFreak001 wrote:
try out the new version please uninstall code-d and install 
code-d-beta 
(https://marketplace.visualstudio.com/items?itemName=webfreak.code-d-beta, it's version 0.16.1) and just try to use it.


Failed to install serve-d (Error code 2)
https://pastebin.com/EMgV1tR2



Re: How do you use D?

2017-08-05 Thread Laeeth Isharc via Digitalmars-d

On Friday, 28 July 2017 at 14:58:01 UTC, Ali wrote:
While the Orgs using D page is very nice ... I hoping to hear 
more personal stories ...


So

How do you use D?
In work, (key projects or smaller side projects)
in your side project, (github, links please)
just to learn something new? (I would easily argue that 
learning D will make you a better C++ programmer, maybe not the 
most efficient way, but I a sure it i very effective)


Did you introduce D to your work place? How? What challenges 
did you face?


What is you D setup at work, which compiler, which IDE?

And any other fun facts you may want to share :)


I started programming in 1983: BBC BASIC, 6502 assembler, Z80 
assembler.  I learnt to program C on an Amstrad PCW running CP/M, 
and compiler I used had K style declarations.


Then I discovered economics, and my life took a different course. 
 I moved into trading and managing money, but I always programmed 
on the side to help me solve investment and business problems.  
Kept it quiet because programming was for a long time low status 
and clashed with what people expected to see in a money manager.


Late 2013 I recognised that the way our business used technology 
was completely broken.  The only way to make the most of 
technology is to combine an understanding of investing, financial 
instruments, the investment business, and technology in one mind. 
 But where am I going to find a guy like that?  So I looked in 
the mirror and realised I had to brush up my skills.


So I started building tools to help me invest.  My friends mostly 
thought it was a crazy course of action, because it's rare if you 
leave investing even temporarily to return to it, and I love 
markets, but sometimes the direct approach isn't the right one.  
We're drowning in data but don't have good tools to make sense of 
it.


I learnt python and cython, but kept looking, because I wanted to 
have my cake and eat it.  Why can I not have all of productivity, 
performance, static typing/correctness, abstraction, and code 
readability - I don't think I should have to choose just a 
couple, and I am not going to. That led me to D in 2014.


At school they used to ask us if everyone else jumped out of the 
window  would you do it too? And it's a profitable approach in 
financial markets to develop and learn to trust your own 
judgement of things.  If a highly respected and very 
knowledgeable economist tells you "you do realise that there is 
no basis in economic theory for what you are suggesting", you 
need to be able to revisit your thinking, see what you might be 
missing, but in the end trust your own judgement over that of the 
putative expert.  And he subsequently wrote a very impressive 
explanation after the fact of how what "couldn't be justified in 
theory" did in fact happen.  And it's a bit similar with 
programming language choices and such.  Its way better to appeal 
to people who make up their own mind and bear the consequences 
then to those who have to cover their behinds by getting the 
right ticks in the boxes because the are never going to be 
earlier adopters except through some unfortunate accident - 
because you also don't want such people as early adopters!


Since then, one thing led to another, and I ended up hiring a few 
people from the community to help me as consultant developers.  
Maybe a bit more than 10% of Team Phobos, based on a simple 
calculation.


I have also ended up running technology, amongst other things, 
for a decent size hedge fund.  I am using D for the project I 
started beforehand, and we are starting to explore its usefulness 
in the rest of the firm for some core analytics.  It pays to 
start small and build on early successes.


Has D been good for me? What have been the consequences of the 
French Revolution? In both cases it's too early to say with utter 
confidence since life is complicated and things are not always 
what they seem to be in the moment, but I have a view on the 
latter, and I think the answer to the former is definitely yes.


Finance used to be relatively at the leading edge.  The industry 
got a bit too fat, it hired the wrong people as it expanded too 
quickly, and then after the crisis people had other things to 
worry about - first survival, and then an exploding burden of 
compliance.  At one big bank even the compliance people complain 
about the number of compliance people they have.  On top of that, 
there's so much legacy systems that it can be very difficult to 
do anything creative or new.


So as an industry we fell behind a bit, and when you go through a 
cycle like that if becomes somewhat self-reinforcing.  To turn 
things around you need to hire very good people, but it's not so 
easy to find very good people who are willing to work with the 
people who created and tolerated the mess in the first place.  
But it can be done, and I think based on a view from afar that 
the banks will do better on this front than they have been.


For a 

Re: returning D string from C++?

2017-08-05 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 05 Aug 2017 20:17:23 +
schrieb bitwise :

>  virtual DString getTitle() const {
>  DString ret;
>  ret.length = GetWindowTextLength(_hwnd) + 1;
>  ret.ptr = (const char*)gc_malloc(ret.length, 0xA, NULL);
>  GetWindowText(_hwnd, (char*)ret.ptr, ret.length);
>  return ret;
>  }

In due diligence, you are casting an ANSI string into a UTF-8
string which will result in broken Unicode for non-ASCII window
titles. In any case it is better to use the wide-character
versions of Windows-API functions nowadays. (Those ending in
'W' instead of 'A'). Starting with Windows 2000, the core was
upgraded to UTF-16[1], which means you don't have to
implement the lossy conversion to ANSI code pages and end up
like this ...

[information loss]
   UTF-8 <-> Windows codepage <-> UTF-16
  ||
  in your code inside Windows

... but instead directly pass and get Unicode strings like
this ...

   UTF-8 <-> UTF-16
  |
  in your code

string to zero terminated UTF-16:
http://dlang.org/phobos/std_utf.html#toUTF16z
zero terminated UTF-16 to string:
ptr.to!string() or just ptr[0..len] if known

Second I'd like to mention that you should have set
ret.length = GetWindowText(_hwnd, (char*)ret.ptr, ret.length);
Currently your length is anything from 1 to N bytes longer
than the actual string[2], which is not obvious because any
debug printing or display of the string stops at the embedded
\0 terminator.

[1] https://en.wikipedia.org/wiki/Unicode_in_Microsoft_Windows
[2]
https://msdn.microsoft.com/de-de/library/windows/desktop/ms633521(v=vs.85).aspx

-- 
Marco



Re: newCTFE Status August 2017

2017-08-05 Thread Stefan Koch via Digitalmars-d

On Tuesday, 1 August 2017 at 21:27:32 UTC, Stefan Koch wrote:

[ ... ]


I am quite surprised.
newCTFE comes far enough now, that it tries to interpret it's own 
interpreter (which is CTFEable)


Of course it fails in doing so since we do not yet handle newing 
arrays or associative arrays.


Though as soon as we do support newing arrays and remove the need 
for associative arrays  from the interpret_ function, we should 
indeed be able to self-host (so to speak.)




Re: d_to_html.d

2017-08-05 Thread Meta via Digitalmars-d-announce

On Saturday, 5 August 2017 at 19:07:50 UTC, WebFreak001 wrote:
Hi, I made a D to HTML generator which is basically diet, but 
fully using the D compiler as generator and not some 
complicated parser, etc. Here an example what you pass in:


string page = html(
head(
title("wtf is this"),
style(
html(
font-family = "Roboto",
background = 0xEFEFEF
),
div.content(
max-width = 800.px,
margin = auto_,
margin-top = 32.px,
box-shadow = "0 2px 5px rgba(0, 0, 0, 0.3)",
background = white,
padding = 32.px
),
div.footer(
text-"align" = center
)
)
),
body(
div.content(
h1("The most crappy HTML generator ever"),
div.teaser(
p("Super fast")
),
hr,
p("Reasons why you should use d_to_html:"),
ul(
li("TODO: no reason yet") * 5
)
),
div.footer(
p(raw!" 2017 webfreak.org")
)
)
).toString;

Which generates: https://i.webfreak.org/fStzn0.html

Full source: 
https://gist.github.com/WebFreak001/6a1916779e48898c7ababc47a3113829


Though some things (like min and max for example) won't work 
correctly, so you need to manually write `attr!"min" = 4` if 
you wanted to add that to an input element.


btw this is just a joke project, it's totally abusing operator 
overloading just to show what is possible with it. The idea 
came up in Wild's discord server, you can join us too, we have 
a programming and a dplug channel: 
https://discordapp.com/invite/bMZk9Q4


Just because you *can* do something, it doesn't mean you 
*should*. ;-)


Very creative, I don't think reading source code has ever made me 
chuckle before.


Re: How do you use D?

2017-08-05 Thread jmh530 via Digitalmars-d

On Sunday, 6 August 2017 at 03:30:00 UTC, Laeeth Isharc wrote:


I've suggested exactly the same "easy-to-learn super-powered 
stronly-typed javascript" and "efficient web server 
development" advertising approachs to the D leadership, using 
a more "Python.org"-like website.




[snip]

Good long read.


Re: Visual Studio Code code-d serve-d beta release

2017-08-05 Thread Neia Neutuladh via Digitalmars-d-announce

On Saturday, 5 August 2017 at 22:43:31 UTC, WebFreak001 wrote:
I just released a beta version on the visual studio marketplace 
that allows you to try out the latest features of serve-d.


Awesome! Once I worked around the binary placement issue, this 
actually gave me completion options, which is better than the 
previous version ever did for me.


Re: How do you use D?

2017-08-05 Thread Laeeth Isharc via Digitalmars-d

On Saturday, 5 August 2017 at 21:31:49 UTC, Ecstatic Coder wrote:
It is more about marketing. Maybe Go is not a perfect 
language, maybe not even a good one, but it's sold so good 
because of a good marketing


So, calling D a "better C++" is a bad advertisement. But if 
you rename it to 'Script', for example "DatScript" 
and sell it as "better, statically typed JavaScript dialect 
which compiles into fast native executables" it will became #1 
language on GitHub in no time.


+1

I've suggested exactly the same "easy-to-learn super-powered 
stronly-typed javascript" and "efficient web server 
development" advertising approachs to the D leadership, using a 
more "Python.org"-like website.


Maybe it's because this change would be much too radical, but 
I've been told that the "Better C++" slogan won't change, 
despite D could easily be "tweaked" to eat a significant part 
of Go/Dart's market shares.


And I'm not especially convinced that many C++ developers are 
currently rushing towards D because of the current website.


For instance, I've personally chosen D *only* it was much 
better than JavaScript/Node.js, not because it was better than 
C++, that I still have to use for game and mobile development.


Still waiting that somebody explains me how to _easily_ use D 
with Unreal Engine, Cocos2D-X, etc... ;)


I know I'm not the general case, but this still proves that 
"some" C++ developers won't switch to D for long because they 
are too tied to their ecosystem.


In open source, and indeed in entrepreneurial corporations, the 
way to persuade people is to create the shift you advocate, at 
least in a small way, so people can see what your early start 
could become.  Code wins arguments, as they say at Facebook, and 
not just code but documentation, business plans etc too.


Its work to write it, but on the other hand my experience has 
been that work is rarely truly wasted.  It might seem so at the 
time, but for example work I did to persuade somebody that didn't 
want to listen, and where it seemed like I was pointlessly 
banging my head against the wall, has ended up being very 
valuable, even in dollar terms a few years later.  It's not 
always rational to be excessively calculating about risk reward 
in the face of genuine, radical  uncertainty when the risk is not 
that bad.


I agree with you that the benefits of D are not perfectly well 
communicated to people who aren't C++ programmers looking for 
salvation.  I had a discussion just last week about that, 
explaining that D isn't just something they mostly fits only 
large data sets where performance is key.  And in particular it's 
a cultural challenge because people have become resigned to the 
idea of different languages for different purposes, and to a 
large extent D doesn't fit the mental schema people have.


Nothing much changes in life day to day, and changes that seem to 
be big often unfold slowly for a long time before being noticed.  
The financial crisis unfolding began in Feb 2007 at the latest, 
but it didn't feel like that to most people at the time.


Similarly, compare D documentation today to that of early 2014 
(when I first look at D).  Plenty of it was all perfectly clear 
if you had a more academic training in computing, but if not then 
it wasn't the friendliest.  I tried to persuade one chap who was 
helping me between jobs to learn D, and he was absolutely 
terrified of it, to a good extent because of the docs!


And it's also because people are used to complexity being hidden 
from them and things being made very easy.  Since D often 
involves paying a price upfront to make future things easier, 
perhaps it's worth bearing in mind that there's a coupling 
between the degree of development of the tooling and how polished 
the docs should be.  If you make it so easy to learn D that you 
draw people who are utterly stuck when they hit dependency 
problems with dub, that may not be ideal either.   Ie an implicit 
question of truth in advertising.


And the situation with docs changed over time.  One recent change 
is thanks to Seb Wilzbach who introduced runnable examples 
generated automatically from unit tests.  If you look at his pull 
request it wasn't welcomed entirely with open arms in the 
beginning because the benefits weren't clear (and some other 
reasons I forgot).


So if you think we should have friendlier docs appealing to non 
systems programmers, why not write a mock up so others can see.  
It needn't be either or, because you can have an easy or advanced 
channel from front page.


And it's worth not alienating those who want to go straight to 
the meat of things - there's nothing more frustrating than a 
system that talks down to you or breaks things down into little 
pieces when you're quite used to slaughtering and butchering 
dinner for yourself, thank you very much...


I really think there's a limit in how much sense it makes to 
think about D marketshare against other programming languages.



Re: Visual D no bp's on x64

2017-08-05 Thread FoxyBrown via Digitalmars-d-debugger

On Sunday, 6 August 2017 at 03:12:22 UTC, FoxyBrown wrote:

On Thursday, 3 August 2017 at 20:22:56 UTC, Johnson Jones wrote:
On Thursday, 3 August 2017 at 07:06:06 UTC, Rainer Schuetze 
wrote:

[...]


Thanks! Seems to be working.


well, in x86 I still get a few BP's that won't be hit every 
once in a while(well, happened for the first time since I've 
used the new release).



The code looks like

while(i < data.length && data[i] != '>' && data[i] != '"' && 
data[i..i+token2.length] != token2) i++;

if (data[i] == '>') { continue; }

I put a BP on the if and when ran it says it won't be hit. I 
have a BP right above it and below it and it works fine.


says "The BP will not currently be hit. No symbols have been 
loaded for this document.". I do not know why symbols really 
matter for BP's?



If I change the if statement to

if (data[i] == '>')
{
continue;
}

it works ;/


Oops, it "works". The BP icon is no longer a hollow read disk but 
it is simply not hit ;/


I know all this doesn't help much but it all seems to be related 
to the previous bugs.


Re: Create class on stack

2017-08-05 Thread FoxyBrown via Digitalmars-d-learn

On Sunday, 6 August 2017 at 02:32:05 UTC, Adam D. Ruppe wrote:

On Sunday, 6 August 2017 at 02:19:19 UTC, FoxyBrown wrote:
Also, does it do the allocation at compile time(reserve space 
on the stack for the variable along with all the others or 
does it "allocate" space on the stack at runtime?... which is 
slightly slower).


compile time. It works like a static array of the appropriate 
size.


though the cost if ti was at runtime is small regardless. I 
think it is just a register subtract.


yeah, I know, but no need for it ;) Still better than the heap 
but was just curious ;) No need to waste cycles if it's not 
necessary.


Re: Netflix opensources its first D library: Vectorflow

2017-08-05 Thread Joakim via Digitalmars-d-announce

On Wednesday, 2 August 2017 at 22:56:32 UTC, Joakim wrote:
On Wednesday, 2 August 2017 at 21:31:19 UTC, Walter Bright 
wrote:

https://www.reddit.com/r/programming/comments/6r6dwp/netflix_opensources_its_first_d_library_vectorflow/


No. 2 liked proggit link of the day, should be no. 1 soon:

https://www.reddit.com/r/programming/top/?time=day

Not doing well on HN though:

https://hn.algolia.com/?query=vectorflow


Top 3 for the week:

https://www.reddit.com/r/programming/top/?sort=top=week

People seem really enthused by this library.


Re: SVD_to_D: Generate over 100k lines of highly-optimized microcontroller mmapped-IO code in the blink of an eye

2017-08-05 Thread Mike via Digitalmars-d-announce

On Saturday, 5 August 2017 at 20:08:39 UTC, WebFreak001 wrote:

I just clicked through some random files in the example folder, 
this line seems broken: 
https://github.com/JinShil/svd_to_d/blob/master/examples/atsamd21g18a/AC.d#L13


Fixed. Thanks!


Re: Create class on stack

2017-08-05 Thread Adam D. Ruppe via Digitalmars-d-learn

On Sunday, 6 August 2017 at 02:19:19 UTC, FoxyBrown wrote:
Also, does it do the allocation at compile time(reserve space 
on the stack for the variable along with all the others or does 
it "allocate" space on the stack at runtime?... which is 
slightly slower).


compile time. It works like a static array of the appropriate 
size.


though the cost if ti was at runtime is small regardless. I think 
it is just a register subtract.


Re: Create class on stack

2017-08-05 Thread FoxyBrown via Digitalmars-d-learn

On Sunday, 6 August 2017 at 02:10:31 UTC, Moritz Maxeiner wrote:

On Sunday, 6 August 2017 at 01:18:50 UTC, Johnson Jones wrote:
On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner 
wrote:
On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones 
wrote:
using gtk, it has a type called value. One has to use it to 
get the value of stuff but it is a class. Once it is used, 
one doesn't need it.


Ideally I'd like to treat it as a struct since I'm using it 
in a delegate I would like to minimize unnecessary 
allocations. Is there any way to get D to allocate a class 
on the stack like a local struct?


The easy way is through std.typecons.scoped [1].
Here be dragons, though, because classes are reference types.

[1] https://dlang.org/phobos/std_typecons.html#.scoped


Thanks, I didn't think it created on the stack but it makes 
sense to do so.


See the source [1] as to why: typeof(scoped!T) is a 
(non-copyable) struct that holds the memory for the T object 
inside it.



The only issue is that it escaping the reference?


Yes, don't escape references, that's the reason for my comment:

Here be dragons, though, because classes are reference types.


[1] 
https://github.com/dlang/phobos/blob/v2.075.0/std/typecons.d#L6613


I don't think you understand what I'm saying.

If I use this method to create a "reference" type on the stack 
rather than the heap, is the only issue worrying about not having 
that variable be used outside that scope(i.e., have it "escape")?


Obviously since it's on the stack it will be invalid after the 
function call, but I'm talking about other pitfalls. I don't see 
any but I want to be sure. Also, does it do the allocation at 
compile time(reserve space on the stack for the variable along 
with all the others or does it "allocate" space on the stack at 
runtime?... which is slightly slower).







Re: Did dmd forget how to read?

2017-08-05 Thread Johnson Jones via Digitalmars-d

On Sunday, 6 August 2017 at 00:22:45 UTC, Cym13 wrote:

On Saturday, 5 August 2017 at 23:54:45 UTC, Johnson Jones wrote:
main.d(157): Error: no property 'SetCursor' for type 
'gdk.Window.Window', did you mean 'getCursor'?


um... anyone see bug? It's there, I promise.


"setCursor" exists, but "SetCursor" doesn't (or your "bug" 
depends on code that you wrote and didn't share). I believe as 
both "setCursor" and "getCursor" are one character away from 
"SetCursor" dmd took the first one in alphabetic order or 
something. No need to panic ;)


No one is panicking, so you can stop panicking that you think 
they are panicking.


The point is that setCursor is much closer to SetCursor than 
getCursor. It should prioritize case differences first. SETCURSOR 
should still match setcursor better than getcursor or getCURSOR 
or whatever.


But I'll get you a ascii star for realizing the issue

 /\
<  >
 \/



Re: Create class on stack

2017-08-05 Thread Moritz Maxeiner via Digitalmars-d-learn

On Sunday, 6 August 2017 at 01:18:50 UTC, Johnson Jones wrote:
On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner 
wrote:
On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones 
wrote:
using gtk, it has a type called value. One has to use it to 
get the value of stuff but it is a class. Once it is used, 
one doesn't need it.


Ideally I'd like to treat it as a struct since I'm using it 
in a delegate I would like to minimize unnecessary 
allocations. Is there any way to get D to allocate a class on 
the stack like a local struct?


The easy way is through std.typecons.scoped [1].
Here be dragons, though, because classes are reference types.

[1] https://dlang.org/phobos/std_typecons.html#.scoped


Thanks, I didn't think it created on the stack but it makes 
sense to do so.


See the source [1] as to why: typeof(scoped!T) is a 
(non-copyable) struct that holds the memory for the T object 
inside it.



The only issue is that it escaping the reference?


Yes, don't escape references, that's the reason for my comment:

Here be dragons, though, because classes are reference types.


[1] 
https://github.com/dlang/phobos/blob/v2.075.0/std/typecons.d#L6613


Re: Visual Studio Code code-d serve-d beta release

2017-08-05 Thread Soulsbane via Digitalmars-d-announce

On Saturday, 5 August 2017 at 22:43:31 UTC, WebFreak001 wrote:
You might remember the blog post from a while back about 
workspace-d and serve-d, I just released a beta version on the 
visual studio marketplace that allows you to try out the latest 
features of serve-d. Note that this version might easily break 
in the future, but for the next few days I am trying to gain 
some feedback. If you are a user of code-d and if you want to 
try out the new version please uninstall code-d and install 
code-d-beta


I'm getting this error: "Could not initialize dub. Falling back 
to limited functionality!". I don't get this error in the other 
version and dub is installed: DUB version 1.4.0, built on Jul 19 
2017.





gtkD: events being triggered twice

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn

GtkEventBox - Enter
GtkEventBox - Enter
Down
GtkEventBox - Leave
Up
GtkEventBox - Leave
GtkEventBox - Leave

That is when I move the mouse over the event box then click then 
move out out then release.


I would expect

Enter Down Leave Up

The fact that enter and leave are not paired equally is a 
problem. Can be worked around but seems like it would be a bug.


the code is simply


ebox.addOnEnterNotify(delegate(Event e, Widget w)
{   
writeln(w.getName(), " - ", "Enter");
return true;
});

ebox.addOnLeaveNotify((Event e, Widget w)
{   writeln(w.getName(), " 
- ", "Leave");
return true;
});


Re: Create class on stack

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn

On Saturday, 5 August 2017 at 23:09:09 UTC, Moritz Maxeiner wrote:

On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote:
using gtk, it has a type called value. One has to use it to 
get the value of stuff but it is a class. Once it is used, one 
doesn't need it.


Ideally I'd like to treat it as a struct since I'm using it in 
a delegate I would like to minimize unnecessary allocations. 
Is there any way to get D to allocate a class on the stack 
like a local struct?


The easy way is through std.typecons.scoped [1].
Here be dragons, though, because classes are reference types.

[1] https://dlang.org/phobos/std_typecons.html#.scoped


Thanks, I didn't think it created on the stack but it makes sense 
to do so. The only issue is that it escaping the reference?




[Issue 16474] CTFE pow

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16474

ki...@gmx.net changed:

   What|Removed |Added

 CC||ki...@gmx.net

--- Comment #11 from ki...@gmx.net ---
(In reply to uplink.coder from comment #10)
> (In reply to kinke from comment #9)
> > 
> > So how does newCTFE interact with CTFloat at the moment? This is an
> > important piece for cross-compilers. And is there an estimate for when
> > newCTFE will land?
> 
> It does currently not use CTFloat at all.
> It only implements add, sub, mul and div and mod for floats/doubles.
> As well as float <=> double <=> long/int casts.

[Sorry about hijacking this issue.] Okay, but as guys clearly expect most of
the math functionality to be available at CTFE too, newCTFE will eventually
have to feature a similar system of CTFE builtins (ddmd.builtin). Currently, it
plugs into function calls and tries to match the callee name in a map of
mangled name => CTFE implementation. The builtins are required for functions
whose source code isn't available for CTFE, such as compiler intrinsics, inline
assembly and C library functions.

So newCTFE discriminates between 32-bit float and 64-bit double but lacks
support for real_t, as opposed to the current interpreter, which uses real_t
exclusively (in RealExp). So the current floating-point builtin implementations
expect host/compiler-specific real_t values, but extending those to allow for
all 3 (float, double, real_t) should be straightforward.

newCTFE should at some point support real_t and use it to represent target
reals at compile-time. It's most likely the host real type, but it may also be
a software implementation as custom type with overloaded binops (GDC afaik,
possibly LDC at some point), with a specific size and alignment, and more
advanced functionality provided by helper struct CTFloat.

--


Re: d_to_html.d

2017-08-05 Thread David Gileadi via Digitalmars-d-announce

On 8/5/17 12:07 PM, WebFreak001 wrote:
Hi, I made a D to HTML generator which is basically diet, but fully 
using the D compiler as generator and not some complicated parser, etc. 


[snip]

That is amazing! I can't decide whether it's the best thing I've ever 
seen or a horrible hack, but it's a great showcase for what you can do 
with D.


Re: Did dmd forget how to read?

2017-08-05 Thread Cym13 via Digitalmars-d

On Saturday, 5 August 2017 at 23:54:45 UTC, Johnson Jones wrote:
main.d(157): Error: no property 'SetCursor' for type 
'gdk.Window.Window', did you mean 'getCursor'?


um... anyone see bug? It's there, I promise.


"setCursor" exists, but "SetCursor" doesn't (or your "bug" 
depends on code that you wrote and didn't share). I believe as 
both "setCursor" and "getCursor" are one character away from 
"SetCursor" dmd took the first one in alphabetic order or 
something. No need to panic ;)


[Issue 16191] std/digest/digest.d should be renamed to package.d

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16191

Vladimir Panteleev  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=17724

--


[Issue 17724] digest is not a template declaration, it is a module

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17724

Vladimir Panteleev  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=16191

--


[Issue 17724] New: digest is not a template declaration, it is a module

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17724

  Issue ID: 17724
   Summary: digest is not a template declaration, it is a module
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: regression
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: dlang-bugzi...@thecybershadow.net

/ test.d 
import std.digest.digest;
import std.digest.md;

alias foo = digest!MD5;
/

test.d(4): Error: std.digest.digest at test.d(1) conflicts with
std.digest.digest(Hash, Range)(auto ref Range range) if (!isArray!Range &&
isDigestibleRange!Range) at .../phobos/std/digest/package.d(432)
test.d(4): Error: template instance digest!MD5 digest is not a template
declaration, it is a module

--


Did dmd forget how to read?

2017-08-05 Thread Johnson Jones via Digitalmars-d
main.d(157): Error: no property 'SetCursor' for type 
'gdk.Window.Window', did you mean 'getCursor'?


um... anyone see bug? It's there, I promise.




[Issue 16474] CTFE pow

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16474

--- Comment #10 from uplink.co...@googlemail.com ---
(In reply to kinke from comment #9)
> 
> So how does newCTFE interact with CTFloat at the moment? This is an
> important piece for cross-compilers. And is there an estimate for when
> newCTFE will land?

It does currently not use CTFloat at all.
It only implements add, sub, mul and div and mod for floats/doubles.
As well as float <=> double <=> long/int casts.

--


Re: Getting enum from value

2017-08-05 Thread Kreikey via Digitalmars-d-learn

On Saturday, 5 August 2017 at 20:11:27 UTC, Matthew Remmel wrote:

On Saturday, 5 August 2017 at 18:26:10 UTC, Kreikey wrote:

On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel


I'm annoyed that I didn't think of trying to cast it. That 
works great if the value exists in the enum. It does something 
weird if the value doesn't though. This is my test.d file:


import std.stdio;

enum Foo {
A = "AV",
B = "BV"
}

void main() {
Foo k = cast(Foo)"BV"; // Works and prints correctly

k = cast(Foo)"CV";
writeln("Type: ", typeid(k));  // Type: test.Foo
writeln("Value: ", k);   // Value: cast(Foo)CV
}

The output shows the type being the Foo enum but the value is 
'cast(Foo)CV'. I would of expected an error or exception to be 
thrown if it wasn't able to cast into an actual enum member. Is 
this something with how the enums are implemented under the 
hood?


That was my first post on this forum, so I'm glad it was at least 
a little bit useful :-D
I think the reasoning for no error on bad casts is that casting 
is a blunt instrument that assumes the programmer knows what he's 
doing, and it breaks the type system. So you'd want to use one of 
the aforementioned solutions if you're set on using enums in this 
way. You might also consider using associative arrays, but it's 
also a bit cumbersome. There's no way to get around searching:


  capitals = [
"Indiana" : "Indianapolis",
"Illinois" : "Chicago",
"Ohio" : "Columbus"
  ];
  auto r = capitals.byKeyValue.find!((a, b) => a.value == 
b)("Chicago");

  if (!r.empty) {
writeln(capitals[r.front.key]);
  } else {
writeln("not found");
  }

You could also define another associative array statesByCapital 
with the key : value orders reversed, and then you could also do 
statesByCapitol["Chicago"]. Of course then you'd have to keep 
things in sync if things change. But I discovered a neat trick 
you could use to generate such a two way mapping. You could 
define one array string[] capitals, and another array string[] 
states. Then you could do:


auto capitalsByState = assocArray(zip(states, capitals));
auto statesByCapital = assocArray(zip(capitals, states));

If your data doesn't change for the lifetime of the program, that 
looks like a nice way to do it.


Re: Create class on stack

2017-08-05 Thread Moritz Maxeiner via Digitalmars-d-learn

On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote:
using gtk, it has a type called value. One has to use it to get 
the value of stuff but it is a class. Once it is used, one 
doesn't need it.


Ideally I'd like to treat it as a struct since I'm using it in 
a delegate I would like to minimize unnecessary allocations. Is 
there any way to get D to allocate a class on the stack like a 
local struct?


The easy way is through std.typecons.scoped [1].
Here be dragons, though, because classes are reference types.

[1] https://dlang.org/phobos/std_typecons.html#.scoped


Re: newCTFE Status August 2017

2017-08-05 Thread Stefan Koch via Digitalmars-d

On Tuesday, 1 August 2017 at 21:27:32 UTC, Stefan Koch wrote:

[ ... ]


The following code does now compile with newCTFE,
and it's a little faster then the old interpreter.
Not much though since that is not a pathological case.

pure nothrow @nogc @safe uint[256][8] genTables32(uint 
polynomial)

{
uint[256][8] res = 0u;
{
int __key479 = 0;
int __limit480 = 256;
for (; __key479 < __limit480; __key479 += 1)
{
int i = __key479;
uint crc = cast(uint)i;
{
int __key481 = 0;
int __limit482 = 8;
for (; __key481 < __limit482; __key481 += 1)
{
int _ = __key481;
crc = crc >> 1 ^ cast(uint)-cast(int)(crc 
& 1u) & polynomial;

}
}
res[0][i] = crc;
}
}
{
int __key483 = 0;
int __limit484 = 256;
for (; __key483 < __limit484; __key483 += 1)
{
int i = __key483;
res[1][i] = res[0][i] >> 8 ^ res[0][(res[0][i] & 
255u)];
res[2][i] = res[1][i] >> 8 ^ res[0][(res[1][i] & 
255u)];
res[3][i] = res[2][i] >> 8 ^ res[0][(res[2][i] & 
255u)];
res[4][i] = res[3][i] >> 8 ^ res[0][(res[3][i] & 
255u)];
res[5][i] = res[4][i] >> 8 ^ res[0][(res[4][i] & 
255u)];
res[6][i] = res[5][i] >> 8 ^ res[0][(res[5][i] & 
255u)];
res[7][i] = res[6][i] >> 8 ^ res[0][(res[6][i] & 
255u)];

}
}
return res;
}


static immutable tables = genTables32(0xEDB88320);
static assert(tables[0][0] == 0x && tables[0][$ - 1] 
== 0x2d02ef8d && tables[7][$ - 1] == 0x264b06e6);




[Issue 16474] CTFE pow

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16474

--- Comment #9 from ki...@gmx.net ---
(In reply to uplink.coder from comment #7)
> (In reply to ZombineDev from comment #6)
> > Manu, you may be interested in trying LDC as it will soon support much more
> > intrinsics at CTFE than dmd. For reference:
> > https://github.com/ldc-developers/ldc/pull/2259 I'm not sure if specifically
> > the pow operator is supported (though pow is supported as a function call).

I started that work due to a recent ping of this issue and me accidentally
noticing it. ;)
So the pow operator is working with that PR for LDC; there a static assert in
the last line of the test.

> Do they interface with the CTFE engine ?
> That'd be crazy :)

I detect a few more key primitive functions (ldexp, isNaN, isInfinity,
isFinite...) as builtins and forward to proper implementations in CTFloat. I
also had to make std.math.exp2() CTFE-able for 80-bit reals by not using the
inline assembly code for CTFE. DMD may need a few more builtins or
CTFE-friendly Phobos implementations to get all of this working as well; I'll
open a DMD PR for the ones required by LDC.

So how does newCTFE interact with CTFloat at the moment? This is an important
piece for cross-compilers. And is there an estimate for when newCTFE will land?

--


[Issue 16474] CTFE pow

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16474

--- Comment #8 from ZombineDev  ---
I don't think so, but see the PR for yourself ;)

--


Re: Please document packages/libraries before putting them on dub registry

2017-08-05 Thread solidstate1991 via Digitalmars-d

On Saturday, 5 August 2017 at 00:08:29 UTC, aberba wrote:
Those packages without documentation might be useful but no one 
except you will use it because only you know how and what it 
does. We spend hours writing code but can't spend minutes 
getting people to use them.


Intro
Purpose
Usage
...
To do
Contributions

Basic stuff.


I'm currently working on this alongside with my code.

Tip: Name all your variables after what they supposed to do, this 
further helps understanding your code. Using "foo" and "bar" 
might be trendy among programmers, but it can ruin code 
readability (to the point I once had to completely rewrite an 
algorithm instead of simply updating it).


Also can I skimp out on details if a certain function only 
supposed to simply return a value (eg. getters, I usually write 
some warnings for setters even if they're pretty short).


Re: Who maintains the D website?

2017-08-05 Thread Ecstatic Coder via Digitalmars-d

On Thursday, 3 August 2017 at 00:18:38 UTC, Andrej Mitrovic wrote:
Is there a single person who's the main maintainer of the D 
website..?



If not, I have some ideas on how to improve it. Not just ideas, 
I'd like to give a host at improving it myself, really.


Have a look at "python.org". 2nd language in PYPL, 5th at TIOBE...

Maybe there are some good things on this website that could be 
transposed to "dlang.org", like :

- "easy to learn"
- "easy to use"
- simple examples
- etc...


[Issue 16474] CTFE pow

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16474

--- Comment #7 from uplink.co...@googlemail.com ---
(In reply to ZombineDev from comment #6)
> Manu, you may be interested in trying LDC as it will soon support much more
> intrinsics at CTFE than dmd. For reference:
> https://github.com/ldc-developers/ldc/pull/2259 I'm not sure if specifically
> the pow operator is supported (though pow is supported as a function call).

Do they interface with the CTFE engine ?
That'd be crazy :)

--


Re: How do you use D?

2017-08-05 Thread Ecstatic Coder via Digitalmars-d
It is more about marketing. Maybe Go is not a perfect language, 
maybe not even a good one, but it's sold so good because of a 
good marketing


So, calling D a "better C++" is a bad advertisement. But if you 
rename it to 'Script', for example "DatScript" and 
sell it as "better, statically typed JavaScript dialect which 
compiles into fast native executables" it will became #1 
language on GitHub in no time.


+1

I've suggested exactly the same "easy-to-learn super-powered 
stronly-typed javascript" and "efficient web server development" 
advertising approachs to the D leadership, using a more 
"Python.org"-like website.


Maybe it's because this change would be much too radical, but 
I've been told that the "Better C++" slogan won't change, despite 
D could easily be "tweaked" to eat a significant part of 
Go/Dart's market shares.


And I'm not especially convinced that many C++ developers are 
currently rushing towards D because of the current website.


For instance, I've personally chosen D *only* it was much better 
than JavaScript/Node.js, not because it was better than C++, that 
I still have to use for game and mobile development.


Still waiting that somebody explains me how to _easily_ use D 
with Unreal Engine, Cocos2D-X, etc... ;)


I know I'm not the general case, but this still proves that 
"some" C++ developers won't switch to D for long because they are 
too tied to their ecosystem.




Re: returning D string from C++?

2017-08-05 Thread Jeremy DeHaan via Digitalmars-d-learn

On Saturday, 5 August 2017 at 20:17:23 UTC, bitwise wrote:
I have a Windows native window class in C++, and I need a 
function to return the window title.


[...]


As long as you have a reachable reference to the GC memory 
SOMEWHERE, the GC won't reclaim it. It doesn't have to be on the 
stack as long as it is reachable through the stack.


[Issue 16474] CTFE pow

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16474

ZombineDev  changed:

   What|Removed |Added

 CC||petar.p.ki...@gmail.com

--- Comment #6 from ZombineDev  ---
Manu, you may be interested in trying LDC as it will soon support much more
intrinsics at CTFE than dmd. For reference:
https://github.com/ldc-developers/ldc/pull/2259 I'm not sure if specifically
the pow operator is supported (though pow is supported as a function call).

--


Re: gtkD load images

2017-08-05 Thread ag0aep6g via Digitalmars-d-learn

On 08/05/2017 10:30 PM, Mike Wey wrote:

On 05-08-17 15:23, Johnson Jones wrote:

On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote:

[...]
There are two issues here, you need to properly escape the slash: 
"C:a.jpg".

[...]

```
Pixbuf p = new Pixbuf(r"C:\\a.jpg");
```


Thanks. Why do I need 4 slashes? Is that standard with gtk because 
strings are interpreted twice or something? Seemed to work though.





Nothing specific to GTK but in D and other programing languages the \ is 
used as an escape character, so you can use special characters in your 
sting like `\n` for a newline. But this means you will need to use \\ to 
get an literal back slash.


I think you missed the point of the question.

In the end, the path should contain only one backslash. But with 
`"C:a.jpg"` and `r"C:\\a.jpg"` you get two. Why do you need two? 
Does the library do another round of escape sequence handling?


Re: gtkD window centering message up and no app on taskbar

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 05-08-17 20:14, Johnson Jones wrote:
When trying to center the window. If one uses ALWAYS_CENTERED any 
resizing of the window is totally busted. CENTER also does not work. 
move(0,0) seems to not be relative to the main display. I'd basically 
like to center the window on the main display or at least be able to set 
coordinates properly. Windows sets (0,0) to be the lower left corner of 
the main display I believe. What happens is that the gtk window, when 
using 0,0 actually is like -1000,0 or something in windows coordinates 
and ends up on my secondary monitor.


When the app starts there's no taskbar icon. Luckily I still have the 
console shown but Eventually I'll need the taskbar. I'm not setting 
skipTaskBarHint, but I have tried both true and false without any 
difference.




gtk.Widget.translateCoordinates or gtk.Fixed could be useful for 
positioning the widgets.


Windows will only show the taskbar icon if you are not running the 
application from the console.


--
Mike Wey


Re: gtkD load images

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 05-08-17 15:23, Johnson Jones wrote:

On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote:

On 03-08-17 21:56, Johnson Jones wrote:

If I do something like

import gdkpixbuf.Pixbuf;
Pixbuf.newFromResource("C:\\a.jpg");


There are two issues here, you need to properly escape the slash: 
"C:a.jpg".


And a.jpg is not a resource file, so you would use the Pixbuf 
constuctor to load an image file.


```
Pixbuf p = new Pixbuf(r"C:\\a.jpg");
```


Thanks. Why do I need 4 slashes? Is that standard with gtk because 
strings are interpreted twice or something? Seemed to work though.





Nothing specific to GTK but in D and other programing languages the \ is 
used as an escape character, so you can use special characters in your 
sting like `\n` for a newline. But this means you will need to use \\ to 
get an literal back slash.


https://dlang.org/spec/lex.html#double_quoted_strings

You can also use an wysiwyg string by using `r"` at the start so what 
you type is what you get.


https://dlang.org/spec/lex.html#wysiwyg

--
Mike Wey


Re: Create class on stack

2017-08-05 Thread angel via Digitalmars-d-learn

On Saturday, 5 August 2017 at 17:08:32 UTC, Johnson Jones wrote:
using gtk, it has a type called value. One has to use it to get 
the value of stuff but it is a class. Once it is used, one 
doesn't need it.


Ideally I'd like to treat it as a struct since I'm using it in 
a delegate I would like to minimize unnecessary allocations. Is 
there any way to get D to allocate a class on the stack like a 
local struct?


Emplace ?
https://dlang.org/phobos/std_conv.html#emplace



returning D string from C++?

2017-08-05 Thread bitwise via Digitalmars-d-learn
I have a Windows native window class in C++, and I need a 
function to return the window title.


So in D, I have this:

// isn't D's ABI stable enough to just return this from C++
// and call it a string in the extern(C++) interface? anyways..
struct DString
{
size_t length;
immutable(char)* ptr;
string toString() { return ptr[0..length]; }
alias toString this;
}

extern(C++) interface NativeWindow {
DString getTitle() const;
}

and in C++, this:

class NativeWindow
{
public:
struct DString {
size_t length;
const char* ptr;
};

virtual DString getTitle() const {
DString ret;
ret.length = GetWindowTextLength(_hwnd) + 1;
ret.ptr = (const char*)gc_malloc(ret.length, 0xA, NULL);
GetWindowText(_hwnd, (char*)ret.ptr, ret.length);
return ret;
}
};

So while it's not generally safe to _store_ pointers to D's GC 
allocated memory exclusively in C++, I've read that D's GC scans 
the stack, and getTitle() is being called from D(and so, is on 
that stack..right?). So is the string I'm returning safe from GC 
collection?


  Thanks



Re: Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn

On Saturday, 5 August 2017 at 18:26:10 UTC, Kreikey wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel 
wrote:
I feel like I'm missing something, but there has to be an 
easier way to convert a value into an enum than switching over 
every possible value: i.e


[...]


Capitals c = cast(Capitals)"Chicago";
writeln(c);// Illinois


I'm annoyed that I didn't think of trying to cast it. That works 
great if the value exists in the enum. It does something weird if 
the value doesn't though. This is my test.d file:


import std.stdio;

enum Foo {
A = "AV",
B = "BV"
}

void main() {
Foo k = cast(Foo)"BV"; // Works and prints correctly

k = cast(Foo)"CV";
writeln("Type: ", typeid(k));  // Type: test.Foo
writeln("Value: ", k);   // Value: cast(Foo)CV
}

The output shows the type being the Foo enum but the value is 
'cast(Foo)CV'. I would of expected an error or exception to be 
thrown if it wasn't able to cast into an actual enum member. Is 
this something with how the enums are implemented under the hood?


Re: lambda function with "capture by value"

2017-08-05 Thread Temtaime via Digitalmars-d-learn

On Saturday, 5 August 2017 at 19:19:06 UTC, Simon Bürger wrote:

On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote:

Maybe std.functional.partial can help you.


Nope.

int i = 1;
alias dg = partial!(writeln, i);
i = 2;
dg();

still prints '2' as it should because 'partial' takes 'i' as a 
symbol, which is - for this purpose - kinda like "by reference".


Anyway, I solved my problem already a while ago by replacing 
delegates with custom struct's that implement the 
call-operator. I started this thread just out of curiosity, 
because as I see it, the purpose of lambdas is pretty much to 
remove the need for such custom constructions.


This one works

void delegate()[3] dgs;
for(int i = 0; i < 3; ++i)
{
(k){ dgs[k] = {writefln("%s", k); }; }(i);
}

dgs.each!(a => a());


Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn

On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote:

Maybe std.functional.partial can help you.


Nope.

int i = 1;
alias dg = partial!(writeln, i);
i = 2;
dg();

still prints '2' as it should because 'partial' takes 'i' as a 
symbol, which is - for this purpose - kinda like "by reference".


Anyway, I solved my problem already a while ago by replacing 
delegates with custom struct's that implement the call-operator. 
I started this thread just out of curiosity, because as I see it, 
the purpose of lambdas is pretty much to remove the need for such 
custom constructions.


d_to_html.d

2017-08-05 Thread WebFreak001 via Digitalmars-d-announce
Hi, I made a D to HTML generator which is basically diet, but 
fully using the D compiler as generator and not some complicated 
parser, etc. Here an example what you pass in:


string page = html(
head(
title("wtf is this"),
style(
html(
font-family = "Roboto",
background = 0xEFEFEF
),
div.content(
max-width = 800.px,
margin = auto_,
margin-top = 32.px,
box-shadow = "0 2px 5px rgba(0, 0, 0, 0.3)",
background = white,
padding = 32.px
),
div.footer(
text-"align" = center
)
)
),
body(
div.content(
h1("The most crappy HTML generator ever"),
div.teaser(
p("Super fast")
),
hr,
p("Reasons why you should use d_to_html:"),
ul(
li("TODO: no reason yet") * 5
)
),
div.footer(
p(raw!" 2017 webfreak.org")
)
)
).toString;

Which generates: https://i.webfreak.org/fStzn0.html

Full source: 
https://gist.github.com/WebFreak001/6a1916779e48898c7ababc47a3113829


Though some things (like min and max for example) won't work 
correctly, so you need to manually write `attr!"min" = 4` if you 
wanted to add that to an input element.


btw this is just a joke project, it's totally abusing operator 
overloading just to show what is possible with it. The idea came 
up in Wild's discord server, you can join us too, we have a 
programming and a dplug channel: 
https://discordapp.com/invite/bMZk9Q4


Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn

On Saturday, 5 August 2017 at 18:54:22 UTC, ikod wrote:

On Saturday, 5 August 2017 at 18:45:34 UTC, Simon Bürger wrote:

On Saturday, 5 August 2017 at 18:22:38 UTC, Stefan Koch wrote:

[...]


No, sometimes I want i to be the value it has at the time the 
delegate was defined. My actual usecase was more like this:


void delegate()[3] dgs;
for(int i = 0; i < 3; ++i)
dgs[i] = (){writefln("%s", i); };


And I want three different delegates, not three times the 
same. I tried the following:


void delegate()[3] dgs;
for(int i = 0; i < 3; ++i)
{
int j = i;
dgs[i] = (){writefln("%s", j); };
}

I thought that 'j' should be considered a new variable each 
time around, but sadly it doesn't work.


Maybe std.functional.partial can help you.


Thanks. But std.functional.partial takes the fixed arguments as 
template parameters, so they must be known at compile-time. 
Anyway, I solved my problem already a while ago by replacing 
delegates with custom structures which overload the 
call-operator. I opened this thread just out of curiosity. Takes 
a couple lines more but works fine.


Re: lambda function with "capture by value"

2017-08-05 Thread ikod via Digitalmars-d-learn

On Saturday, 5 August 2017 at 18:45:34 UTC, Simon Bürger wrote:

On Saturday, 5 August 2017 at 18:22:38 UTC, Stefan Koch wrote:

[...]


No, sometimes I want i to be the value it has at the time the 
delegate was defined. My actual usecase was more like this:


void delegate()[3] dgs;
for(int i = 0; i < 3; ++i)
dgs[i] = (){writefln("%s", i); };


And I want three different delegates, not three times the same. 
I tried the following:


void delegate()[3] dgs;
for(int i = 0; i < 3; ++i)
{
int j = i;
dgs[i] = (){writefln("%s", j); };
}

I thought that 'j' should be considered a new variable each 
time around, but sadly it doesn't work.


Maybe std.functional.partial can help you.


Re: lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn

On Saturday, 5 August 2017 at 18:22:38 UTC, Stefan Koch wrote:

On Saturday, 5 August 2017 at 18:19:05 UTC, Stefan Koch wrote:

On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote:
If a lambda function uses a local variable, that variable is 
captured using a hidden this-pointer. But this capturing is 
always by reference. Example:


int i = 1;
auto dg = (){ writefln("%s", i); };
i = 2;
dg(); // prints '2'

Is there a way to make the delegate "capture by value" so 
that the call prints '1'?


Note that in C++, both variants are available using
  [&]() { printf("%d", i); }
and
   [=]() { printf("%d", i); }
respectively.


No currently there is not.


and it'd be rather useless I guess.
You want i to be whatever the context i is a the point where 
you call the delegate.

Not at the point where you define the delegate.


No, sometimes I want i to be the value it has at the time the 
delegate was defined. My actual usecase was more like this:


void delegate()[3] dgs;
for(int i = 0; i < 3; ++i)
dgs[i] = (){writefln("%s", i); };


And I want three different delegates, not three times the same. I 
tried the following:


void delegate()[3] dgs;
for(int i = 0; i < 3; ++i)
{
int j = i;
dgs[i] = (){writefln("%s", j); };
}

I thought that 'j' should be considered a new variable each time 
around, but sadly it doesn't work.


Re: lambda function with "capture by value"

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn

On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote:
If a lambda function uses a local variable, that variable is 
captured using a hidden this-pointer. But this capturing is 
always by reference. Example:


int i = 1;
auto dg = (){ writefln("%s", i); };
i = 2;
dg(); // prints '2'

Is there a way to make the delegate "capture by value" so that 
the call prints '1'?


Note that in C++, both variants are available using
   [&]() { printf("%d", i); }
and
   [=]() { printf("%d", i); }
respectively.


There is, but it isn't pretty.

import std.stdio;

void main()
{
int i = 1;
int* n = null;
auto dg = (){ if (n is null) n = cast(int*)i; else writefln("%s", 
n); }; dg();

i = 2;
dg(); // prints '1'
}


1. I'm pretty sure that D creates the delegate "lazily" in the 
sense that the first call is what captures the variable. Hence, 
we must call it where we want to capture, not after the change 
occurs.


2. We use a temp local variable to act as a place holder. A 
singleton basically.


You might be able to wrap this up in some type of template that 
makes it easier to use but it does work.





Re: Getting enum from value

2017-08-05 Thread Kreikey via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote:
I feel like I'm missing something, but there has to be an 
easier way to convert a value into an enum than switching over 
every possible value: i.e


[...]


Capitals c = cast(Capitals)"Chicago";
writeln(c);// Illinois


Re: lambda function with "capture by value"

2017-08-05 Thread Stefan Koch via Digitalmars-d-learn

On Saturday, 5 August 2017 at 18:19:05 UTC, Stefan Koch wrote:

On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote:
If a lambda function uses a local variable, that variable is 
captured using a hidden this-pointer. But this capturing is 
always by reference. Example:


int i = 1;
auto dg = (){ writefln("%s", i); };
i = 2;
dg(); // prints '2'

Is there a way to make the delegate "capture by value" so that 
the call prints '1'?


Note that in C++, both variants are available using
  [&]() { printf("%d", i); }
and
   [=]() { printf("%d", i); }
respectively.


No currently there is not.


and it'd be rather useless I guess.
You want i to be whatever the context i is a the point where you 
call the delegate.

Not at the point where you define the delegate.



Re: lambda function with "capture by value"

2017-08-05 Thread Stefan Koch via Digitalmars-d-learn

On Saturday, 5 August 2017 at 18:17:49 UTC, Simon Bürger wrote:
If a lambda function uses a local variable, that variable is 
captured using a hidden this-pointer. But this capturing is 
always by reference. Example:


int i = 1;
auto dg = (){ writefln("%s", i); };
i = 2;
dg(); // prints '2'

Is there a way to make the delegate "capture by value" so that 
the call prints '1'?


Note that in C++, both variants are available using
   [&]() { printf("%d", i); }
and
   [=]() { printf("%d", i); }
respectively.


No currently there is not.


lambda function with "capture by value"

2017-08-05 Thread Simon Bürger via Digitalmars-d-learn
If a lambda function uses a local variable, that variable is 
captured using a hidden this-pointer. But this capturing is 
always by reference. Example:


int i = 1;
auto dg = (){ writefln("%s", i); };
i = 2;
dg(); // prints '2'

Is there a way to make the delegate "capture by value" so that 
the call prints '1'?


Note that in C++, both variants are available using
   [&]() { printf("%d", i); }
and
   [=]() { printf("%d", i); }
respectively.


gtkD window centering message up and no app on taskbar

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
When trying to center the window. If one uses ALWAYS_CENTERED any 
resizing of the window is totally busted. CENTER also does not 
work. move(0,0) seems to not be relative to the main display. I'd 
basically like to center the window on the main display or at 
least be able to set coordinates properly. Windows sets (0,0) to 
be the lower left corner of the main display I believe. What 
happens is that the gtk window, when using 0,0 actually is like 
-1000,0 or something in windows coordinates and ends up on my 
secondary monitor.


When the app starts there's no taskbar icon. Luckily I still have 
the console shown but Eventually I'll need the taskbar. I'm not 
setting skipTaskBarHint, but I have tried both true and false 
without any difference.





Re: newCTFE Status August 2017

2017-08-05 Thread Stefan Koch via Digitalmars-d

On Tuesday, 1 August 2017 at 21:27:32 UTC, Stefan Koch wrote:

[ ... ]


After a surprisingly small amount of work we are now supporting 
pointers to array-items.
It should be quite doable to add bounds-checked pointer with 
minimal amount of work.
(Note this is only for 1D arrays/Slices ... Mulidimensional 
Arrays/Slices still have issues preventing that)


The following video shows what needed to happen:
https://www.youtube.com/watch?v=QHwIEd8E5mE

example code that now works:

int* getAPtr(int[] arr)
{
  // assert(a.length > 1);
  return [1];
}

static assert(getAPtr([1, 2, 3]) == 2);


Re: Getting enum from value

2017-08-05 Thread ag0aep6g via Digitalmars-d-learn

On 08/05/2017 07:05 PM, ag0aep6g wrote:

E enumFromValue(E)(string s)


The type of `s` should probably be a template parameter as well.


Re: Getting enum from value

2017-08-05 Thread ag0aep6g via Digitalmars-d-learn

On 08/05/2017 05:33 PM, Matthew Remmel wrote:
I feel like I'm missing something, but there has to be an easier way to 
convert a value into an enum than switching over every possible value: i.e


enum Capitals {
 Indiana = "Indianapolis",
 Illinois = "Chicago",
 Ohio = "Columbus"
}

Capitals enumFromValue(string s) {
 switch (s) {
 case Capitals.Indiana:
 return Capitals.Indiana;
  case Capitals.Illinois:
 return Capitals.Illinois;
  case Capitals.Ohio:
 return Capitals.Ohio;
  default:
  throw new Exception(format("No Capitals enum member with 
value %s", s));

 }
}

int main() {
 Capitals c = enumFromValue("Chicago"); // works

 // I tried using std.conv, but it matches on the enum member name
 c = to!Capitals("Chicago") // fails, no member named Chicago
}

With how redundant the enumFromValue(string) implementation is, I would 
think there would be an easier way to do it. I'm sure you could use a 
mixin, a template, or std.traits. I was hoping there was a more 
'builtin' way to do it though. Something along the simplicity of:


int main() {
 Capitals c = Capitals("Chicago");
}

Any ideas?


As far as I know, there's no built-in way to do this. But you can 
simplify and generalize your `enumFromValue`:



enum Capitals
{
Indiana = "Indianapolis",
Illinois = "Chicago",
Ohio = "Columbus"
}

E enumFromValue(E)(string s)
{
import std.format: format;
import std.traits: EnumMembers;
switch (s)
{
foreach (c; EnumMembers!E)
{
case c: return c;
}
default:
immutable string msgfmt = "enum %s has no member with value %s";
throw new Exception(format(msgfmt, E.stringof, s));
}
}

void main()
{
auto c = enumFromValue!Capitals("Chicago");
assert(c == Capitals.Illinois);
}



Create class on stack

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
using gtk, it has a type called value. One has to use it to get 
the value of stuff but it is a class. Once it is used, one 
doesn't need it.


Ideally I'd like to treat it as a struct since I'm using it in a 
delegate I would like to minimize unnecessary allocations. Is 
there any way to get D to allocate a class on the stack like a 
local struct?


Re: Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel 
wrote:

Any ideas?


You can use to! in std.conv:


import std.stdio;
import std.conv;

enum Foo
{
A = "A",
B = "B"
}

void main()
{
writeln("A".to!Foo);  
}


This only works because the enum name and the value are the same. 
Its actually converting on the enum name, which happens to be the 
same as the value. This doesn't work if the values is different:


enum Foo {
A = "AV",
B = "BV"
}

int main() {
writeln("AV".to!Foo); // Throws exceptions
return 0;
}

It looks like Temtaime's solution works:


enum Foo
{
A = "AV",
B = "BV",
C = "CV",
}



Foo K = [ EnumMembers!Foo ].find!(a => a == `BV`)[0];


I can probably make a template or something out of this to make 
the syntax simpler.


Re: Size of D bool vs size of C++ bool

2017-08-05 Thread Jeremy DeHaan via Digitalmars-d-learn
On Friday, 4 August 2017 at 20:38:16 UTC, Steven Schveighoffer 
wrote:

On 8/4/17 4:16 PM, Jeremy DeHaan wrote:
I'm trying to do some binding code, and I know that C++ bool 
isn't defined to be a specific size like D's bool. That said, 
can I assume that the two are the same size on the most 
platforms?


I shudder to think that D may work with a platform that doesn't 
consider it to be 1 byte :)


The only platforms I'm really interested in are Windows, 
Linux, OSX, iOS, FreeBSD, Android. The only thing that might 
throw me off is if there are some things that Linux or FreeBSD 
target where this is not the case, but these machines are 
probably out of the scope of my project.


I would say any platform that D currently supports, C++ bool is 
defined to be 1 byte.


The ldc/gdc guys would know better.

-Steve


Thanks, Steve. I was hoping this was the case and it will 
significantly simplify a lot of my binding code.


I'm curious to see what systems don't have a bool size of 1 byte, 
but perhaps I'll put a check in my CMake file and prevent the 
project from building if it isn't.


Re: gtk get actual pixel height of widget

2017-08-05 Thread FoxyBrown via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:23:15 UTC, Johnson Jones wrote:
I am trying to set positions of widgets automatically. e.g., I 
have a paned widget and I to set the position of the handle 
manually based on a percentage of the window. e.g., 0.5 will 
set the handle midway and both children will have the same 
height. I 0.2 will set it to to 20%.


[...]


Sorry, I think I was running my code before the window was 
actually being shown and I guess these values are not set until 
the actual display of the window.


Re: Getting enum from value

2017-08-05 Thread Temtaime via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:42:53 UTC, Rene Zwanenburg wrote:
On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel 
wrote:

Any ideas?


You can use to! in std.conv:


import std.stdio;
import std.conv;

enum Foo
{
A = "A",
B = "B"
}

void main()
{
writeln("A".to!Foo);  
}


Are you fools ?
Did you ever read the post ?

I think this is a minimal solution:

enum Foo
{
A = "AV",
B = "BV",
C = "CV",
}

Foo K = [ EnumMembers!Foo ].find!(a => a == `BV`)[0];


Re: Jetbrains announce support for rust plugin, show them we want one too!

2017-08-05 Thread Russel Winder via Digitalmars-d
On Sat, 2017-08-05 at 13:16 +, Dmitry via Digitalmars-d wrote:
> 
[…]
> I'm an one who needed a good IDE (+debugger) support. But 
> unfortunately I'm not found a good one for D.
> I have small skills in D, so my abilities is very limited 
> (translate something to another language, etc). And I'm not sure 
> that I'll be able grow it well without a good IDE, because
> then I'd prefer other solid ecosystems for any serious projects.

As far as I can tell there are no good D development environments in the way
there are C++, Go, Rust ones. I have no idea about Visual D since that
involves Visual Studio which I think involves Windows and possibly money –
though paying for a good development environment does usually imply better
quality, support and maintenance.

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc
Description: This is a digitally signed message part


[Issue 17723] Replace Facebook on the front page with Weka.io

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17723

Richard Cattermole  changed:

   What|Removed |Added

 CC||alphaglosi...@gmail.com

--- Comment #1 from Richard Cattermole  ---
If Netflix were willing, it would probably be a better choice.

But no reason we cannot have one chosen from a couple, randomly per
request/day.

--


[Issue 17723] New: Replace Facebook on the front page with Weka.io

2017-08-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17723

  Issue ID: 17723
   Summary: Replace Facebook on the front page with Weka.io
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: shish...@hotmail.com

To the best of my knowledge, Facebook is no longer actively using D
while I don't object to keeping Facebook in the "Orgs Using D" page 
putting it on the front page feel deceptive 

I think we should replace it by a company that actively use D, such as Weka or
others

--


Re: How to build GUI-based applications in D ?

2017-08-05 Thread ashit via Digitalmars-d-learn

thank you everybody for your time to answer my questions.


Re: How to build GUI-based applications in D ?

2017-08-05 Thread ashit via Digitalmars-d-learn

On Saturday, 5 August 2017 at 07:10:50 UTC, aberba wrote:
The DlangUI docs has you covered with everything you need to 
set it up both on the github README file or the github wiki.


Its just:

dub init PROJECT_NAME dlangui


This will create project and add dlangui as dependency. 
Creating a project requires Internet connection to download the 
dlangui package. You may also add dlangui as a dependency in 
the project's dub.json file.


thank you aberba

ok, so this is useless to me.
i want something fully functional stand-alone tools.
i have no internet connection there.




Re: Getting enum from value

2017-08-05 Thread Rene Zwanenburg via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote:

Any ideas?


You can use to! in std.conv:


import std.stdio;
import std.conv;

enum Foo
{
A = "A",
B = "B"
}

void main()
{
writeln("A".to!Foo);  
}


Re: Getting enum from value

2017-08-05 Thread Stefan Koch via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:33:57 UTC, Matthew Remmel wrote:
I feel like I'm missing something, but there has to be an 
easier way to convert a value into an enum than switching over 
every possible value: i.e


[...]


What you want is already in the standard library.
std.conv.to can convert strings to enums and back.


Re: gtk: get property

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:19:43 UTC, Gerald wrote:

On Saturday, 5 August 2017 at 15:08:21 UTC, Johnson Jones wrote:
I am trying to get the handle size of panned. Not sure if I'm 
doing it right but


[...]


I'm using this in Tilix:

Value handleSize = new Value(0);
paned.styleGetProperty("handle-size", handleSize);


Awesome! Thanks! I didn't see that method in the list of 1000's 
of function in Visual D ;/ Figured everything that was a getter 
started with get.







Getting enum from value

2017-08-05 Thread Matthew Remmel via Digitalmars-d-learn
I feel like I'm missing something, but there has to be an easier 
way to convert a value into an enum than switching over every 
possible value: i.e


enum Capitals {
Indiana = "Indianapolis",
Illinois = "Chicago",
Ohio = "Columbus"
}

Capitals enumFromValue(string s) {
switch (s) {
case Capitals.Indiana:
return Capitals.Indiana;
 case Capitals.Illinois:
return Capitals.Illinois;
 case Capitals.Ohio:
return Capitals.Ohio;
 default:
 throw new Exception(format("No Capitals enum member 
with value %s", s));

}
}

int main() {
Capitals c = enumFromValue("Chicago"); // works

// I tried using std.conv, but it matches on the enum member 
name

c = to!Capitals("Chicago") // fails, no member named Chicago
}

With how redundant the enumFromValue(string) implementation is, I 
would think there would be an easier way to do it. I'm sure you 
could use a mixin, a template, or std.traits. I was hoping there 
was a more 'builtin' way to do it though. Something along the 
simplicity of:


int main() {
Capitals c = Capitals("Chicago");
}

Any ideas?


gtk get actual pixel height of widget

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
I am trying to set positions of widgets automatically. e.g., I 
have a paned widget and I to set the position of the handle 
manually based on a percentage of the window. e.g., 0.5 will set 
the handle midway and both children will have the same height. I 
0.2 will set it to to 20%.


I want it to retain this proportion when the window is resized.

The problem is I cannot get get the paned widgets actual 
height(nor the handle size).


paned.getHeight() returns -1.

If I use the main window's height, things go wonky because, I 
guess the border size and title bar size skew the calculations.


I'm still learning this api and how it all functions and works. 
Some things are not so obvious nor logical. getHeight should 
return the height. If -1 means "leave it up to the internals" 
then there should be some other height function that works like 
getActualHeight() but there isn't or I can't find anything that 
works.


If I do


writeln(mainPaned.getAllocatedHeight());

writeln(mainPaned.getChild1.getAllocatedHeight());  

writeln(mainPaned.getChild2.getAllocatedHeight());



then I get something like

800
1
1

where 800 is the height I used to set the window using

auto width = 1000, height = 800;
mainWindow.resize(width,height);

which, I'd expect it to actually be smaller as either it doesn't 
take in to account the titlebar or the resize function above is 
not for the full application window.






Re: gtk: get property

2017-08-05 Thread Gerald via Digitalmars-d-learn

On Saturday, 5 August 2017 at 15:08:21 UTC, Johnson Jones wrote:
I am trying to get the handle size of panned. Not sure if I'm 
doing it right but


[...]


I'm using this in Tilix:

Value handleSize = new Value(0);
paned.styleGetProperty("handle-size", handleSize);


Re: ASCII-ART mandelbrot running under newCTFE

2017-08-05 Thread Igor Shirkalin via Digitalmars-d

On Friday, 4 August 2017 at 22:50:03 UTC, Stefan Koch wrote:

Hey Guys,
I just trans-compiled a brainfuck mandelbrot into ctfeable D.
newCTFE is able to execute it correctly (although it takes 3.5 
minutes to do so).


The code is here
https://gist.github.com/UplinkCoder/d4e4426e6adf9434e34529e8e1f8cb47

The gist it evaluates the function at runtime since the newCTFE 
version capable of running this, is not yet available as a 
preview release.


If you want a laugh you can compile the code with ldc and -Oz 
flag set.
LLVM will detect that the function is pure and will try to 
constant-fold it.
I do not know how long this takes though since my patience is 
limited.


Cheers,
Stefan
I have interest in mandelbtott. Some day, a long time ago, when 
turbo pascal was the part of the world and EGA monitors had 
320x240x1 bytes per pixel... That time it was interesting to 
algorithm to go around the Mandelbrott set because of one theorem 
where every point of manfelbrott set has continious connection 
with any other point. If I have time I'd love to write it in D.




gtk: get property

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn
I am trying to get the handle size of panned. Not sure if I'm 
doing it right but


Value value = new Value();
paned.getProperty("handle-size", value);


GLib-GObject-CRITICAL **: g_object_get_property: assertion 
'G_IS_VALUE (value)' failed


or I get stuff like

GLib-GObject-WARNING **: g_object_get_property: object class 
'GtkStyle' has no property named 'handle-size'


if I do

mainPaned.getStyle().getProperty("handle-size", value);

I haven't been able to figure out how to get it.


I've also tried

mainPaned.getStyle().getStyleProperty(...

but the first parameter is a GType which is suppose to be the 
widget type yet I am getting value types like INT BOOl, etc.


Not sure if there are two types of GTypes

enum GType : size_t
{
INVALID = 0<<2,
NONE = 1<<2,
INTERFACE = 2<<2,
CHAR = 3<<2,
UCHAR = 4<<2,
BOOLEAN = 5<<2,
INT = 6<<2,
UINT = 7<<2,
LONG = 8<<2,
ULONG = 9<<2,
INT64 = 10<<2,
UINT64 = 11<<2,
ENUM = 12<<2,
FLAGS = 13<<2,
FLOAT = 14<<2,
DOUBLE = 15<<2,
STRING = 16<<2,
POINTER = 17<<2,
BOXED = 18<<2,
PARAM = 19<<2,
OBJECT = 20<<2,
VARIANT = 21<<2,
}

If that what I'm suppose to use then not sure which one I use for 
Paned ;)







Re: ASCII-ART mandelbrot running under newCTFE

2017-08-05 Thread Timon Gehr via Digitalmars-d

On 05.08.2017 02:59, Johnson Jones wrote:



Any screenshots? I don't wanna have to install something I won't use but 
once or twice but would be interested in seeing what is going on since I 
used to be a fractal freak ;)


https://dpaste.dzfl.pl/d7791f4e2845


Re: Remove instance from array

2017-08-05 Thread Igor Shirkalin via Digitalmars-d-learn

On Wednesday, 5 July 2017 at 16:04:16 UTC, Jolly James wrote:

On Wednesday, 5 July 2017 at 15:56:45 UTC, Igor Shirkalin wrote:

On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote:
On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin 
wrote:

On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:

WhatEver[] q = [];

[...]

auto i = new WhatEver();
q[] = i;



How does one remove that instance 'i'?


What exactly do you want to remove? After a[]=i your array 
contain a lot of references to 'i'.


I would like to know how works: removing
 - the first
 - and all
references to 'i' inside the 'q'.


Perhaps, for all references to i it should look like:
a = a.filter!(a => a !is i).array;


Thank you! :)


But why a containers so complicated in D?

In C# I would go for a generic List, which would support 
structs and classes, where I simply could call '.Remove(T 
item)' or '.RemoveAt(int index)'. I would know how this works, 
because the method names make sense, the docs are straight 
forward.


Here in D everything looks like climbing mount everest. When 
you ask how to use D's containers you are recommended to use 
dynamic arrays instead. When you look at the docs for 
std.algorithm, e.g. the .remove section, you get bombed with 
things like 'SwapStrategy.unstable', asserts and tuples, but 
you aren't told how to simply remove 1 specific element.


I don't know c sharp, but I can tell everything about c++ and 
python. To climb a everest in python you have to know almost 
nothing, in c++ you have to know almost everything. In D you have 
to be smarter, you do not need to climb a everest but you have to 
know minimum to do that. Spend a year in learning and get the 
best result in minutes).


Re: Fix gtkD api display

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 04-08-17 17:24, Gerald wrote:

On Friday, 4 August 2017 at 15:08:27 UTC, Mike Wey wrote:
Improving the documentation is something i want to do but there are 
always some more important things to do. Like the Questions/Issues you 
posted earlier.


So unless somebody volunteers it won't happen anytime soon.


Mike I had contributed the makeddox.sh script awhile ago, it generates 
much nicer documentation then candydocs in my IHMO and includes a nice 
search box. If there is something lacking in it that needs to be 
improved before it can be used let me know and I'll do the work.


The only issue with it that I am aware of is you need to manually copy 
the public ddox css into the generated folder. I didn't see an easy way 
to determine it's location automatically.


One issue is the shear size of the generated documentation, though the 
current version of ddox no longer generates a ton of unused files 
bringing the size down from 15-20GB to a mere 2GB.


So it has at leased become manageable to host it on the VPS that hosts 
gtkd.org.


Now remains figuring out setting up the proper redirects on the server, 
and a few personal preferences about ddox:


The need to go trough the empty module page when browsing the 
documentation. For a lot / most? functions the complete documentation is 
in the overview defeating the purpose of the one page per artifact.

And im not a big fan of the one page per artifact style of documentation.

--
Mike Wey


Re: gtkD load images

2017-08-05 Thread Johnson Jones via Digitalmars-d-learn

On Saturday, 5 August 2017 at 12:51:13 UTC, Mike Wey wrote:

On 03-08-17 21:56, Johnson Jones wrote:

If I do something like

import gdkpixbuf.Pixbuf;
Pixbuf.newFromResource("C:\\a.jpg");


There are two issues here, you need to properly escape the 
slash: "C:a.jpg".


And a.jpg is not a resource file, so you would use the Pixbuf 
constuctor to load an image file.


```
Pixbuf p = new Pixbuf(r"C:\\a.jpg");
```


Thanks. Why do I need 4 slashes? Is that standard with gtk 
because strings are interpreted twice or something? Seemed to 
work though.





Re: Jetbrains announce support for rust plugin, show them we want one too!

2017-08-05 Thread Dmitry via Digitalmars-d

On Saturday, 5 August 2017 at 11:26:57 UTC, Russel Winder wrote:
If more people in the D community had the attitude "I can help 
with that" rather than "I wish they would so something", D 
tooling based on mainstream infrastructure would be a lot 
better than it currently is.


Don't wait from a new people that they're skilled for it. Use D 
and make D (including ecosystem) - it's absolutely different, and 
requires a different level of skills.


I'm an one who needed a good IDE (+debugger) support. But 
unfortunately I'm not found a good one for D.
I have small skills in D, so my abilities is very limited 
(translate something to another language, etc). And I'm not sure 
that I'll be able grow it well without a good IDE, because

then I'd prefer other solid ecosystems for any serious projects.



Re: GtkD custom theme on Windows

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 04-08-17 05:06, Andres Clari wrote:
I've made a linux program with GtkD, and so far, it's been pretty 
awesome, however I'm thinking about porting it to Windows also, but the 
Adwaita theme is too fugly, and cringy, so I'd want to use a compatible 
theme, which is supposed to be doable.


What would be the way to go to make a GtkD app use a custom GTK theme in 
Windows?
I tried this in the past, but never succeeded following documentation 
found online.



I didn't try it myself but it should be something like this:

-Download a theme from gnome-look.org
-Extract the theme to: C:\\Program Files\Gtk-Runtime\share\themes
-Edit C:\\Program Files\Gtk-Runtime\etc\gtk-3.0\settings.ini and add:

```
gtk-theme-name = Name_of_Theme
```

--
Mike Wey


Re: gtkD load images

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 03-08-17 21:56, Johnson Jones wrote:

If I do something like

import gdkpixbuf.Pixbuf;
Pixbuf.newFromResource("C:\\a.jpg");


There are two issues here, you need to properly escape the slash: 
"C:a.jpg".


And a.jpg is not a resource file, so you would use the Pixbuf constuctor 
to load an image file.


```
Pixbuf p = new Pixbuf(r"C:\\a.jpg");
```

--
Mike Wey


Re: Bug in gtkd?

2017-08-05 Thread Mike Wey via Digitalmars-d-learn

On 03-08-17 23:11, Johnson Jones wrote:

On Thursday, 3 August 2017 at 21:00:17 UTC, Mike Wey wrote:

On 03-08-17 22:40, Johnson Jones wrote:
Ok, so, I linked the gtk to the msys gtk that I installed before when 
trying to get glade to work and it worked!


seems that msys is much more up to date than anything else as it just 
works(I need to remember than in the future).


The problem I see is this:

When I get ready to release my app to the public, I can't expect them 
to all have to install msys and build.


msys seems to clump everything together and I don't know what files I 
need to extract to be able to bundle everything together.


Any ideas how to solve that problem? At least now I can move ahead 
and actually make some progress on my app.


Would still be nice to get the x86 vs x64 issue resolved so I don't 
have to keep switching between the two for testing purposes. Since 
Visual D was just patched to handle x64 BP's I guess I can stay with 
that for now.




I'll try to build and test some new installers tomorrow that will 
include the loaders.


Thanks. Could you take a look at the loading image thread I started when 
you get time? I can't seem to get an image to load even though it seems 
straight forward.


These are the pixbufs I'm using

mingw32/mingw-w64-i686-gdk-pixbuf2 2.36.6-2 [installed]
 An image loading library (mingw-w64)
mingw64/mingw-w64-x86_64-gdk-pixbuf2 2.36.6-2 [installed]
 An image loading library (mingw-w64)

in x64 it crashes completely without an exception though... which is why 
I want an easy way to switch between the two architectures... since x64 
seems to be more unstable than x86 but sometimes it's the reverse, and 
ultimately I'll want to release in x64.


Also, do I ever need to rebuild gdk when changing gtk installations? 
Does it ever grab anything from them at compile time or is it all at 
runtime?


The new installers are available: https://gtkd.org/Downloads/runtime/

You don't need to rebuild GtkD when changing GTK installations, it does 
it all at runtime.


--
Mike Wey


Re: Jetbrains announce support for rust plugin, show them we want one too!

2017-08-05 Thread Russel Winder via Digitalmars-d
On Sat, 2017-08-05 at 10:19 +0200, Daniel Kozak via Digitalmars-d wrote:
> I would not say so:
> https://github.com/intellij-dlanguage/intellij-dlanguage/issues/211
> 

Just because Kingsley has moved on doesn't mean the project is dead. In fact
far from it. Except that currently is is spare time activity from a couple of
people. 
-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc
Description: This is a digitally signed message part


Re: Jetbrains announce support for rust plugin, show them we want one too!

2017-08-05 Thread Russel Winder via Digitalmars-d
On Fri, 2017-08-04 at 19:42 +, Ali via Digitalmars-d wrote:
> 
[…]
> They dont have plans for a standalone rust ide, like clion for c++

Remember CLion is first and foremost a CMake based IDE that happens to have
excellent support for C and C++ files. Also Rust, and a whole load of other
languages for which there is a CMake build capability.
 
[…]
> I think a community support for the Dlang intellij plugin is our 
> best hope
> we can start a kickstarter project and donate money to them .. 
> might work
> 
> I would donate to them if they also include a refactoring tool

There is no "they" IntelliJ-DLanguage is a plugin for IntelliJ IDEA being
written by the D community, that is "you". Sadly, currently, only a couple of
people are putting in a bit of their spare time to keep the project moving. 

If more people in the D community had the attitude "I can help with that"
rather than "I wish they would so something", D tooling based on mainstream
infrastructure would be a lot better than it currently is.

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc
Description: This is a digitally signed message part


Re: dlang-requetst: openssl 1.1 compatible release

2017-08-05 Thread Jack Applegame via Digitalmars-d-announce

On Friday, 4 August 2017 at 18:28:23 UTC, ikod wrote:

On Friday, 4 August 2017 at 17:06:16 UTC, Jack Applegame wrote:
Does dlang-requests support binding interface for outgoing 
connection, like curl --interface option?


No, but this can be done. It would be nice if you post issue on 
github.



https://github.com/ikod/dlang-requests/issues/51



Re: Jetbrains announce support for rust plugin, show them we want one too!

2017-08-05 Thread Daniel Kozak via Digitalmars-d
I would not say so:
https://github.com/intellij-dlanguage/intellij-dlanguage/issues/211

On Fri, Aug 4, 2017 at 8:36 PM, Ali via Digitalmars-d <
digitalmars-d@puremagic.com> wrote:

> On Friday, 4 August 2017 at 18:15:47 UTC, SCev wrote:
>
>> Just today, jetbrains announced their official support for the rust plugin
>>
>> I'm sure they'll do something for D if we ask them, don't stay silent!!
>> show them you want something
>>
>> Leave a comment in their blog for a D support!  too!
>>
>> We can do it!
>>
>> https://blog.jetbrains.com/blog/2017/08/04/official-support-
>> for-open-source-rust-plugin-for-intellij-idea-clion-and-
>> other-jetbrains-ides/
>>
>
> there is already a pluggin for D,
> https://github.com/intellij-dlanguage/intellij-dlanguage
>
> not officially supported by Jetbrains
> seems to be under active development
>
>
>


Re: How to build GUI-based applications in D ?

2017-08-05 Thread Jacob Carlborg via Digitalmars-d-learn

On 2017-08-01 17:45, ashit wrote:


thank you James

i should try that.
i was always enjoy the pure and efficiency of C. that made me stubborn
to learn java.


Just to be clear, there's no Java code in DWT. Everything is ported to D.

--
/Jacob Carlborg


Re: How to build GUI-based applications in D ?

2017-08-05 Thread aberba via Digitalmars-d-learn

On Thursday, 3 August 2017 at 10:02:19 UTC, ashit wrote:

On Tuesday, 1 August 2017 at 16:12:45 UTC, Dukc wrote:

On Tuesday, 1 August 2017 at 15:18:12 UTC, ashit wrote:
i couldn't set control's width and height (Button widget) 
shows error. maybe it works a different way.


1. Try layoutHeight/width. Remember to set it for the main 
widget too, not just the children of it.


2. DlangUI is not intended to define sizes in pixels as a 
standard practice. Instead, use layouts and layout sizes. This 
is intended to courage you to make your program 
resolution-agnostic.


But I'm a beginner at this topic too. Take these with a grain 
of salt


thank you Dukc

it worked, i should adapt with this different naming style. (as 
comparing to C#)

[yesterday]
but today, when i went to create another project, it failed.
i get this message:

D:\ashit\documents\D\simpled>dub init simpled dlangui
Couldn't find package: dlangui.

it works without the "dlangui" option, but then when i execute 
run command:


D:\ashit\documents\D\simpled>dub run
Performing "debug" build using dmd for x86.
simpled ~master: building configuration "application"...
source\app.d(2,8): Error: module dlangui is in file 'dlangui.d' 
which cannot be

read
import path[0] = source
import path[1] = C:\dmd2\windows\bin\..\..\src\phobos
import path[2] = C:\dmd2\windows\bin\..\..\src\druntime\import
dmd failed with exit code 1.

this is the path i have extracted the dlangui files:

D:\ashit\software\D Compiler\DlangUI\dlangui-master

how to define dlangui for DUB?


The DlangUI docs has you covered with everything you need to set 
it up both on the github README file or the github wiki.


Its just:

dub init PROJECT_NAME dlangui


This will create project and add dlangui as dependency. Creating 
a project requires Internet connection to download the dlangui 
package. You may also add dlangui as a dependency in the 
project's dub.json file.