Re: How to simplify nested ifs

2018-03-16 Thread Satoshi via Digitalmars-d-learn

On Tuesday, 13 March 2018 at 12:23:06 UTC, Ozan Süel wrote:

Hi

I have a construction like the following

if (source) {
  if (source.pool) {
if (source.pool.repository) {
  if (source.pool.repository.directory) {
if (source.pool.repository.directory.users) {
  // do something

Any chance to simplify this nested ifs?
I know some languages has a way like.

if (source?pool?repository?directory?users) // do something


Similar ways in D?

Thanks and Regards, Ozan


null conditional operators are not implemented in D because, as a 
(I think Walter) said, D is not language designed to work with 
classes or advanced OOP stuff. Nobody uses it, so please, if you 
are using it, stop and use structs and meta programming instead.


Re: What do you want to see for a mature DLang?

2017-12-29 Thread Satoshi via Digitalmars-d

On Friday, 29 December 2017 at 07:53:51 UTC, IM wrote:

I will start:

   -- Better compiler errors, better compiler errors, better 
compiler errors.



I really wish that the compiler errors could receive some 
refinement. Mostly it feels like some error text just being 
thrown at me. It needs to be better formatted, more helpful, 
with suggestions about how to fix (if possible).


To illustrate my point:

- See the compile errors I've just encountered with DMD: 
https://cdn.pbrd.co/images/H0q609l.png


- Now compare that with an error produced by rustc:
https://cdn.pbrd.co/images/H0q6bLi.png


Simple things like these make a big difference. D Lang has been 
around for a long while now, and hence signs of its maturity 
has to show everywhere, especially in the compiler, as well as 
the package manager.



This topic was there for so many times.
Tuples, async/await, maybe monad (eg. int?), conditional 
dereferencing qualifier?.identifier, coalescence operator return 
x ?? 42;
better properties, default safety, explicit throw funcs, runtime 
reflection, ARC instead of GC, so support, ...


The community is quite conservative about implementing new stuff 
in D.


Look at for more info:
http://forum.dlang.org/thread/sapqaonpjseeykdcz...@forum.dlang.org?page=1
http://forum.dlang.org/thread/ot1q8b$23pt$1...@digitalmars.com?page=1



BTW: I decided to make my own language rather than forcing the 
community to implement something what I would like to see in the 
lang. https://github.com/Rikarin/Rin


Re: Global variable type does not match previous declaration

2017-12-16 Thread Satoshi via Digitalmars-d-learn

On Saturday, 16 December 2017 at 09:04:05 UTC, Satoshi wrote:
I commented out the TypeInfo declarations and got the same 
error but on different symbol.


object.d(1569): Error: Function type does not match previously 
declared function with the same mangled name: _d_dynamic_cast



https://github.com/Rikarin/Trinix/blob/master/Kernel/object.d#L1569

https://travis-ci.org/Rikarin/Trinix/builds/317288016?utm_source=github_status_medium=notification

I have no idea what's wrong with that.
Any ideas?


Thanks.


Actually, it seems like bug in LDC (compilation with DMD works 
fine).

I opened issue https://github.com/ldc-developers/ldc/issues/2453


Re: Global variable type does not match previous declaration

2017-12-16 Thread Satoshi via Digitalmars-d-learn
I commented out the TypeInfo declarations and got the same error 
but on different symbol.


object.d(1569): Error: Function type does not match previously 
declared function with the same mangled name: _d_dynamic_cast



https://github.com/Rikarin/Trinix/blob/master/Kernel/object.d#L1569

https://travis-ci.org/Rikarin/Trinix/builds/317288016?utm_source=github_status_medium=notification

I have no idea what's wrong with that.
Any ideas?


Thanks.


Re: Global variable type does not match previous declaration

2017-12-14 Thread Satoshi via Digitalmars-d-learn
On Thursday, 14 December 2017 at 12:18:22 UTC, Nicholas Wilson 
wrote:

On Wednesday, 13 December 2017 at 21:39:40 UTC, Satoshi wrote:

On Wednesday, 13 December 2017 at 21:38:49 UTC, Satoshi wrote:

[...]


Compiling with
ldc2 -debuglib= -defaultlib= -code-model=kernel 
-disable-red-zone -w -wi -de -O3 -mattr=-sse -I../ 
-of=obj-amd64/object.d.o -c -deps=obj-amd64/object.d.o.o.dep 
object.d


Can you add -vv to the command line and post the relevant 
portion of the result (i.e. the portion that correlates to the 
symbol that gives the error)?  (You'll want to pipe the output 
to a file as it produces a lot of output.)


Here is output from -vv
https://gist.github.com/anonymous/0a48808969600a84a683c03df57b5a29


Re: Global variable type does not match previous declaration

2017-12-13 Thread Satoshi via Digitalmars-d-learn

On Wednesday, 13 December 2017 at 21:38:49 UTC, Satoshi wrote:

What means this error and how to solve it?

object.d-mixin-1072(1112): Error: Global variable type does not 
match previous declaration with same mangled name: 
_D10TypeInfo_m6__initZ


Actually, I'm working on OS with minimal D runtime and I'm 
unable to compile object.d


source code:
https://github.com/Rikarin/Trinix/blob/a42a6e1fb4b87374b3e5ad8b9be501b080655ccd/Kernel/object.d

Thanks


Compiling with
ldc2 -debuglib= -defaultlib= -code-model=kernel -disable-red-zone 
-w -wi -de -O3 -mattr=-sse -I../ -of=obj-amd64/object.d.o -c 
-deps=obj-amd64/object.d.o.o.dep object.d


Global variable type does not match previous declaration

2017-12-13 Thread Satoshi via Digitalmars-d-learn

What means this error and how to solve it?

object.d-mixin-1072(1112): Error: Global variable type does not 
match previous declaration with same mangled name: 
_D10TypeInfo_m6__initZ


Actually, I'm working on OS with minimal D runtime and I'm unable 
to compile object.d


source code:
https://github.com/Rikarin/Trinix/blob/a42a6e1fb4b87374b3e5ad8b9be501b080655ccd/Kernel/object.d

Thanks


Re: bootable vibed

2017-12-11 Thread Satoshi via Digitalmars-d

On Saturday, 9 December 2017 at 05:07:46 UTC, Elronnd wrote:
Note to anyone trying to implement this (I might try, but I 
don't have the expertise to...): 
http://wiki.osdev.org/D_Bare_Bones, 
http://wiki.osdev.org/D_barebone_with_ldc2, and 
https://github.com/PowerNex/PowerNex



None of D's OSes supports networking.


Re: Looking for a job in USA

2017-11-26 Thread Satoshi via Digitalmars-d
Thanks everyone for your advices and helping me with finding job 
in the US. I applied for about 300 jobs at companies like Apple, 
M$, Amazon, Google, etc. and got one offer in Canada, so it's 
half-win for me. :)


Thanks!

BTW: Walter, why you don't use IP Board instead of this, custom 
made forum? If you are not OK with topics like this, why you 
don't create off-topic category where it should be fine to post 
topics what are not focused on D?


Re: Looking for a job in USA

2017-11-20 Thread Satoshi via Digitalmars-d

On Monday, 20 November 2017 at 09:15:15 UTC, Adam Wilson wrote:
To get an H1B you'll want to get a job with one of the majors. 
Microsoft, Google, Apple, Amazon. There are smaller companies, 
but the majors have a dedicated team of lawyers who can guide 
your H1B through the process. It is the consulting body-shops 
are bearing the brunt of the crackdown. Much to the rejoicing 
of the H1B's on my team. Second, getting a green card for an 
H1B is easily a 10 year wait. You'll be in for the long-haul. :)


None of these companies are looking for employees without working 
visa in the US. Mostly, they have branch offices in EU, so if I 
apply for a job, they will hire me in one of the EU offices.


But thanks for the advice, I'll apply for some job opportunities 
at these companies and try my best.


Re: Looking for a job in USA

2017-11-20 Thread Satoshi via Digitalmars-d

On Monday, 20 November 2017 at 10:38:59 UTC, user1234 wrote:

On Saturday, 18 November 2017 at 08:59:53 UTC, Satoshi wrote:

On Saturday, 18 November 2017 at 01:31:09 UTC, Indigo wrote:

On Wednesday, 15 November 2017 at 17:32:50 UTC, Satoshi wrote:

Hi,
as the title says, I'm looking for a job opportunity in the


Salary... In US you get $100,000/year as a senior developer or 
something like that, right?
There it's only like $30,000/year. But the price of stuff like 
cars, grocery and everything what you can buy on amazon, 
e-bay, etc. is the same.


Wait wait wait...the social model is not the same, this 
explains the difference. Typically in UE you have welfare 
states, with what this implies ;)


In these welfare states you are required to pay health insurance, 
pension insurance, social insurance which is 30% of your salary. 
Then, there is a difference between your salary what you 
negotiated and the money what your employer spend on your salary. 
He must pay additional 20% to 30% of your salary. Example: I get 
about 1400e/monthly, my employer pays about 2600e/monthly on my 
salary.
If you are sick, it's better to take home office than be paid 
from state.
This system, especially in Slovakia is designed for poor people 
not to fall down.



And still, it's better to have bigger salary, even if you are 
paying higher % as a taxes and stuff.


There you have small cars, small flats, smaller size of food for 
the same % of your salary as in the US. e.g. Dodge RAM cost the 
same price as big house in village 20 minutes from Brno or flat 
in the Brno.


I'm not focusing on material thing or something like that, but my 
dream is to travel through the world, sailing and work remotely 
(which is possible as a programmer) for a few years before I hit 
the age. I don't wanna be the one, who stayed at the same place 
for his entire life. Y'know, I'd like adventures.


I think I'm writing the same code as everyone else in the US, so 
why shouldn't I have the same salary?


Re: Looking for a job in USA

2017-11-18 Thread Satoshi via Digitalmars-d

On Saturday, 18 November 2017 at 01:31:09 UTC, Indigo wrote:

On Wednesday, 15 November 2017 at 17:32:50 UTC, Satoshi wrote:

Hi,
as the title says, I'm looking for a job opportunity in the 
USA (H1B visa sponsorship required).


I'm experienced Software Engineer with a demonstrated history 
of working in the security and investigations industry. 
Skilled in C, C++, D, C#, SQL, Object-Oriented Programming, 
Software Development and Electrical Engineering. Strong 
engineering professional with willingness to further education.


Actually I work as a full stack ASP.NET developer for 
SolarWinds in Brno (Czechia).


There are couple of my open source projects what I have done 
in past. https://github.com/Rikarin


If you are interested or you know someone who could hire me, 
please let me know!


Thanks!


What is your reasoning for coming to the US? You might want to 
rethink this as America is collapsing. America will be vastly 
different in 10 years and not a great a place to be. The amount 
of corruption in the government and the amount of vitriol that 
people have for each other are astonishing... and it is only 
getting worse.
Actually, Slovakia (SK) and Czechia (CZ) are two most corrupted 
countries in the EU. We are paying huge taxes and getting nothing 
in back.


If you are moving to settle down that it would be a bad 
decision IMO. If it is just temporary thing for a few years 
thing it might be ok depending on you end up.
I wanna try to live in the US for a few years and then decide if 
I should leave or settle down.


Do you mind me asking why you are leaving Czech? I hear there 
are a lot of pretty females there ;) Is it simply business or 
is it the country itself? To be honest, I couldn't imagine it 
being as bad as the US but I do not know much about it. To be 
honest, I'm curious as to what it is like over there because I 
plan on moving out of the US at some point and I'm looking for 
countries that are a bit more stable and not on the decline.
Actually, CZ is rising up and getting better, but in business 
area and salaries it's still worse than in the US.


Some places in EU are not safe yet. A lot of immigrants are going 
there from war zones. They are like groups of anarchists 
destroying everything, stealing, raping and not respecting the 
laws.


Salary... In US you get $100,000/year as a senior developer or 
something like that, right?
There it's only like $30,000/year. But the price of stuff like 
cars, grocery and everything what you can buy on amazon, e-bay, 
etc. is the same.


The concept of a money in US seems to be different than in SK. 
There it's more about survive than enjoying life.


People in US seems to be little more opened to strangers than 
here.


That's the reasons why I want to leave.

BTW: What's wrong with the US?


Re: What do people here use as an IDE?

2017-11-17 Thread Satoshi via Digitalmars-d
On Wednesday, 13 October 2010 at 01:58:19 UTC, Michael Stover 
wrote:
Elephant appears dead.  Poseidon's activity is extremely low 
and is still alpha after 5 years. LEDS is even less active, and 
DDT doesn't have a release yet.  What do actual D programmers 
use?


-Mike


vim


Looking for a job in USA

2017-11-15 Thread Satoshi via Digitalmars-d

Hi,
as the title says, I'm looking for a job opportunity in the USA 
(H1B visa sponsorship required).


I'm experienced Software Engineer with a demonstrated history of 
working in the security and investigations industry. Skilled in 
C, C++, D, C#, SQL, Object-Oriented Programming, Software 
Development and Electrical Engineering. Strong engineering 
professional with willingness to further education.


Actually I work as a full stack ASP.NET developer for SolarWinds 
in Brno (Czechia).


There are couple of my open source projects what I have done in 
past. https://github.com/Rikarin


If you are interested or you know someone who could hire me, 
please let me know!


Thanks!


Re: Project Elvis

2017-11-12 Thread Satoshi via Digitalmars-d

It's for you!

https://i.imgur.com/NNgrSyP.png


Re: Project Elvis

2017-11-12 Thread Satoshi via Digitalmars-d

On Sunday, 12 November 2017 at 08:33:34 UTC, Satoshi wrote:


I'm going to start focusing my attention on rewriting (some) 
of FreeBSD userland, using D ..and see what happens. (btw. 
such programs can easily be migrated to Linux/OSX too...or the 
new 'System D' ..when it arrives ;-)

You should starts from Kernel.

And if you don't want to start form scratch, you can use my OS 
written in D :)

https://github.com/Rikarin/Trinix


I'm expecting your first pull request in couple of days :)


Re: Project Elvis

2017-11-12 Thread Satoshi via Digitalmars-d

On Sunday, 12 November 2017 at 04:40:21 UTC, codephantom wrote:

On Sunday, 12 November 2017 at 01:00:46 UTC, bauss wrote:

I'm tired so I will end my post here.


And I'm going to end all my posts here, cause I'm sick of 
arguing with MSFT fanboys, who want to restrain D's development 
by tying it into propriatery, closed source, bloatware.
Yeah, I'm MSFT fanboy because I think ?? and ?. operators from C# 
are useful.

Think of a number between 1 and 10 Yes, that's your IQ.



I'm going to start focusing my attention on rewriting (some) of 
FreeBSD userland, using D ..and see what happens. (btw. such 
programs can easily be migrated to Linux/OSX too...or the new 
'System D' ..when it arrives ;-)

You should starts from Kernel.

And if you don't want to start form scratch, you can use my OS 
written in D :)

https://github.com/Rikarin/Trinix

Besides being more productive, it also seems like more fun, 
than responding to MSFT fanboys (although that's been fun too).

How is rewriting the same software from C to D productive?



Sorry MSFT fanboys, if you don't know what userland means. Go 
google it.

Yeah, nobody is as smart as you.

Good luck with rewriting the same code. It's boring, bug 
introducing and useless work but do what you want.


Re: Project Elvis

2017-11-12 Thread Satoshi via Digitalmars-d

On Sunday, 12 November 2017 at 03:25:47 UTC, codephantom wrote:


But everyone wants a more modular, more refined, more modern, 
more secure operating system ...and a more secure systems 
programming language.


How rewriting Linux from scratch will enhance security of the OS? 
By introducing more bugs to the new code?




But very who's focused on that?

Go has some potential, but I don't like many of its design 
decisions.

fakin' D fanboy!



So D could take advantage of the fact the big corporates are 
focused elsewhere (and, also, that they're not very likely to 
turn their attention to redeveloping their os any time soon).
Because nobody spends billions of dollars on something what will 
not brings anything new.




It could take advantage of Go, having made some questionable 
design decisions.


It could take advantage of Rust, seemingly going nowhere (IMHO).

So if there was ever a time for 'System D', it's now.

Instead, everyones focused on making it compatible..with 
this..and that...which is great..that will certainly bring 
attention to D...but I suspect it won't do too much more than 
that.


D needs a grander vision.





Re: Project Elvis

2017-11-11 Thread Satoshi via Digitalmars-d

On Saturday, 11 November 2017 at 11:18:24 UTC, codephantom wrote:


I'd like D to think bigger than just duplicating what's out 
there, and being 'compatible' with this and that operating 
system
 - or just be marketed as a quicker way to compile your slow 
c++ code.


I'd wouldn't mind seeing a new open source operating system, 
lets call it 'System D'just slips of the tongue doesn't it 
;-)




Yeah, stop duplicating what's out there and start writing similar 
software what already exists. Sounds great.


Re: Project Elvis

2017-11-10 Thread Satoshi via Digitalmars-d

On Friday, 10 November 2017 at 12:27:22 UTC, codephantom wrote:
On Friday, 10 November 2017 at 11:55:52 UTC, Jonathan M Davis 
wrote:

[...]


Well, you just got it wrong, and your comments were unfair, and 
actually, your comment were 'bashing' on me!


I simply used a humourous youtube video, as a way to suggest 
that we reconsider whether we 'should' (as Adam puts it), take 
advice from MSFT.


For that to be taken as 'bashing on Adam', is ridiculous.

And to be honest, I find the MSFT fanboys on these forums 
always seem to react in that way, like MSFT is core part of 
their personality or something. You can't say anything negative 
about a MSFT product without them taking it personally, as 
though your directly insulted them. And then their mates decide 
to get involved too, and the whole thing just seems ridiculous.
You didn't say anything negative about MSFT you just start making 
jokes about it.

Then get rect and start crying and saying you did not troll.
I'm not MSFT fanboy, I just find some of the C# features useful, 
nothing more.




I had a go at Visual Studio, because it's ridiculous that D 
relies so much on it. Some don't agree - ok, but I got bashed 
on for that by the MSFT fanboys.


Then I had a go at Windows 10, cause I tried to install it to 
use the Ubuntu shell to run D. But I could't even find how to 
do simple things in Windows 10.
99% of Windows users couldn't find how to do basic stuff in Linux 
but they are not blaming whole Linux community for it.


So please, give some proper 'context' when you next comment 
about me 'bashing on Microsoft'.




Re: Project Elvis

2017-11-10 Thread Satoshi via Digitalmars-d

On Friday, 10 November 2017 at 12:06:42 UTC, codephantom wrote:

On Friday, 10 November 2017 at 11:45:25 UTC, Satoshi wrote:


How many corporations is using D right now? 10?
Windows is still dominant OS and there are a lot of job 
opportunities for C#.


D is unusable for startups or corporations where are junior 
programmers hired anyway because it's too complicated to use. 
And pay senior developers for job what can be done by juniors 
but in different language is not worth.
(e.g. metaprogramming is great stuff but require high skilled 
programmers to use it correctly.)


Yeah..let's use the D forums to bag D. What a great idea.
Yeah, because my opinion about D will be more valuable for the 
language at C# forum :)
I'm not bagging D I'm just providing my personal opinions, 
experience and expectations.




And, why are you trying to compare the state of C# to D.

I really do not see your point.

Besides being completely different languages, with completely 
different purposes, one is backed by a billion$ corporation, 
and the other is developed by a group of volunteers.


I cannot accept the assertion by some, that we 'should' look to 
C# for language advice.


I'm comparing C# to D because D is trying to do the same stuff as 
C#. GUI development and website development. I used vibe.d, I 
used ASP.NET core and I'm still missing some C# features in D. So 
I'm sharing my experience and expectations.


If you don't want to compare D with C# or other languages, just 
don't push D to the same place as C# is. Why isn't D standing as 
a replacement for C++ but pushing into webdev and gui dev? C++ is 
not used for webdev too, and gui dev in C++ is horrible.


And yeah, swift was developed by some volunteers until Apple took 
it. Why Apple didn't take D instead?


Re: Project Elvis

2017-11-10 Thread Satoshi via Digitalmars-d

On Friday, 10 November 2017 at 11:26:41 UTC, codephantom wrote:

On Friday, 10 November 2017 at 11:19:39 UTC, Satoshi wrote:


You are judging C#


Umm... I have 17y in C# programming. Was one of the first to 
take it up.

Have designed/developed apps for large corporates.
Umm... My old colleague had 30 years of development skills, he 
had developing apps for military sector and still he had writing 
2000 lines long functions in C with memcpy and str* crap...




Yet, I switched from C# to D.

I switched from D to C#. There aren't any positions for D.



I don't think looking to MSFT for programming language advice 
is a good idea. D is not C#. If someone doesn't agree with me, 
ok, let them argue their case, not try to silence me.

Nobody is trying to silent you, you just started trolling there.




but looks where is D and where is C#.


ok..and where exactly is C#?

Still, to this day, trying to get itself out of the Windows 
only world.


What a joke.

The world moved beyond the Windows monopoly a decade ago. C# is 
still catching up..


How many corporations is using D right now? 10?
Windows is still dominant OS and there are a lot of job 
opportunities for C#.


D is unusable for startups or corporations where are junior 
programmers hired anyway because it's too complicated to use. And 
pay senior developers for job what can be done by juniors but in 
different language is not worth.
(e.g. metaprogramming is great stuff but require high skilled 
programmers to use it correctly.)


Re: Project Elvis

2017-11-10 Thread Satoshi via Digitalmars-d

On Friday, 10 November 2017 at 11:12:38 UTC, codephantom wrote:
On Friday, 10 November 2017 at 10:51:28 UTC, Jonathan M Davis 
wrote:

we're trying to have a technical discussion.

- Jonathan M Davis


And will someone please tell me, where is technical benefit of 
putting this crap (?: or ??) into a programming language?


After 8 pages of people rambling on about it, nobody agrees on 
anything.


And then you have a go at me for trying to bring in some humour?

Wow!


"Technical benefit"
Where is the technical benefit in changing design of web pages or 
apps? Why windows, Unity, KDE, Gnome or OSX changes their design 
by ages?


Not everything is about technical benefits. Sometimes it's about 
better look, better usability or just innovation and bringing 
something new.



You are judging C#, but looks where is D and where is C#.


Re: Project Elvis

2017-11-10 Thread Satoshi via Digitalmars-d

On Friday, 10 November 2017 at 08:24:59 UTC, codephantom wrote:

On Friday, 10 November 2017 at 05:23:53 UTC, Adam Wilson wrote:
MSFT spends a LOT of time studying these things. It would be 
wise to learn for free from the money they spent.


Is that the same company that made Windows 10?


Not just the company, it's the same person who written MSDOS, Win 
95, Windows Vista, 7, 8, 8.1, 10 and everything else in M$ 
because M$ is just one person company with some random guy who 
can write a thousands lines of code per hour.


Re: Project Elvis

2017-11-07 Thread Satoshi via Digitalmars-d

On Monday, 6 November 2017 at 19:13:59 UTC, Adam Wilson wrote:

On 10/28/17 04:38, Andrei Alexandrescu wrote:

[...]



C# has extensive experience with this operator and I think it 
would be wise to study the history of what they did and why the 
did it. NOTE: I understand that other languages have it, and 
there are variations on the theme, but C# has many similarities 
to D and extensive "in practice" idioms.


[...]


I strongly agree with you.


Re: Project Elvis

2017-11-06 Thread Satoshi via Digitalmars-d
On Monday, 6 November 2017 at 08:06:54 UTC, Jonathan M Davis 
wrote:
On Monday, November 06, 2017 07:10:43 bauss via Digitalmars-d 
wrote:
On Monday, 6 November 2017 at 00:20:09 UTC, Neia Neutuladh 
wrote:

> On Saturday, 28 October 2017 at 11:38:52 UTC, Andrei
>
> Alexandrescu wrote:
>> [...]
>
> It's easy to write in function form:
>   auto orElse(T)(T a, lazy T b)
>   {
>
> return a ? a : b;
>
>   }
>
>   writeln(args[1].length.orElse(fibonacci(50)));
>
> This version can also be specialized for things like 
> Nullable, where you can't necessarily cast it safely to a 
> boolean but have a check for validity.

>
> Is it that valuable to have an operator for it instead?
>
>
> As an aside, I believe feepingcreature had a custom infix
>
> operator for this sort of thing defined, so you could write:
>   (a /or/ b /or/ c).doStuff();
>
> The implementation (along with /and/) is left as an exercise 
> to

> the reader.

Sure you might be able to write it easily, but pretty much 
everyone writes a function like that in their projects and you 
don\t really know the implementation always and you have to 
remember the exact name or else you end up writing the 
function yourself in your project to make sure the 
implementation is exactly like that, which in fact turns out 
to be re-inventing the wheel.


By having an official syntax for it, you don't end up with 
code duplication like that and the implementation details of 
the behavior is clear.


Because in some implementation "orElse()" might only check if 
the value is null and not necessary if the value is true.


Ex. one might implement it like:

auto orElse(T)(T a, lazy T b)
{
  return a !is null ? a : b;
}

Such implementation detail is not clear from the call-side.

However with an official implementation you know exactly how 
it will behave and nothing is obscure like this.


That might be an argument for having an official 
implementation, but it's not really an argument for why it 
should be built into the language; it could just as easily be 
in Phobos if that's all that matters.


- Jonathan M Davis


You need additional import for this
verbose syntax
https://en.wikipedia.org/wiki/Syntactic_sugar
Why we have operators overloading when we could have Equals() and 
stuff like in java?
Why we have arr ~= arr2 when we could have Array.mergeArrays(arr, 
arr2) instead?


Look, this operator does not break anything. If you don't want to 
use it, just don't, but why do you force everyone else to not to 
use it, just because it is not adding anything "more valuable" 
than just better syntax?


Re: Project Elvis

2017-10-30 Thread Satoshi via Digitalmars-d

On Sunday, 29 October 2017 at 20:37:21 UTC, bauss wrote:
On Sunday, 29 October 2017 at 20:15:41 UTC, Ola Fosheim Grøstad 
wrote:

[...]


But casting to bool is what you use to tell whether something 
is valid or not.


true = valid, false = invalid.

If you want 0 to be valid for a type then you wrap around it 
with opCast.


Ex.

---
import std.stdio;

struct MyInt
{
int value;

bool opCast(T : bool)()
{
return value >= 0;
}
}

void main()
{
MyInt a = MyInt(1);
MyInt b = MyInt(0);
MyInt c = MyInt(-1);

if (a) writeln("a is valid");
if (b) writeln("b is valid");
if (c) writeln("c is valid");
}
---

Output:
a is valid
b is valid


TL;DR

This could be done by maybe monad.

int? a = 0;
if (a) writeln("a is valid");



BTW: Thanks for implementing the Elvis feature.


Re: My two cents

2017-10-25 Thread Satoshi via Digitalmars-d

On Tuesday, 24 October 2017 at 20:36:47 UTC, Walter Bright wrote:

On 10/24/2017 3:36 AM, Satoshi wrote:

Can you provide an example?


I'd start with https://dlang.org/spec/interface.html

You'll see the same thing with Windows COM programming, and 
using interfaces in Java.


 view.di 
interface View {
void render();
}
View createView();

 button.di 
import view;
interface Button : View {
void simulateClick();
}
Button createButton();

 closed_src_library.d 
import view, button;
private class LibraryView : View {
   int hidden_data;
   void render() { do something with hidden_data }
}

private class LibraryButton : Button {
int hidden_data;
void simulateClick() {  }
}

View createView() {
return new LibraryView();
}

View createButton() {
return new LibraryButton();
}

--- my_extension.d ---
import view, button;
class ExtendView : View {
View base;
this() {
base = createView();
}
void render() {
base.render();
... do my rendering ...
}
}


Thanks, but I see there 3 problems:
1. this example enforce users to use composition instead of 
inheritance when they wants to create custom descendant.
2. multiple dispatch levels. Extending the ExtendView in another 
lib we get triple dispatch for each method.
3. 1:1 methods mapping is required? or can be there used some 
sort of aliasing?


interface View {
  void render();
  // another hundred methods
}

class ControlView : View {
  View parent;

  void render() { parent.render(); }
}

class ButtonView : View {
  ControlView parent;

  void render() { parent.render(); } // triple dispatch
}




Re: My two cents

2017-10-24 Thread Satoshi via Digitalmars-d

On Tuesday, 24 October 2017 at 10:20:43 UTC, Walter Bright wrote:

On 10/24/2017 1:13 AM, Satoshi wrote:

But it's quite useless to me.


That's what interfaces are for. Define your View and Button as 
interfaces. The implementations of interfaces are completely 
hidden from the derived class.


Can you provide an example?


Re: My two cents

2017-10-24 Thread Satoshi via Digitalmars-d

On Tuesday, 24 October 2017 at 08:06:55 UTC, Atila Neves wrote:

On Tuesday, 24 October 2017 at 07:17:08 UTC, Satoshi wrote:

On Monday, 23 October 2017 at 21:42:03 UTC, Atila Neves wrote:

On Monday, 23 October 2017 at 21:14:18 UTC, bauss wrote:
On Monday, 23 October 2017 at 12:48:33 UTC, Atila Neves 
wrote:

[...]


Okay, but what about now?

void sendAMessage(string message)
{

}


sendAMessage(text(...));

Atila


boilerplate...


True, but in my opinion not enough to justify complicating the 
language. One could also always do:


import std.conv: t = text;
sendAMessage(t("Foo is ", foo, " and bar is ", bar"));

If it were me I'd just make `sendAMessage` take a variadic 
template and call text internally.


Atila


so, we should complicate source code instead of the language?

Actually, you provide one of the best examples why we should add 
this syntactic sugar.


Re: My two cents

2017-10-24 Thread Satoshi via Digitalmars-d

On Tuesday, 24 October 2017 at 07:55:49 UTC, Walter Bright wrote:

On 10/24/2017 12:21 AM, Satoshi wrote:

what about this:

-- file.d
class Foo {
   private int bar;
   private string text;

   void call() { }
}

--- file.di

class Foo {
   call();
}



and then I want to inherit from it (I have access to file.di 
only)
class Bar : Foo { // I cannot due I have misleading 
information about size of Foo


}



If you don't add data members to Bar, it will work. If you do 
add data members, then the compiler needs to know the data 
members in Foo. This is the same in C++ .h files.


You could specify Foo as an interface,

  https://dlang.org/spec/interface.html

and then Bar can inherit from Foo without needing any knowledge 
of Foo's data members.



But it's quite useless to me.


i.e.
class View { }
class Button : View { }

I want to let users to inherit from View or Button and let them 
customize the elements.

This can be done just by PIMPL.

But doing PIMPL inheritance inside one library is pain in the a$$.

 view.d --
class View {
  private ViewData _;

  package class ViewData {
int a, b, c;
  }

  this() {
initData();
  }

  protected void initData() {
if (!_) _ = new ViewData;
  }

  void render() { }
}


--- button.d ---
class Button : View {
  package class ButtonData : ViewData {
string stuff;
  }

  protected override void initData() {
if (!_) _ = new ButtonData;
  }

  void simulateClick() { }
}


and headers
- view.di 
class View {
  private void* _;

  this();
  void render();
}

- button.di ---
class Button : View {
  void simulateClick();
}



But the worst part is that I need to hold di in sync to d files 
manually, so there is not any advantages over C++'s header files.


Re: My two cents

2017-10-24 Thread Satoshi via Digitalmars-d

On Monday, 23 October 2017 at 15:21:02 UTC, Kagamin wrote:

On Friday, 20 October 2017 at 09:49:34 UTC, Adam Wilson wrote:
Others are less obvious, for example, async/await is syntax 
sugar for a collection of Task-based idioms in C#.


Now I think it's doesn't fit D. async/await wasn't made for 
performance, but for conservation of thread resources, async 
calls are rather expensive, which doesn't fit in D if we prefer 
raw performance. Also I found another shortcoming: it doesn't 
interoperate well with cache: cache flip flops between 
synchronous and asynchronous operation: when you hit cache it's 
synchronous, when you miss it it performs IO.



Actually, async/await should be faster and safer than running 
same blocking code in another thread and then syncing between 
them.


If we want to use D for GUI development we will need this feature 
anyway. It's the easiest solution how to run blocking functions 
in GUI callback without freezing, it reduces bugs and callback 
hell. Look at Javascript and Node.js (I think).


Re: My two cents

2017-10-24 Thread Satoshi via Digitalmars-d

On Monday, 23 October 2017 at 20:47:26 UTC, Walter Bright wrote:

On 10/18/2017 1:56 AM, Satoshi wrote:
Unable to publish closed source library without workaround and 
ugly PIMPL design.



Consider this:

--- file s.d 
  struct S {
int x;
this(int x) { this.x = x; }
int getX() { return x; }
  }
--- file s.di 
  struct S {
this(int x);
int getX();
  }
--

User code:

import s;
S s = S(3);
writeln(s.getX());

Ta dah! Implementation is hidden, no PIMPL. Of course, inlining 
of the member functions won't work, but it won't work in C++, 
either, when this technique is used.


I.e. you can use .di/.d files just like you'd use .h/.cpp in 
C++. The technique works with classes, too.



what about this:

-- file.d
class Foo {
  private int bar;
  private string text;

  void call() { }
}

--- file.di

class Foo {
  call();
}



and then I want to inherit from it (I have access to file.di only)
class Bar : Foo { // I cannot due I have misleading information 
about size of Foo


}



Re: My two cents

2017-10-24 Thread Satoshi via Digitalmars-d

On Monday, 23 October 2017 at 21:42:03 UTC, Atila Neves wrote:

On Monday, 23 October 2017 at 21:14:18 UTC, bauss wrote:

On Monday, 23 October 2017 at 12:48:33 UTC, Atila Neves wrote:

On Monday, 23 October 2017 at 09:13:45 UTC, Satoshi wrote:

On Wednesday, 18 October 2017 at 08:56:21 UTC, Satoshi wrote:

[...]


Whats about this one?

auto foo = 42;
auto bar = "bar";
writeln(`Foo is {foo} and bar is {bar}`);


writeln("Foo is ", foo, "and bar is ", bar");

Two more characters.

Atila


Okay, but what about now?

void sendAMessage(string message)
{

}


sendAMessage(text(...));

Atila


boilerplate...


Re: My two cents

2017-10-23 Thread Satoshi via Digitalmars-d

On Wednesday, 18 October 2017 at 08:56:21 UTC, Satoshi wrote:

Hi,
I had been using D for almost 6 years and I want to share my 
opinion with you.
I don't want to blame anyone but I'll focus more on bad things 
and possible improvements.

And this is just how I see D from my perspective.
(Sorry for my English, I'm too lazy to take the lessons).

[...]


Whats about this one?

auto foo = 42;
auto bar = "bar";
writeln(`Foo is {foo} and bar is {bar}`);



Re: My two cents

2017-10-20 Thread Satoshi via Digitalmars-d
On Friday, 20 October 2017 at 08:32:36 UTC, Jonathan M Davis 
wrote:
On Friday, October 20, 2017 08:09:59 Satoshi via Digitalmars-d 
wrote:

On Friday, 20 October 2017 at 04:26:24 UTC, Jonathan M Davis

wrote:
> On Friday, October 20, 2017 02:20:31 Adam D. Ruppe via
>
> Digitalmars-d wrote:
>> On Friday, 20 October 2017 at 00:26:19 UTC, bauss wrote:
>> > [...]
>>
>> return getOr(foo, null);
>>
>> That's really easy to do generically with a function. I 
>> wouldn't object to the ?? syntax, but if it really is 
>> something you write all over the place, you could just 
>> write the function.

>>
>> > [...]
>>
>> In dom.d, since I use this kind of thing somewhat 
>> frequently, I wrote a function called `optionSelector` 
>> which returns a wrapper type that is never null on the 
>> outside, but propagates null through the members. So you 
>> can do

>>
>> foo.optionSelector("x").whatever.you.want.all.the.way.down
>>
>> and it handles null automatically.
>>
>>
>> You can do that semi-generically too with a function if it 
>> is something you use really frequently.

>
> For better or worse, solutions like this are the main reason 
> that a number of things folks ask for don't get added to the 
> language. It's frequently the case that what someone wants 
> to do can already be done using the language as-is; it just 
> may not be as syntactically pleasing as what the person 
> wants, and they may not know D well enough yet to have come 
> up with the solution on their own.

>
> - Jonathan M Davis

Yeah, but if it can be done by stuff like you said it's not 
reason to not implement syntactic sugar for it.


array[0 .. 42] can be substituted by array.slice(0, 42) too, 
but

it's not.

it's more handy to write
void foo(int? a, string? b);

than
void foo(Maybe!int a, Maybe!string b);


same for
return a ?? null;

than
return getOr(a, null);


foo.optionSelector("x").whatever.you.want.all.the.way.down 
it's not clear if you are able or not to able to hit the null.


foo?.x?.whatever?.you?.want;
is more clear and doesn't need any boilerplate.
it doesn't need to be implemented in code.


Yes, there is syntactic sugar in the language, and yes, there 
could be more, but it reached the point a while ago where 
Walter and Andrei seem to have decided that additional 
syntactic sugar isn't worth it. For something to be added the 
language, it generally has to add actual capabilities or solve 
a problem that is just unreasonable or impossible to solve with 
a library solution.


And honestly, where to draw the line on syntactic sugar is 
highly subjective. Something that one person might think makes 
the code nicely concise might seem annoyingly crpytic to 
someone else. And obviously, not everything can have syntactic 
sugar. Not everything can be built into the language. A line 
has to be drawn somewhere. It's just a question of where it 
makes the most sense to draw it, and that's not at all obvious. 
There's bound to be disagreement on the matter.


D is an extremely powerful language, and for now at least, the 
conclusion seems to be that its power is being underutilized 
and that it simply isn't worth adding things to the language if 
they can be easily done with a library solution. Obviously, 
there are things that some folks would like to be in the 
language that aren't, but there's always going to be something 
that someone wants to be in the language but isn't, and the 
guys in charge seem to have decided that D is now featureful 
enough and powerful enough that it's not getting new features 
unless it actually needs them. Simply making some syntax look 
prettier isn't enough. A feature has to actually add 
capabilities that we're missing. There may be exceptions to 
that, but that's generally where things sit.


And honestly, they were going to have to take this stance at 
some point. We can't keep adding syntactic sugar forever. They 
just happen to have stopped adding syntactic sugar before they 
added some syntactic sugar that you'd like D to have.


If you can make a really good argument in a DIP as to why D 
really needs a feature that you want, then it may yet get added 
(even if it's only syntactic sugar), but it's going to have to 
be a really compelling argument that is likely going to need to 
show why the feature is objectively better and thus worth 
having rather than simply saving you a bit of typing or making 
the code look prettier. It's probably going to have to clearly 
reduce bugs or provide capabilities that can't reasonably be 
done with a library.


D is long past the point where the language was in flux and we 
were constantly adding new features. Features do still get 
added, but they really have to pull their own weight rather 
than being a nice-to-have.


- Jonathan M

Re: My two cents

2017-10-20 Thread Satoshi via Digitalmars-d
On Friday, 20 October 2017 at 04:26:24 UTC, Jonathan M Davis 
wrote:
On Friday, October 20, 2017 02:20:31 Adam D. Ruppe via 
Digitalmars-d wrote:

On Friday, 20 October 2017 at 00:26:19 UTC, bauss wrote:
> return foo ? foo : null;
>
> where
>
> return foo ?? null; would be so much easier.

return getOr(foo, null);

That's really easy to do generically with a function. I 
wouldn't object to the ?? syntax, but if it really is 
something you write all over the place, you could just write 
the function.


> return foo ? foo.bar ? foo.bar.baz ? foo.bar.baz.something : 
> null;

>
> Which could just be:
>
> return foo?.bar?.baz?.something;

In dom.d, since I use this kind of thing somewhat frequently, 
I wrote a function called `optionSelector` which returns a 
wrapper type that is never null on the outside, but propagates 
null through the members. So you can do


foo.optionSelector("x").whatever.you.want.all.the.way.down

and it handles null automatically.


You can do that semi-generically too with a function if it is 
something you use really frequently.


For better or worse, solutions like this are the main reason 
that a number of things folks ask for don't get added to the 
language. It's frequently the case that what someone wants to 
do can already be done using the language as-is; it just may 
not be as syntactically pleasing as what the person wants, and 
they may not know D well enough yet to have come up with the 
solution on their own.


- Jonathan M Davis


Yeah, but if it can be done by stuff like you said it's not 
reason to not implement syntactic sugar for it.


array[0 .. 42] can be substituted by array.slice(0, 42) too, but 
it's not.


it's more handy to write
void foo(int? a, string? b);

than
void foo(Maybe!int a, Maybe!string b);


same for
return a ?? null;

than
return getOr(a, null);


foo.optionSelector("x").whatever.you.want.all.the.way.down
it's not clear if you are able or not to able to hit the null.

foo?.x?.whatever?.you?.want;
is more clear and doesn't need any boilerplate.
it doesn't need to be implemented in code.


Re: My two cents

2017-10-18 Thread Satoshi via Digitalmars-d
On Wednesday, 18 October 2017 at 09:03:27 UTC, Andrea Fontana 
wrote:

I think you missed many things for example:

On Wednesday, 18 October 2017 at 08:56:21 UTC, Satoshi wrote:


e.g.
auto result = device.start(foo, bar); // This is RPC to remote 
server returning Task!Bar

// do some important stuff
return await result; // wait for RPC finish, then return it's 
result


https://dlang.org/phobos/std_parallelism.html#.task


Sorry, I mean Task from C# which is returned from async func, not 
the D's Task.


Re: My two cents

2017-10-18 Thread Satoshi via Digitalmars-d

+syntactic sugar for dynamic types

some better explaining tutorials and examples about shared. After 
6 years I'm still unable to use it properly.


My two cents

2017-10-18 Thread Satoshi via Digitalmars-d

Hi,
I had been using D for almost 6 years and I want to share my 
opinion with you.
I don't want to blame anyone but I'll focus more on bad things 
and possible improvements.

And this is just how I see D from my perspective.
(Sorry for my English, I'm too lazy to take the lessons).


First, D started as a great new language with the best from all 
languages. But now D seems more and more conservative. New 
syntactic sugars aren't added just because they can be found in 
phobos. (this was Walter's answer when I asked for maybe monad 
syntactic sugar).


OK, what I'm missing in D and what I think is wrong?

syntactic sugar for:
tuples
maybe monad (why we cannot have same syntax as in C#?)
conditional dereferencing and stuff about that (same as in C#)
foo?.bar;
foo?[bar];
return foo ?? null;

async/await (vibe.d is nice but useless in comparison to C# or js 
async/await idiom)
I want to create function returning Promise/Task and await where 
I want to.

e.g.
auto result = device.start(foo, bar); // This is RPC to remote 
server returning Task!Bar

// do some important stuff
return await result; // wait for RPC finish, then return it's 
result


I want to do this and not any ugly workaround about that.


@trusted, @safe, @system - why we have 3 keywords instead of one? 
And why it's so complicated to use?


First, we should have one 'unsafe' keyword.
Second, everything should be safe by default.
3rd, if we want to declare @system func, use 'void foo() unsafe;'
if we want to declare @trusted func, use
void foo() {
unsafe {

}
}

This fulfills the D's idiom in better way, because we should be 
defining unsafe sections as small as possible.



C# properties instead of existing ones.
function and property should be two different things.
Calling function without () or assigning to it by = is a ugly 
behavior and should be avoided.


implement this thing from C# (just because it's cool)
new Foo() {
  property1 = 42,
  property2 = "bar"
};


Reference counting when we cannot use GC...


Commercial usage, shared libraries and stuff
There isn't any handy tool to download, manage and publish closed 
source stuff.
dub is great for simple solutions but useless in big projects 
with multiple targets, configurations, etc.
Everything is primary focused on opensource development (but 
everyone here wants to see D as a next successor of C++ in 
commercial sphere).



Still cannot easily develop closed source dlls on Windows. On 
Linux every symbol is public by default, but on Windows not so 
it's needed to export them manually.



Unable to publish closed source library without workaround and 
ugly PIMPL design.


Add dll/so usage without header files
(export enums, templates and stuff right into dll/so and let D 
compiler to import these stuff from it)




For me, it seems like Walter is solving edge case problems like 
return ref parameters and return functions but is unable to add 
some basic stuff.



Thanks for your time.
- Satoshi


Re: Hiring D programmers (with cryptography and blockchain knowledge are preferred)

2017-08-14 Thread Satoshi via Digitalmars-d-announce
Thanks for the interesting idea. I decided to try something 
similar. (just for fun).


Decentralized Social Network (DecNet):
Is a conjunction of facebook, twitter and reddit.

Clients:
Can create their own profiles (private key, public key, address, 
profile file) and share them through the network. Pull other 
profiles by address. Writing posts, replies, open threads, vote, 
etc.
Content like images, videos, etc. cannot be stored in the profile 
file but should be linked through special tags (like html?).

Every client provide their own profile file.

Servers:
Will provide a list of addresses where profile files can be found 
including an address of the owner.

Will backup profile files.

1. Content cannot be in blockchain because of overbloating the 
network. Every profile has their own `file` with all the content 
in it.
2. `Servers` can setup their exchanging limits. Like profile size 
limit (default 40 MB), time to live (3 to 48 hours from last 
profile pull).


More info will be added to the README later.

https://github.com/SatoshiR/DecNet



People... It just came to mind... it's a very bad idea to make 
an incensurable social media. It would be a safe heaven for 
pedophiles, drug traffickers, human traffickers, > hitmen and 
criminals alike.


It's similar to working as a programmer for a military. You are 
just a provider who provides the software.


Re: Single exe vibe.d app

2017-04-06 Thread Satoshi via Digitalmars-d-learn

On Wednesday, 5 April 2017 at 12:42:23 UTC, evilrat wrote:

On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:

Hi,
How can I build single exe application with vibe.d (windows)?
now it require zlib.dll, libeay32.dll and ssleay32.dll

But I need it as single app.


btw, if all you need is to ship it as a single file and don't 
care if it writes anything, you can probably compile-in those 
.dll's to your .exe as string with D import statement and write 
them on disk from static module ctor (static shared this{} at 
module scope) when it launched.


It's not possible because exe will not run when dll is missing. 
Phobos (or vibe.d ?) doesn't load dll dynamically by dlopen but 
link with .lib of the .dll


Single exe vibe.d app

2017-04-05 Thread Satoshi via Digitalmars-d-learn

Hi,
How can I build single exe application with vibe.d (windows)?
now it require zlib.dll, libeay32.dll and ssleay32.dll

But I need it as single app.


Re: pImpl in D

2017-04-04 Thread Satoshi via Digitalmars-d
test/Foo.di(3,1): Error: class test.Foo.FooPrivate is forward 
referenced when looking for 'opAssign'


forward reference in Foo.di


test/Bar.d(14,25): Error: cannot implicitly convert expression 
(p) of type test.BarPrivate.BarPrivate to test.Foo.FooPrivate


I'm unable to cast from BarPrivate to FooPrivate because it can't 
recognize Bar : Foo; inheritance from Foo.di (FooPrivate.d and 
BarPrivate.d is ignored).



test/Foo.di(3,1): Error: class test.Foo.FooPrivate is forward 
referenced when looking for 'opCast'


same as first


pImpl in D

2017-04-04 Thread Satoshi via Digitalmars-d

Hi,
do someone have any experience with pImpl and inheritance in D?

I tried something like:

// FooPrivate.d
class FooPrivate {
int a;
}


// BarPrivate.d
import FooPivate;

class BarPrivate : FooPrivate {
string b;
}


// Foo.d
import FooPrivate;

class Foo {
protected FooPrivate m_private;

this() { m_private = new FooPrivate; }
}


// Bar.d
import Foo;
import FooPrivate;
import BarPrivate;

class Bar : Foo {
this() { m_private = new BarPrivate; }
}


And public interface
// Foo.di
class FooPrivate;
class Foo {
private FooPrivate m_private;
}


Bar.d looks like it imported Foo with forward referenced 
FooPrivate and is unable to resolve it by importing FooPrivate.


Is this bug?
Do you know about any *less verbose* design pattern how I can 
hide implementaion details from .di files?


Thanks!


Re: .di generator fix

2017-04-03 Thread Satoshi via Digitalmars-d

On Monday, 3 April 2017 at 16:41:15 UTC, Stefan Koch wrote:

On Monday, 3 April 2017 at 11:16:41 UTC, Satoshi wrote:

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

6 months from reporting this bug and there is still no usable 
fix...



How to test:
1. generate di files from druntime and phobos
2. compile any bigger project like vibe.d to .di files instead 
of .d files.

3. fix bugs


I fixed at trusted thing just now :)


Thank you :)

But there are more bugs.
Please look at this
https://issues.dlang.org/show_bug.cgi?id=16590#c14
and this
https://issues.dlang.org/show_bug.cgi?id=16590#c16
If you have some free time.


.di generator fix

2017-04-03 Thread Satoshi via Digitalmars-d

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

6 months from reporting this bug and there is still no usable 
fix...



How to test:
1. generate di files from druntime and phobos
2. compile any bigger project like vibe.d to .di files instead of 
.d files.

3. fix bugs


Re: How to continue after the book?

2017-03-28 Thread Satoshi via Digitalmars-d-learn

On Tuesday, 28 March 2017 at 07:27:31 UTC, I Lindström wrote:
After getting the basics down, how did you continue when 
learning programming in general?


I do have a need for which I've been trying out a few languages 
and D seems by far the best for me. Should I just start doing 
that project and learn as I go by googling and asking here, or 
are there some other things you did before starting your first 
"real" project.



You can develop your skills just by doing it not reading about 
it. Theoretical base is good when you can associate learned 
information with your practical skills.


Re: Can you fix this code to avoid using pointers?

2017-03-11 Thread Satoshi via Digitalmars-d-learn

On Saturday, 11 March 2017 at 12:35:42 UTC, XavierAP wrote:
I do not really think it's a bad solution, to check several 
scalar arguments that must obey the same condition; just 
wondering if you have better ideas. Try to avoid modifying the 
function's signature and defining custom types, unless you have 
a really terrific idea.


void calc(double in1, double in2, double in3, double in4)
in {
   foreach(const p; [, , , ])
  enforce(*p > 0);
}
body { /* ... */ }



void calc(in double[] array...) {
foreach (x; array) { }
}


Create doc simultaneously with compilation

2017-02-19 Thread Satoshi via Digitalmars-d-learn
Why is not possible to create documentation, compile code and 
generate header files simultaneously?


When I pass -D and -Dd flags to ldc2 command it won't create doc 
until I don't pass -o- flag too.


Re: Force inline

2017-02-19 Thread Satoshi via Digitalmars-d-learn

On Sunday, 19 February 2017 at 19:19:25 UTC, berni wrote:

Is it possible to force a function to be inlined?

Comparing a C++ and a D program, the main difference in speed 
(about 20-30%) is, because I manage to force g++ to inline a 
function while I do not find any means to do the same on D.



Or make it as template, maybe...


void foo()() {

}


Re: CTFE Status 2

2017-02-18 Thread Satoshi via Digitalmars-d
Will be possible to make precompiled headers and distribute it 
with static library for example?


Re: Release D 2.073.1

2017-02-16 Thread Satoshi via Digitalmars-d-announce

On Thursday, 16 February 2017 at 17:35:27 UTC, Martin Nowak wrote:

Glad to announce D 2.073.1.

http://dlang.org/download.html

This point release fixes a few issues over 2.073.0, see the 
changelog for more details.


http://dlang.org/changelog/2.073.1.html

-Martin


Why wasn't https://issues.dlang.org/show_bug.cgi?id=16590 
released yet?


Re: Questionnaire

2017-02-09 Thread Satoshi via Digitalmars-d-announce

1. Why your company uses  D?

I can use D only for very small apps in my job.

My own project use D because it was the best language what I 
found when I started developing OS from scratch 5 years ago.



2. Does your company uses C/C++, Java, Scala, Go, Rust?

We use C/C++, Java


3. If yes, what the reasons to do not use D instead?

Replacement as C++:
There is problem to find and hire C++ programmers so how could we 
find D programmers...


Nobody here wants to learn new programming language...
Many of ours projects/libraries are already written in C/C++.

Replacement as Java:
Making GUI apps in D (with Qt) is pain in the a$$. We need good 
IDE, Drag'n'Drop GUI builder and framework with stuff like in 
Java or .NET first.




2. Have you use one of the following Mir projects in production:

No

4. Have you use one of the following Tamedia projects in your 
production:

No


5. What D misses to be commercially successful languages?

Native GUI
IDE with D'n'D interface builder
Framework with all stuff in (like .NET)
Maybe more understandable documentation with more examples.

More syntactic sugar in D? Like maybe monad, tuples, etc.

6. Why many topnotch system projects use C programming language 
nowadays?

Small and fast programs with no runtime.



dep files

2017-02-01 Thread Satoshi via Digitalmars-d-learn

Hi,
I'm using package.d file for the project, where is each file 
imported. In each file is imported only that one package file 
(like `import Foo;`).


Problem is with .dep files. dep file for each source file 
contains all source files of the project just because it imports 
that package.


This made dep files quite useless because every time when I 
change something just in one file, whole project is always 
rebuild.


Re: Why not promoting team work?

2017-01-17 Thread Satoshi via Digitalmars-d

On Saturday, 14 January 2017 at 03:05:44 UTC, nbro wrote:

On Saturday, 14 January 2017 at 02:57:05 UTC, ketmar wrote:

On Saturday, 14 January 2017 at 02:28:34 UTC, nbro wrote:

How could you do such a thing?


freakin' easy: just pay people to do what you want. either 
that, or people will keep working on the things *they* are 
interested (and not someone else).


Serious users, to whom I'm directing this post, who really 
believe in D's potential, should try to collaborate somehow, 
like ants which are trying to protect their nest and queen. A 
serious programmer knows that there's no point of starting a 
"another" project. There must be a goal and the the product 
must be useful somehow.


I believe in D's potential and that's the reason why I'm not 
developing IDE and GUI AppKit as an open-source project. Sorry, 
but I don't have any motivation to spend 2 years of development 
something that will not bring me anything. Actually, I want to do 
it  for full-time and only way how to do it is be paid by large 
company or make the company by myself.


You cannot expect that people doing theirs full-time jobs will 
have free time to collaborate on open-source projects. Look, how 
long it takes to fix bug in D compiler.


Re: Gui in D: I miss this project

2017-01-10 Thread Satoshi via Digitalmars-d

On Monday, 9 January 2017 at 21:41:37 UTC, aberba wrote:
This seemed to be an effort (among others) to bring GUI cross 
platform to standard D but some 
language/compiler/Phobos/Deimos/manpower issues were the drag.


https://github.com/Devisualization


We now have DLangUI.

I wonder what the current drag is.


Actually I'm working on a GUI toolkit for 2 years. This quarter 
could be a first release if everything goes fine.


Re: What are you planning, D related, for 2017 ?

2017-01-02 Thread Satoshi via Digitalmars-d

On Monday, 2 January 2017 at 15:16:31 UTC, Basile B. wrote:
Write your plan here, and let's take a rendez-vous next year, 
to check those plans !!


I want to release beta version of GUI Framework, build tool and 
IDE for D.


Re: D future ...

2016-12-28 Thread Satoshi via Digitalmars-d

On Wednesday, 28 December 2016 at 19:51:38 UTC, Jerry wrote:
You don't need the source of the GUI framework to use a 
compiled program. If you are developing both the GUI and the 
IDE, then you don't need interface files. You can just use the 
D source code. Once you compile the IDE no one will have access 
to the interface files anyways, unless (like i mentioned above) 
for third party plugin developers.
No, GUI framework is one part of project like Qt, GTK or WPF and 
IDE is an another part.


That's including all the actual code bodies, you could probably 
write a regex to detect and select them. It wouldn't take as 
long as you think when you start erasing hundreds of lines of 
code with a single backspace. Anyways point is, it isn't really 
a showstopper. You could still have released your IDE without 
interface files to be used as an IDE and you could have made 
the interface files yourself if you really wanted to release 
the GUI.


It's not so simple. I actually must know which functions can be 
called by CTFE and which not. auto functions should have stripped 
body with replaced auto for a specific type, etc.


Main part of the project is GUI framework not IDE itself. IDE is 
made just for simplify GUI development by D'n'D Interface 
Builder. Like in VS or XCode or Qt Creator.


Actually I want to release pre-alpha version of GUI framework 
just for a few people to show them progress, let them test it and 
get some feedback.


I can generate header files and then fix it manually but first I 
need a full coverage tests to recognize where bugs are. But 
still, patching header files every time when I change something 
is not real.


Re: D future ...

2016-12-28 Thread Satoshi via Digitalmars-d

On Wednesday, 28 December 2016 at 12:55:17 UTC, YAHB wrote:
Sorry, to be honest I didn't take you seriously. Your bug 
report, so the starter of this off topic fork, is barely 
understandable: impossible to understand if it was a language 
issue, an issue of the header function generator...
Sorry, I didn't want to start OT I just want to point on some 
aspects of D from my view.
My english is bad so I'm not able to express things as 
professionally as in my native language. But I think people here 
are enough intelligent to take me seriously regardless on how I 
write. Sorry...


Re: D future ...

2016-12-28 Thread Satoshi via Digitalmars-d

On Wednesday, 28 December 2016 at 12:43:03 UTC, bachmeier wrote:

On Wednesday, 28 December 2016 at 08:35:52 UTC, Satoshi wrote:
I'm working on a commercial IDE and GUI framework for a year 
and half and I'm not able to release any version due to this 
bug[1].


...

Please, stop adding new features to D and start fixing 
existing ones.


- Satoshi

---
[1] https://issues.dlang.org/show_bug.cgi?id=16590


You've got things reversed. The point of a company like Google 
or Sun backing a language is that things get done, like this 
bug fix, so that the language can be used for whatever that 
company needs it to do.


You claim you want to make money off the language, yet you are 
demanding that volunteers immediately fix a bug that is holding 
you back. That's an odd business model. You have three options: 
pay to fix it yourself, use a different language that allows 
you to benefit from work paid for by more profitable companies 
like Google, or wait for volunteers to do it on their schedule.


This is not unique to D. I'm reminded of Visual Studio not 
supporting C99 or Firefox not supporting certain HTML 5 
features.


I know that :/  I'm just responding to people who wants shift D 
to commercial companies but are doing different steps than they 
should do.


Yes, it's true that I want to make money off the language so I 
should paid for that fix but in other way you want to promote D 
to others and this is the thing what's holding me back to do the 
same. And the bug will be fixed anyway, so.




Re: D future ...

2016-12-28 Thread Satoshi via Digitalmars-d

On Wednesday, 28 December 2016 at 12:14:02 UTC, YAHB wrote:
But what's the real issue ? You want to release a 
pre-compiled static library with headers ?

Yes.


you'll be in front of another issue then: "dmd_personality"... 
unless you release the static library for DMD, LDC, GDC, + each 
version for each, basically debug + release...so already 6 ;]


Nope :)
Rikarin Studio is a package of precompiled druntime, phobos, 
Rikarin Framework (Async core, GUI AppKit, basic bindings...) 
bundled with LDC and own build tool distributed as a toolkit. 
User will not be able to choose between compilers :)


This is what people need, not 800 variants of every tool where at 
least one cannot work properly.


Re: D future ...

2016-12-28 Thread Satoshi via Digitalmars-d

On Wednesday, 28 December 2016 at 12:03:53 UTC, YAHB wrote:
Making header files manually is a wast of time what i don't 
have.


Write your own header generator.

Yes, why not to write my own language.


Pfff...too hard to use an AST visitor. And that wants to 
release a commercial IDE.

Compiler design is not my business.

Personally I don't get the point of writing an IDE if at a 
time or another you don't start working a bit around you 
know...D syntax, D grammar.

Actually, I written an OS in D.


True...an Outrageous Scam...

So funny...
https://github.com/Rikarin/Trinix

Instead you seem to get stuck on first issue related to the 
language.
First issue? Developers of LDC can respond and fix issue in a 
real time but developers of D frontend not. And that's the 
thing what pissed me off.


But what's the real issue ? You want to release a 
pre-compiled static library with headers ?

Yes.


Then you could license the sources, simply.

No, thanks.


Just think to your strategy and try to be wise. Even Qt sources 
are available. There's at least 10 ways to waste a freelance 
commercial project.
Qt is out of dated crap mostly useless for fast GUI development. 
Anyway, it's my project and I don't want to release source codes. 
No, it's not a freelance project, I got some money for dev and I 
already have clients waiting for stable release. There will be 
info soon.


Personally I've been client of a commercial GUI framework, 
and we get the sources with the license. It worked, I mean 
that the developer had clients.

I don't need to follow same rules as others do.


Re: D future ...

2016-12-28 Thread Satoshi via Digitalmars-d

On Wednesday, 28 December 2016 at 11:18:10 UTC, YAHB wrote:

On Wednesday, 28 December 2016 at 10:52:45 UTC, Satoshi wrote:
On Wednesday, 28 December 2016 at 10:52:45 UTC, Satoshi wrote:
Making header files manually is a wast of time what i don't 
have.


Write your own header generator.

Yes, why not to write my own language.

Personally I don't get the point of writing an IDE if at a time 
or another you don't start working a bit around you know...D 
syntax, D grammar.

Actually, I written an OS in D.

Instead you seem to get stuck on first issue related to the 
language.
First issue? Developers of LDC can respond and fix issue in a 
real time but developers of D frontend not. And that's the thing 
what pissed me off.


But what's the real issue ? You want to release a pre-compiled 
static library with headers ?

Yes.


Then you could license the sources, simply.

No, thanks.

Personally I've been client of a commercial GUI framework, and 
we get the sources with the license. It worked, I mean that the 
developer had clients.





Re: D future ...

2016-12-28 Thread Satoshi via Digitalmars-d

On Wednesday, 28 December 2016 at 09:37:06 UTC, Jerry wrote:
Personally I'm not really looking for an IDE, I've settled for 
a text editor with a plugin for it. IDEs tend to be bulky and 
not be very good at manipulating text or rather lacking 
features to do so.


It depends on specific IDE.

I don't see how the interface generator is stopping you from 
releasing the IDE anyways.


It's GUI framework (set of libraries) what I cannot release. IDE 
is without the libs quite useless.



All it would really stop is
potentially third party plugins. Even then you can just write 
the interface files yourself. Wouldn't be that hard, just 
coping the source file and removing function bodies for the 
most part. What you'd need to do if you were writing C++ code, 
but you would keep the header and source files in sync as you 
were developing.


Wouldn't be that hard but the project have 200k lines of code. 
Making header files manually is a wast of time what i don't have.


But the point is that D compiler specification[1] looks like this 
part works without a problem and is usable but it's a lie and 
nobody cares about it. Actually it will not ruin my project but 
complicates it. And this is not the way in which should business 
be made. 10 years of development and still some key features 
won't work properly.


[1] https://dlang.org/dmd-osx.html#interface-files


Re: D future ...

2016-12-28 Thread Satoshi via Digitalmars-d

On Wednesday, 28 December 2016 at 03:21:03 UTC, Jerry wrote:
On Tuesday, 27 December 2016 at 16:36:10 UTC, Laeeth Isharc 
wrote:

On Monday, 19 December 2016 at 23:02:59 UTC, Benjiro wrote:
So if you want to improve the language and its ecosystem, the 
best way is to contribute pull requests or $$$s - the 
Foundation now accepts individual donations, and it's also 
open to corporate sponsorship, I believe.



Editor support:


Sublime text and sometimes vim work well enough for me, though 
these things are very personal.  For the others, have you 
contributed anything - time or money in making them better?  
If wishes were horses, beggars would ride.  And contribution 
of either has a higher value than just the thing itself, 
because it also tends to energise the project - look at the 
frustration Basil experienced regarding his IDE project.  It's 
good to have high standards, but one should have some 
appreciation also for the gift that people make of their time, 
work, and energy in ways that don't always lead to the 
gratitude that one might expect.


There's only so much time and money someone can give. It isn't 
that appealing when virtually no other language out there 
suffers from this problem cause they have an actual market 
behind them. Those markets fuel money being poured into the 
tools of the lanugage. It doesn't really matter how many users 
you have, it depends on the demographic of those users. If they 
are all students still in school, then you haven't really 
created a market.


Anyways most of the IDEs out there are made by a small team or 
only one person. Not only that but they almost all (if not all) 
rely on the same projects to get the features you would expect 
in an IDE. The DCD, DScanner, DFix, DFmt etc... All those tools 
also seem to be developed primarily by the same single person. 
Rust seems to be in a similar situation but at least it seems 
the rust team has plans for adding IDE support into the 
compiler itself. Something that is probably unrealistic for D.


Seb posted a massive list of modules that can be standard 
candidates. And the response is more or less ignore it. 
People who work on Standard libraries are more motivated. 
Bring  them into the fold. But it seems that they simple get 
ignored.


Rome wasn't built in a year.  Great things are achieved by 
taking baby steps, compounded over time.  And if one does what 
little one can, others are inspired by it.  Enthusiasm and a 
constructive attitude are infectious in my experience.


D isn't a year old though. If the steps you take are too small, 
you can also end up being left behind.



I'm working on a commercial IDE and GUI framework for a year and 
half and I'm not able to release any version due to this bug[1].
But nobody cares about fixing it because it doesn't give any 
benefits in opensource way to D or what.


I don't know how there can be any others closed source/commercial 
libraries for D when the one of the key features won't work.


Actually I wasted one and half year of developing project that I 
cannot release due to the bug. When I started I didn't even know 
that future existence of my project can depend on the compiler 
itself. Please, stop adding new features to D and start fixing 
existing ones.


- Satoshi

---
[1] https://issues.dlang.org/show_bug.cgi?id=16590


rtInfo()

2016-12-14 Thread Satoshi via Digitalmars-d-learn

Hello,
is rtInfo() already used by GC?
I need to store some data for each class so I'm using this 
template and m_rtInfo in TypeInfo_Class but now it seems that GC 
is not working properly in some cases.


Thanks.


Re: @property

2016-12-09 Thread Satoshi via Digitalmars-d-learn
On Thursday, 8 December 2016 at 22:09:14 UTC, Jonathan M Davis 
wrote:
On Thursday, December 08, 2016 16:54:57 Adam D. Ruppe via 
Digitalmars-d- learn wrote:

[...]


Yeah, it's pretty common for folks to slap @property on 
functions to make it clear that it's intended to be used as a 
property and thus is a getter or setter. So, it serves a 
purpose from the standpoint of documentation. But at this 
point, it doesn't make much differently on the technical level. 
The differences with typeof and stuff like 
std.traits.FunctionAttributes are what would be different. You 
can use the property syntax whether @property was used or not.


[...]



Thank you very much for your detailed explanation.


@property

2016-12-08 Thread Satoshi via Digitalmars-d-learn

Hello,
is there any advantage of marking function as @property??


class Foo {
void objectValue(Object value) { }
Object objectValue() { }
}



auto foo = new Foo;

// This works fine without @property attribute
foo.objectValue = null;
auto bar = foo.objectValue;


@trusted AKA most useless statement ever

2016-11-25 Thread Satoshi via Digitalmars-d

Simply, it should be replaced by:

void safeFunc() @safe {
unsafe {
auto vi = doUnsafeCall();
}
}

@trusted functions are prohibited by d-idiom (so I don't know why 
are still in D).
So, when I need to create a simple window with OpenGL context I 
need to write about 10-15 calls to system functions. But 
D-idiom[1] for @trusted tells me to make @trusted functions as 
small as possible. OK, it makes sense.


but writing 20 times something like:
auto vi = (() @trusted => glXChooseXFBConfig(...))();

or:
auto vi = () @trusted { return glXChooseXFBConfig(...); }();

is annoying and just forced me to mark whole class with 
@trusted...




[1] 
https://dlang.org/blog/2016/09/28/how-to-write-trusted-code-in-d/


Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn

or I have simple class

class View {
this(Rectangle frame) {...}
this(float, float, float, float) { ... }
this(Point, Size) { ... }
}

then struct Point, Size and Rectangle (Point, Size)

now I need to write 2 overloads for View class taking 4 floats or 
(Point, Size) and this must do in every descendant of View class.


Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn

On Tuesday, 22 November 2016 at 19:16:56 UTC, Ali Çehreli wrote:

On 11/22/2016 08:05 AM, Satoshi wrote:


I don't have extensive experience with other languages. In 
fact, the only other languages that I can claim proficiency are 
C and C++. (I also know Python just enough to find it 
incredible how it's used in the industry. Let's not get in to 
that discussion but I really tried and failed... in industry... 
:) ) Given that experience, I still find D a very useful tool.




D is one o the best languages what exists, it's reason why I'm 
using it. But some issues are solved better in other languages 
like rust, go or swift.




Agreed but it opens the door for bugs. Assuming

struct A { int a; }
struct B { int b; int c; }

void foo(int, int, int);

If foo(1, 2, 3) meant foo(A(1), B(2, 3)) today, it could 
silently mean foo(A(1, 2), B(3)) if one moved one member from 
one struct to the other.


Then there are other corner cases:

writeln(1, 2, 3);

Should that print the integers or A(1) and B(2, 3)? It's always 
better to be explicit.




argument expand should be applied only to the last argument and 
cannot be used in variadic templates. Like in my simple example 
where I exactly know what function will do, but I want to call it 
by simplest way.


It actually works with classes, but no with structs.



import std.stdio;

struct Point {
int x;
int y;
}

struct GraphicsContext {
static GraphicsContext current() {
return GraphicsContext();
}

void moveTo(Point point) {
writefln("Moving to %s", point);
}

void lineTo(Point point) {
writefln("Drawing line to %s", point);
}
}

void goTo(GraphicsContext gc, int x, int y) {
gc.moveTo(Point(x, y));
}

void drawTo(GraphicsContext gc, int x, int y) {
gc.lineTo(Point(x, y));
}

void main() {
auto gc = GraphicsContext.current;
gc.goTo(70, 70);// <-- Clean syntax
gc.drawTo(70, 170);
}


But I need to write overload function for every function taking 
simple messengers like Point/Size/Rectangle




Re: A simplification of the RvalueRef idiom

2016-11-22 Thread Satoshi via Digitalmars-d-learn

On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote:

First, a reminder that we have this great resource of D idioms:


https://p0nce.github.io/d-idioms/#Rvalue-references:-Understanding-auto-ref-and-then-not-using-it

The link above has an idiom of mixing in a byRef() member 
function to a struct. I think I've simplified the template by 
moving typeof(this) inside it:


mixin template RvalueRef()// <-- DOES NOT TAKE A PARAMETER 
ANY MORE

{
alias T = typeof(this);
static assert (is(T == struct));

@nogc @safe
ref const(T) byRef() const pure nothrow return
{
return this;
}
}

struct Vector2f
{
float x, y;

this(float x, float y) pure nothrow
{
this.x = x;
this.y = y;
}

mixin RvalueRef;// <-- SIMPLER USE
}

void foo(ref const Vector2f pos)
{
writefln("(%.2f|%.2f)", pos.x, pos.y);
}

void main()
{
Vector2f v = Vector2f(42, 23);
foo(v);   // Works
foo(Vector2f(42, 23).byRef);  // Works as well, and use 
the same function

}

Let me know if it's not the equivalent of the original.

Ali



Sorry, but D seems to be worse and worse day by day.
This should be resolved by language and not doing it by template 
function.

Same thing should be applied for maybe monad and tuples.

e.g. When I want to create simple function for drawing

void lineTo(auto ref Point point...) {
//...
}

It's easier to call it like:
Point p = Point(42, 42);

lineTo(p);
lineTo(42, 42);


lineTo(Point(42, 42)); // this
lineTo(Point(42, 42).byRef); // and this is just overhead


Everything possible should be solved by syntactic sugar rather 
than implementing it as template func.


Or just remove shared, TLS and other stuff from D and implement 
it as templates like in C++. Then you can write much more longer 
and uglier stuffs as you trying.


void lineTo(std::shared_ptr point) {
// ...
}

lineTo(std::make(42, 42));

should be ideal way how to complicate programming for other users.



Sorry, but I want to write fast and safe programs in the fastest 
possible way and writing Point(...) or Point(...).byRef every 
time is redundant overhead.


Like http://pix.toile-libre.org/upload/original/1479816672.png


PS: sorry for sarcasm
- Satoshi



Re: null this

2016-11-21 Thread Satoshi via Digitalmars-d-learn

On Monday, 21 November 2016 at 10:25:17 UTC, Satoshi wrote:

Hello,
how can calling method on local struct throw "null this"?
struct is initialized by .init and have default values.


struct Foo {
Bar bar;

static struct Bar {
float x, y, z;
}

Bar getBar() {
return bar;
}

}


then
Foo foo = Foo.init;
auto b = foo.getBar(); // throw "null this"




I had
auto ref getBar() inout {
return bar;
}

in which was problem. When I separated it into 2 funcs get/set it 
works fine.


Re: null this

2016-11-21 Thread Satoshi via Digitalmars-d-learn

cast(ulong) but is not null.

It won't work just in special cases what I cannot reproduce 
easily.





null this

2016-11-21 Thread Satoshi via Digitalmars-d-learn

Hello,
how can calling method on local struct throw "null this"?
struct is initialized by .init and have default values.


struct Foo {
Bar bar;

static struct Bar {
float x, y, z;
}

Bar getBar() {
return bar;
}

}


then
Foo foo = Foo.init;
auto b = foo.getBar(); // throw "null this"


Class copy

2016-11-10 Thread Satoshi via Digitalmars-d-learn

Hello,
how can I copy class when I have pointer to the parent of it?

eg.

class Foo {
int m_a;

this(const(Foo) other) {
m_a = other.m_a;
}
}

class Bar : Foo {
int m_b;

this(const(Bar) other) {
super(other);

m_b = other.m_b;
}

R dup(this R)() {
void* data = cast(void *)typeid(this).create();
data[0 .. __traits(classInstanceSize, R)] = 
typeid(R).init[];


auto ret = cast(R)data;
ret.__ctor(this);

return ret;
}
}



Foo foo = new Bar;

Foo copyOfFoo = foo.dup; // ??


But this implementation of dup doesn't work.
Thanks


Re: Linux Kernel in D?

2016-11-01 Thread Satoshi via Digitalmars-d

On Tuesday, 1 November 2016 at 12:12:29 UTC, Heisenberg wrote:
Just an idea. Do you think it would have any advantage compared 
to the one that is written in C?


Look at https://github.com/Rikarin/Trinix for example


Re: Bug in header file generation

2016-10-25 Thread Satoshi via Digitalmars-d

I posted 3 more bugs what I found.
Seriously, can someone fix these bugs, please?

Thanks!


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


Re: Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn

On Thursday, 20 October 2016 at 16:04:00 UTC, Nordlöw wrote:

On Thursday, 20 October 2016 at 12:48:34 UTC, Satoshi wrote:

Hello,
why ... cannot be used with structs?

struct Foo {
this(int a) { }
}

void bar(Foo foo...) {

}

bar(42);


Being explicit about these things makes complex code more clear.


With class it works fine.
https://dlang.org/spec/function.html#typesafe_variadic_functions

I have struct Point(x, y) and I want to let the people call some 
methods with Point or just pass x and y argument. I can make 
Point as a class but it's not efficient.


I think this
void moveMouseTo(float x, float y);
is same clear as
void moveMouseTo(Point point);


Re: Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn
On Thursday, 20 October 2016 at 12:52:42 UTC, rikki cattermole 
wrote:

On 21/10/2016 1:48 AM, Satoshi wrote:

Hello,
why ... cannot be used with structs?

struct Foo {
this(int a) { }
}

void bar(Foo foo...) {

}

bar(42);


Because an int is not a Foo.



Oh, really? I didn't notice that... (sarcasm)

If I change struct Foo to class Foo it works.


Typesafe variadic argument taking struct

2016-10-20 Thread Satoshi via Digitalmars-d-learn

Hello,
why ... cannot be used with structs?

struct Foo {
this(int a) { }
}

void bar(Foo foo...) {

}

bar(42);


Re: Bug in header file generation

2016-10-17 Thread Satoshi via Digitalmars-d

On Monday, 17 October 2016 at 07:54:33 UTC, Mike Parker wrote:

On Monday, 17 October 2016 at 07:50:17 UTC, Satoshi wrote:
On Saturday, 15 October 2016 at 06:55:31 UTC, Uplink_Coder 
wrote:

On Saturday, 15 October 2016 at 06:51:44 UTC, Satoshi wrote:

Hello,
can someone look at this quite simple bug in dmd please?
https://issues.dlang.org/show_bug.cgi?id=16590

I cannot release non-opensource libraries without this.



It is exported correctly, but when I create it like:
class TestClass {
int aa;

ref foo() { // without auto
return aa;
}
}

it is exported like:
class TestClass {
int aa;

ref foo(); // Cannot deduce return type
}


Is there something preventing you from declaring the return 
type?


ref int foo() { ... }



no, but I just try to export headers on druntime and phobos and 
found this bug.


Re: Bug in header file generation

2016-10-17 Thread Satoshi via Digitalmars-d

On Saturday, 15 October 2016 at 06:55:31 UTC, Uplink_Coder wrote:

On Saturday, 15 October 2016 at 06:51:44 UTC, Satoshi wrote:

Hello,
can someone look at this quite simple bug in dmd please?
https://issues.dlang.org/show_bug.cgi?id=16590

I cannot release non-opensource libraries without this.


You mean auto ref right ?
please attach a small test-case.

You can force the function body to be there by making it a 
template

just give it another pair of parens.



When I create function like:

class TestClass {
int aa;

auto ref foo() {
return aa;
}
}

It is exported correctly, but when I create it like:
class TestClass {
int aa;

ref foo() { // without auto
return aa;
}
}

it is exported like:
class TestClass {
int aa;

ref foo(); // Cannot deduce return type
}



Bug in header file generation

2016-10-16 Thread Satoshi via Digitalmars-d

Hello,
can someone look at this quite simple bug in dmd please?
https://issues.dlang.org/show_bug.cgi?id=16590

I cannot release non-opensource libraries without this.


Re: ptrdiff_t of class.tupleof entry

2016-10-11 Thread Satoshi via Digitalmars-d-learn
On Monday, 10 October 2016 at 18:21:10 UTC, Jonathan M Davis 
wrote:
On Monday, October 10, 2016 17:57:15 Satoshi via 
Digitalmars-d-learn wrote:

[...]


You can use the offsetof property of a member variable to find 
out the offset between its address and the address of the 
beginning of the class or struct that it's a member of.


- Jonathan M Davis




Thanks a lot!


ptrdiff_t of class.tupleof entry

2016-10-10 Thread Satoshi via Digitalmars-d-learn

Hello,
How can I take an ptrdiff_t of any tupleoff entry from class 
during compilation?



I need something like this:

template Test(T, int i) {
 enum Test = [i] - [0];
}


and then use it like:

class AnyClass {
int a;
int b;
int c;
string d;

}

enum Addr = Test!(AnyClass, 3);

void assignInt!(T)(AnyClass cls, T value) {
*(cast(T *)cast(void *)cls + Addr) = value;
}



This is just an example how I need to use it.
Is something like this possible to do?


Re: Problems with "shared"

2016-10-10 Thread Satoshi via Digitalmars-d-learn

On Sunday, 9 October 2016 at 21:32:23 UTC, ag0aep6g wrote:

On 10/09/2016 10:57 PM, jython234 wrote:

1. Where do I use the "shared" keyword?


What doesn't work is creating an unshared object of a class 
that only has a shared constructor. To create both shared and 
unshared objects, you need either two constructors or a `pure` 
one.


class C
{
this() pure {}
}
void main()
{
auto u = new C; /* works */
auto s = new shared C; /* too */
}




Why this ins't in doc? :O I didn't know about using pure in this 
way.


Re: Class attributes

2016-10-03 Thread Satoshi via Digitalmars-d-learn

On Sunday, 2 October 2016 at 17:22:57 UTC, Basile B. wrote:

On Sunday, 2 October 2016 at 15:54:38 UTC, Satoshi wrote:

Hello,

why
pure @safe nothrow @nogc struct Point {
}

isn't same as

struct Point {
pure: @safe: nothrow: @nogc:
}

??


This is not specified but attributes aren't applied to the 
scope created by the declaration. Which is a good thing, for 
example with the visibility attributes it would be a problem, 
imagine the following declarations:


struct Foo(T)
{
private struct Range // imagine that private as a inner 
"private:"

{
void popFront(); // would be private !!
bool empty(); // would be private !!
T front(); // would be private !!
}
}

So this is really not something anyone would want.


But shared or abstract attribute can be applied to scope created 
by class so nothrow @safe @nogc or pure should be too.



It should follow same rules as in function declaration.

void test() @safe {
  void thisFunctionIsSafeToo() {

  }
}


Class attributes

2016-10-02 Thread Satoshi via Digitalmars-d-learn

Hello,

why
pure @safe nothrow @nogc struct Point {
}

isn't same as

struct Point {
pure: @safe: nothrow: @nogc:
}

??


Re: Easy sockets - don't exist yet?

2016-09-27 Thread Satoshi via Digitalmars-d-learn

On Monday, 26 September 2016 at 23:40:10 UTC, Vincent wrote:

Hello, guys!

I was very surprised that module 'socketstream' was deprecated. 
Usually if something become obsolete, there is some perfect 
replacement! But my digging in Inet and forums gave nothing, 
but "outdated" examples with 'SocketStream' class. So first 
question is WHAT Phobos has to replace SocketStream?
To avoid unnecessary mail bouncing, I write upfront what I 
expect from normal Socket implementation (kind of interface) :


1. Easy to use. No more stupid "UNIX sockets", "TCP types" and 
so on. Just simple as this:


// Client side
auto sock = new ClientSocket("google.com", 80);
sock.WriteLine("GET / HTTP/1.0");
sock.WriteLine("Host: google.com");
sock.WriteLine();// empty line sent

// Server side:
auto svc = new ServerSocket("Bound.To.This.IP", 1000);
while ((auto ClientSock = svc.AcceptClient()) !is null) {
auto command = ClientSock.ReadLine();// this is important - 
read by line, not idiotic "buffers of bytes"!

ClientSock.WriteLine(command ~ ` yourself!`);
ClientSock.Close();
}

2. Of course integration with std.stream could be nice, it 
gives "for free" readLine and other methods.
3. Ability to 'get and forget': hardly all of us wanna deal 
with "get portion, write portion to disk, blah". Simple 
"sock.ReceiveFile(`http://porno/girl.avi`, 
`c:\diploma_work.avi`)" could be enough.

   Some kind of "progress report" callback would be nice.
4. SSL/TLS out-of-the-box. In example above it should be same 
easy as:


auto sock = new ClientSocket("google.com", 80, Proto.TLS);


At the moment it's all I need, but hope you'll be happy too 
with such interface. Sockets are SOOO important, that I cannot 
believe we don't have so easy API now. Or if we have, please 
share!


Thanks everybody!



-idiotic "buffers of bytes"!
It's not buffer of bytes who is idiotic... communication over 
sockets are binary, not in text form. Sending structs in binary 
form is much better idea than send it in text form.


e.g.
struct Message {
int magic;
int command;
int dataLength; // length of data pushed after this struct
}

then you can receive sizeof(Message), check magic, receive 
dataLength of bytes and call delegate by the command int in 
Message...



UNIX sockets are not stupid, only you cannot use it.


Re: [your code here]

2016-09-16 Thread Satoshi via Digitalmars-d

On Friday, 16 September 2016 at 08:40:08 UTC, alam wrote:

give me code




if (2b || !2b) { //to be or not to be? It's funny becasue its true


}


Re: Properties don't work as expected

2016-07-05 Thread Satoshi via Digitalmars-d-learn

On Tuesday, 5 July 2016 at 10:52:10 UTC, zodd wrote:
Property functions are used wrong by a compiler when it needs 
to get and set a value at the same time:


[...]




Try
 @property ref int value() {
return value_;
}


Re: D is crap

2016-07-03 Thread Satoshi via Digitalmars-d

On Sunday, 3 July 2016 at 04:37:02 UTC, D is crap wrote:
Basically there is no great IDE for D, in fact, there is none. 
They are all general purpose IDE's that have been configured to 
compile D code. Great! Except they don't work well because they 
wern't designed for D. (e.g., template debugging? mixins? Error 
messages? Code maps? refactoring? All the stuff that more 
modern languages and IDE's are using is lacking for D.


11. D has no proper Gui. WTF?  This isn't the 70's no matter 
how much you to relive peace and sex. Oh, did I hear someone 
say bindings? WTF?


I am working on a GUI framework and IDE for Dlang for a year.


BTW. There is still DlangUI


Re: executeShell doesn't work but system does

2016-06-27 Thread Satoshi via Digitalmars-d-learn

On Sunday, 26 June 2016 at 19:01:07 UTC, cym13 wrote:

On Sunday, 26 June 2016 at 17:56:08 UTC, Satoshi wrote:

On Sunday, 26 June 2016 at 15:37:03 UTC, "Smoke" Adams wrote:
system("cls") works but executeShell doesn't. system is 
depreciated.


What's going on? The docs say that it creates a new process. 
I simply want to clear the console!



I have problem with executeShell on windows 10 (LDC 1.0.0) too.
When I rewrote it into http://prntscr.com/blc9j8 it works.


OT but please, refrain from using screenshots. I know it's very 
customary on windows but I can't copy paste code from a 
screenshot to play with it and manually copying is error-prone. 
We manipulate text, let's stay with it.


Sorry... It's same function as executeImpl just with changed 
byChunk to 1. It corrupt stack when I called the original 
function.


https://github.com/ldc-developers/phobos/blob/aa133b5927bbc5f9669374d5bb0f206f6f68cfe4/std/process.d#L2130


Re: executeShell doesn't work but system does

2016-06-26 Thread Satoshi via Digitalmars-d-learn

On Sunday, 26 June 2016 at 15:37:03 UTC, "Smoke" Adams wrote:
system("cls") works but executeShell doesn't. system is 
depreciated.


What's going on? The docs say that it creates a new process. I 
simply want to clear the console!



I have problem with executeShell on windows 10 (LDC 1.0.0) too.
When I rewrote it into http://prntscr.com/blc9j8 it works.


Re: Project Highlight: The PowerNex Kernel

2016-06-26 Thread Satoshi via Digitalmars-d-announce

On Saturday, 25 June 2016 at 18:42:20 UTC, Wild wrote:

On Friday, 24 June 2016 at 15:09:41 UTC, Satoshi wrote:

On Friday, 24 June 2016 at 14:09:12 UTC, Mike Parker wrote:
Not that long ago, Dan Printzell announced his D OS Kernel, 
PowerNex [1], in this forum. It is now the subject of the 
first project highlight on the D Blog [2].


[1] https://github.com/Vild/PowerNex
[2] 
http://dlang.org/blog/2016/06/24/project-highlight-the-powernex-kernel/



Its funny how he took existing sources from my OS 
https://github.com/Rikarin/Trinix
rewrite it during stream session on Livecoding and get more 
popularity than my OS.


Do you want me to remove all the code that is influenced by 
your code in the kernel and rewrite from scratch?


Because I don't want my project to contain 
illegal/controversial code.


no


Re: Project Highlight: The PowerNex Kernel

2016-06-24 Thread Satoshi via Digitalmars-d-announce

On Friday, 24 June 2016 at 14:09:12 UTC, Mike Parker wrote:
Not that long ago, Dan Printzell announced his D OS Kernel, 
PowerNex [1], in this forum. It is now the subject of the first 
project highlight on the D Blog [2].


[1] https://github.com/Vild/PowerNex
[2] 
http://dlang.org/blog/2016/06/24/project-highlight-the-powernex-kernel/



Its funny how he took existing sources from my OS 
https://github.com/Rikarin/Trinix
rewrite it during stream session on Livecoding and get more 
popularity than my OS.


Re: problem using ldc 1.0.0 as D compiler

2016-06-21 Thread Satoshi via Digitalmars-d

On Tuesday, 21 June 2016 at 17:30:38 UTC, yawniek wrote:

On Tuesday, 21 June 2016 at 16:26:14 UTC, Satoshi wrote:

On Monday, 20 June 2016 at 11:28:58 UTC, Antonio Corbi wrote:

Hi folks!

I'm using ldc version:
LDC - the LLVM D compiler (1.0.0):
  based on DMD v2.070.2 and LLVM 3.8.0
  built with DMD64 D Compiler v2.071.0
  Default target: x86_64-unknown-linux-gnu
  Host CPU: core2

[...]


I have the same problem with LDC 1.1.0 on Arch Linux


you could use ldc-git from aur,
https://aur.archlinux.org/packages/ldc-git/
this has static phobos



I'm linking phobos and druntime into another shared lib then I'm 
using it in projects.


Re: problem using ldc 1.0.0 as D compiler

2016-06-21 Thread Satoshi via Digitalmars-d

On Monday, 20 June 2016 at 11:28:58 UTC, Antonio Corbi wrote:

Hi folks!

I'm using ldc version:
LDC - the LLVM D compiler (1.0.0):
  based on DMD v2.070.2 and LLVM 3.8.0
  built with DMD64 D Compiler v2.071.0
  Default target: x86_64-unknown-linux-gnu
  Host CPU: core2

[...]


I have the same problem with LDC 1.1.0 on Arch Linux


  1   2   >