Re: "else if" for template constraints

2015-08-17 Thread Zoadian via Digitalmars-d
On Monday, 17 August 2015 at 13:18:43 UTC, Steven Schveighoffer 
wrote:
void replaceInPlace(T, Range)(ref T[] array, size_t from, 
size_t to, Range stuff)

if(isDynamicArray!Range &&
is(Unqual!(ElementEncodingType!Range) == T) &&
!is(T == const T) &&
!is(T == immutable T))
{ /* version 1 that tries to write into the array directly */ }

void replaceInPlace(T, Range)(ref T[] array, size_t from, 
size_t to,

Range stuff)
else if(is(typeof(replace(array, from, to, stuff
{ /* version 2, which simply forwards to replace */ }

looks much better IMO. Can we do something like this? I'm not a 
compiler guru, so I defer to you experts out there.


-Steve


wouldn't is(typeof(replace(array, from, to, stuff))) better be a 
static if inside the first version?


Re: "else if" for template constraints

2015-08-17 Thread Zoadian via Digitalmars-d

On Monday, 17 August 2015 at 16:57:33 UTC, Zoadian wrote:
wouldn't is(typeof(replace(array, from, to, stuff))) better be 
a static if inside the first version?


nevermind, I missed that the first constraint is negated.

In that case I agree, else if would be nice.


Re: AST like coding syntax. Easy upgrade!

2015-09-06 Thread Zoadian via Digitalmars-d

On Sunday, 6 September 2015 at 19:32:58 UTC, Prudence wrote:

template X(Y)
{
string X = Y.stringof;
}

[...]



as you'd have to write a parser for other languages why not just 
use strings? you can already do this:


template X(string Y)
{
enum X = Y;
}

auto s = X!q{int 3;};

obviously X has to be a compiletime js->d compiler.


Re: [dlang.org] new forum design - preview

2016-01-13 Thread Zoadian via Digitalmars-d

On Wednesday, 13 January 2016 at 13:41:00 UTC, Bubbasaur wrote:

May I suggest one thing? Could you put the page numbers on top 
instead of bottom? Because this is a common style in many 
pages, I think It would be nice if it was right bellow of (Log 
in,Settings,help), because currently, if I want to go to page 
50, I need to scroll down 5 times.


+1




Re: Iterating over modules

2016-02-04 Thread Zoadian via Digitalmars-d

On Thursday, 4 February 2016 at 15:45:03 UTC, Satoshi wrote:

Hi,
is there any way how to iterate over every module/submodule?

I have project like
Rikarin
Rikarin/AppKit
Rikarin/Drawing
Rikarin/Runtime
etc.

In every directory, I have package.d file where I include every 
.d file from the dir.


And the think what I want to do is to define UDA's like 
@Action, @Outlet, etc. for methods and generate runtime info 
for them.


I know I can use something like mixin(generate!...); in every 
file where I used that UDA's, but its not the best idea for me.


disclaimer: I don't know if this works.

enum fileContent = import(__FILE__);

parse imports and repeat this recursivly for all found imports


Re: OT: Vulkan released

2016-02-16 Thread Zoadian via Digitalmars-d
On Tuesday, 16 February 2016 at 14:20:51 UTC, Ola Fosheim Grøstad 
wrote:

https://www.khronos.org/vulkan/

OS-X Metal is kinda like a C++ derivative => GPU compilation.

With Vulkan/SPIR other languages should be able to come up with 
something similar for other platforms.


finally.

I'll write derelict bindings.


Re: A few notes on choosing between Go and D for a quick project

2015-03-13 Thread Zoadian via Digitalmars-d

On Friday, 13 March 2015 at 10:34:32 UTC, bearophile wrote:

Ola Fosheim Grøstad:

Yes, but what is a "strict mode". I agree with most of what is 
said about D and Go in the top post, but is there a market for 
yet another high level language that isn't high level enough?


"Strict mode" is a D2 with immutable+@safe+pure by default, 
something like a "var" keyword to denote mutable values, no 
comma operator, static full tracking of memory ownership, less 
implicit casts (because now we have the safe int(x) sytnax), 
and few other small changes that make the language less bug 
prone and more strict.


And I'd still like built-in tuple syntax in D.

Bye,
bearophile


+1


Re: 0 is not a power of 2

2015-05-19 Thread Zoadian via Digitalmars-d

On Tuesday, 19 May 2015 at 18:04:49 UTC, Marco Leise wrote:

Am Mon, 18 May 2015 22:16:47 -0700
schrieb Andrei Alexandrescu :


But that has branches in it. So I came up with:

bool isPowerOf2(uint x)
{
 return (x & (x - 1) | !x) == 0;
}

which has no branches at least with dmd, see 
http://goo.gl/TVkCwc.


Any ideas for faster code?


Thanks,

Andrei


Any faster ?! This is already minimal assembly code with
pretty looks!

While you are at it, you might also need "round pointer up to"
and "round pointer down to", which can be implemented with bit
ops for power-of-2 multiples.

Its the kind of stuff that's not really a std.algorithm
candidate, but still somewhat common in memory management code.
Often these and other little helpers end up in everyones
stdlib_extensions.d which I suppose don't look all that
different. Who has some of these in their code?:

- isPowerOf2, nextLargerPowerOf2
- roundUp/Down to multiple of X
- increment with wraparound at X
- clamp value (low, high or both ends)
- check if numerical value is in between two others
- compile time "iota"
- format an argument as it would appear in source code
  (i.e. add quotes around strings)


+1 ;)
all except the last one


Re: Wait, what? What is AliasSeq?

2015-07-09 Thread Zoadian via Digitalmars-d

It is a compiletime tuple so i'd vote for:
CtTuple


Re: Wait, what? What is AliasSeq?

2015-07-21 Thread Zoadian via Digitalmars-d

On Tuesday, 21 July 2015 at 06:49:10 UTC, deadalnix wrote:
Some of the proposals do not even make any sense. Come on, all 
people that got into this know how newcomer react to the Tuple 
name noticed the same reaction. Yet, there is a large crow of 
idiots (sorry if you are in that crowd, on that one you ARE an 
idiot) that will send that proposal in again and again. Anyone 
that proposed that name at this point should only be laughed 
at, as it is clearly the manifestation of someone that have not 
deal first hand with the problems of the historical name and is 
serving as a living example of Dunning Kruger.


i get that TypeTuple is confusing as it is not _limited_ to types,
but why is it not a tuple?


Re: Wait, what? What is AliasSeq?

2015-07-21 Thread Zoadian via Digitalmars-d

On Tuesday, 21 July 2015 at 16:54:54 UTC, H. S. Teoh wrote:
On Tue, Jul 21, 2015 at 04:06:11PM +, Zoadian via 
Digitalmars-d wrote:

On Tuesday, 21 July 2015 at 06:49:10 UTC, deadalnix wrote:
>Some of the proposals do not even make any sense. Come on, 
>all people that got into this know how newcomer react to the 
>Tuple name noticed the same reaction. Yet, there is a large 
>crow of idiots (sorry if you are in that crowd, on that one 
>you ARE an idiot) that will send that proposal in again and 
>again. Anyone that proposed that name at this point should 
>only be laughed at, as it is clearly the manifestation of 
>someone that have not deal first hand with the problems of 
>the historical name and is serving as a living example of 
>Dunning Kruger.


i get that TypeTuple is confusing as it is not _limited_ to 
types, but why is it not a tuple?


Because, among other things, it auto-expands.


T


I agree that auto-expansion is a bit unexpected (documentation 
does not even mention it...). But by that logic it's not a 
'Sequence', 'List' or 'Pack' either.


Can't we just call it Unpack!() then?




Re: Vulkan

2018-02-16 Thread Zoadian via Digitalmars-d

On Friday, 16 February 2018 at 22:58:30 UTC, Ivan Trombley wrote:
On Wednesday, 14 February 2018 at 02:40:18 UTC, Mike Parker 
wrote:
What [does] it mean to say they don't work? Have you reported 
any issues? I don't see any in the DerelictVulkan repo. If 
something's broken, please report it so it can  be fixed.


Derelict-vulkan is Windows only ATM.


Actually someone added posix support. Just forgot to flag a new 
release. (I did not test posix support myself yet).

If there are other issues please file them on GitHub.


Re: C++ launched its community survey, too

2018-02-28 Thread Zoadian via Digitalmars-d
On Wednesday, 28 February 2018 at 00:53:16 UTC, psychoticRabbit 
wrote:
It should have gone to the Java developers - cause they 
deserved it.


C++ is the worst thing to have ever come out of computer 
science!


yes c++ is not the greatest language (thats why i use D). but 
java is the worst language i've ever used.


Re: Favorite GUI library?

2018-04-23 Thread Zoadian via Digitalmars-d

On Monday, 23 April 2018 at 06:12:33 UTC, TheGag96 wrote:
Heya guys. For my projects that use a GUI library, I've tried 
both tkd and DlangUI. Both I feel have their drawbacks, and I'd 
like to know if any of you are using anything you find better. 
In my case, my ideal choice would be:


- Nice bindings/API, friendly to idiomatic D
- Cross platform
- Can compile to a standalone binary (no shared libraries or 
extra files)

- Reasonably efficient
- Support for a good amount of well-working widgets

Although quite a cool library, my biggest issue with DlangUI 
was that it was a little mind-bending at times to keep track of 
multiple widgets that view/modify the same data without 
screwing things up. I saw QtE5 recently and have been thinking 
about trying it out.


What do you all recommend? Thanks!


i'm happy with:
vibe.d + CEF + vue.js


Re: Favorite GUI library?

2018-04-23 Thread Zoadian via Digitalmars-d

On Monday, 23 April 2018 at 14:38:44 UTC, TheGag96 wrote:

On Monday, 23 April 2018 at 11:26:30 UTC, Chris wrote:

On Monday, 23 April 2018 at 09:50:21 UTC, Zoadian wrote:



i'm happy with:
vibe.d + CEF + vue.js


Good point. I've been thinking about vibe.d + HTML/JS based 
UIs too. I think that's where UIs are increasingly moving 
towards: HTML+CSS + some sort of web-based backends.


That's definitely what I'm trying to avoid... I feel those 
kinds of interfaces are 99% of the time mega bloated for what 
they are. Discord is the only one that seemed big enough for 
the britches of an entire browser instance. Absolutely not a 
fan of Electron and the like.


If we are talking binary size: then yes, I agree.
But it is a lot easier to maintain & write than QT-Widgets/GTK 
based code.





Re: Sealed classes - would you want them in D? (v2)

2018-05-17 Thread Zoadian via Digitalmars-d

On Thursday, 17 May 2018 at 02:32:07 UTC, KingJoffrey wrote:
I propose an idea, for discussion (robust discussion even 
better ;-)


Add an new attribute to class, named 'sealed'.


If class level protection is added, please do not call it sealed.
People from c++ might be suprised by 'private' already. We do not 
have to confuse those c#ies too.


Module level protection is enough to hide implementation details 
though. So while i do understand why you want this in D, i don't 
think it is worth it to complicate the language for something you 
can work around easily by putting the classes in their own 
modules.
I'm also not convinced think that your 'sealed' would be used 
much, because accessing private state in the module is actually 
extremly useful (e.g. unittests).


That beeing said, if you are convinced it would be a good 
addition, please write a DIP.
Even if it will not be accepted it will at least force a 
decision. And we can point to the reasons it got 
accepted/rejected in the future.


Re: std.signals non-object delegates

2018-06-12 Thread Zoadian via Digitalmars-d

On Tuesday, 12 June 2018 at 15:21:49 UTC, Jacob Shtokolov wrote:
On Tuesday, 12 June 2018 at 14:33:57 UTC, Steven Schveighoffer 
wrote:

[...]


Thank you Steve!

Then I'll try to fire a bug report and propose my own solution 
to this problem.
Probably there is no need to track down the non-object dispose 
events.


Good to hear that not so many people are affected by this 😏


i remember someone was working on a std.signals replacement a few 
years ago.

don't know where that went.
it might be this:
https://wiki.dlang.org/Review/std.signal
https://github.com/phobos-x/phobosx/blob/master/source/phobosx/signal.d


Re: Automatic variable declaration

2018-08-16 Thread Zoadian via Digitalmars-d

On Wednesday, 15 August 2018 at 14:58:40 UTC, Everlast wrote:

Many times one must create a variable before a function call:


  int x = 3;
  foo(x);
  writeln(x);

[...]


check this out:

void main() {
import std.stdio;
writeln = 4;
}

https://run.dlang.io/is/0wgWtw


Re: Thoughts about D

2017-11-27 Thread Zoadian via Digitalmars-d
On Monday, 27 November 2017 at 09:07:10 UTC, Nicholas Wilson 
wrote:

On Monday, 27 November 2017 at 07:58:27 UTC, IM wrote:
On Monday, 27 November 2017 at 03:01:24 UTC, Jon Degenhardt 
wrote:
Forum discussions are valuable venue. Since you are in 
Silicon Valley, you might also consider attending one of the 
Silicon Valley D meetups 
(https://www.meetup.com/D-Lang-Silicon-Valley). It's hard to 
beat face-to-face conversations with other developers to get 
a variety of perspectives. The ultimate would be DConf, if 
you can manage to attend.


Thanks. I intend to attend some of their meetup events.


I'll be giving a presentation on Thursday evening on using D 
for (among other things) GPGPU, hope you can make it!


Any chance it gets recorded? I'd be highly interested!


Re: D, ZeroMQ, Nanomsg

2016-09-28 Thread Zoadian via Digitalmars-d
On Wednesday, 28 September 2016 at 11:53:05 UTC, Russel Winder 
wrote:

Hi,

I see that some people have wrapped in various different ways 
ZeroMQ. Was this manually, or using DStep?


Has anyone wrapped Nanomsg? If yes, was this manually or using 
DStep.


derelict_extras-nanomsg was converted manually