Re: macOS Mojave compatiblity

2019-04-11 Thread Joel via Digitalmars-d-learn

On Thursday, 11 April 2019 at 23:22:19 UTC, Joel wrote:
I've ordered a new computer, and it has Mojave OS. It's 64 bit 
only, so I'm wondering what difference would that make with 
things like with C bindings and stuff.


For example would https://code.dlang.org/packages/dsfml and 
https://code.dlang.org/packages/dlangui librarys work?


Never mind, I got those to work - I read Mojave isn’t even 64 bit 
only.


Re: bug in compiles?

2019-04-11 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/11/19 6:45 PM, Alex wrote:

On Thursday, 11 April 2019 at 19:42:05 UTC, Steven Schveighoffer wrote:

On 4/11/19 2:13 PM, Alex wrote:

The following code works when I comment out the static if

//static if (__traits(compiles, __traits(getAttributes, T)))
    static foreach(a;  __traits(getAttributes, T)) Attributes ~=


There seems to be absolutely no reason why this code would fail with 
the static if but pass without it but in the first case I get no 
attributes because the __traits compiles fails.




__traits(compiles, __traits(getAttributes, T))

vs

__traits(getAttributes, T)

How could it not compile in the first case and yet work in the foreach?


It should. Do you have a larger example? One that can be played with?

-Steve


import std.stdio, std.traits, std.conv;


struct A(alias T)
{
     static void foo()
     {
     static if (__traits(compiles, __traits(getAttributes, T))) // 
Failing for some reason
     static foreach(a;  __traits(getAttributes, T)) pragma(msg, 
to!string(a), "-", typeof(a).stringof);

     }
}

void main()
{
     @(3) int a;

     (A!a).foo();
}

Commenting out the static if allows the foreach to pass and everything 
works. The whole point of the static if is to let the foreach work.


Both are only dependent on

__traits(getAttributes, T)

So if that can't compile then how could the foreach work?

https://run.dlang.io/is/WlXCIZ




Seems like a bug to me.

These all work:

@(3) int a;

static assert(__traits(compiles, __traits(getAttributes, a)));
alias X = a;
static assert(__traits(compiles, __traits(getAttributes, X)));

But this does not:

static function foo(alias T)()
{
   static assert(__traits(compiles, __traits(getAttributes, T)));
}

foo!a;

I think all 3 should work.

-Steve


Re: bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn

On Friday, 12 April 2019 at 00:02:36 UTC, Seb wrote:

On Thursday, 11 April 2019 at 23:55:18 UTC, Alex wrote:

to judge people objectively. This isn't a nursery school and 
we are not 3 year olds...


Exactly. So start behaving like a grown-up and professional.

When you ask someone for help on the street, do you curse at 
him too?


Um, where the hell did I "curse" at him? See, you are making up 
shit. Prove it! The posts are recorded!


See, you do want this to a nursery school... You want your little 
rules and regulations and no cursing or you'll get soap in your 
mouth.



You want to act like a grown up but you don't wanna be a grown 
up. Being a grown up sometimes requires you to not respond to 
people that you don't like. Yet you did! In the real world when 
someone says shit you don't like and you say shit back and then 
claim your in the right when you do the exact same shit doesn't 
cut it.


See, you decided to become part of this problem... because you 
are part of the problem.  You had nothing useful to say, nothing 
factual, nothing to add intelligently but you just decided on 
your own that you wanted to take sides play these little games.



"Must be something else in your code because it works fine for me 
with this shortened example.


https://run.dlang.io/is/o8xESB


Seriously? Do you think you have ESP? Your code isn't even close 
to was talking about ;/


Here is is updated that shows the error. You seem to fail to 
understand that it is impossible for it to be my code. There is 
no way the static if should fail yet the static foreach pass. 
They both go together, that is is the whole point of the static 
if, to make sure the foreach works, yet it says it doesn't work 
when it in fact does(as commenting out the line proves)."


I asked him if he thinks he has ESP, was that cursing him? I told 
him his code isn't close to what I was talking about, is that 
cursing?


I'm asking a damn question and making a statement. I was trying 
to explain to him that there is no way in hell that he could be 
right(well, there is a small chances but why would he assume 
that?) because he of the nature of the problem.


No where did I cuss him, attack him personally... it's something 
you guys decided to interpret as then you get offended and cause 
problems and you don't like me telling you to fuck off for saying 
I'm causing problems when you are causing problems.


See, you guys are the source. You think your job is to police the 
world because you are special. If Bauss got offended or didn't 
like my town then he can chose to not respond to me ever again, 
that solve that problem.


See, if I'm so fucking hostile to everyone and everyone never 
responds to me, guess the fuck what? No one responds, no 
problems. At most I could flood the site with useless posts or 
some shit like that(which I wouldn't do)..


But instead, what happens is people like you that think you are 
do-gooders and you are going to save the world from ilk like me 
only make things worse. That is typical of people like you(which 
I say because you have proven you are that type of person by 
responding rather than just ignoring). At least if you had 
something useful to say then maybe it would matter.


Instead, you say I am slinging poop and that gives you the right 
to sling poop back... but you also claim you are on the moral 
high ground.


Now, that is my assessment of the situation. I claim it is based 
on facts. You can object, but you have the right to just STFU and 
let other people STFU. But I imagine you will want to continue 
being part of the problem.


Seriously, what do you think will come out of your comments? They 
have no substance that can possibly have any good outcome. It's 
just like the shit I have said here, except my goal is to get you 
to realize that you are not contributing to the solution. Same as 
Parker with his need to police the the world. Do you really think 
it will make things better?











Re: bug in compiles?

2019-04-11 Thread Seb via Digitalmars-d-learn

On Thursday, 11 April 2019 at 23:55:18 UTC, Alex wrote:

to judge people objectively. This isn't a nursery school and we 
are not 3 year olds...


Exactly. So start behaving like a grown-up and professional.

When you ask someone for help on the street, do you curse at him 
too?


Re: bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn

On Thursday, 11 April 2019 at 23:04:46 UTC, Mike Parker wrote:

On Thursday, 11 April 2019 at 22:41:32 UTC, Alex wrote:



Seriously? Do you think you have ESP? Your code isn't even 
close to was talking about ;/


Here is is updated that shows the error. You seem to fail to 
understand that it is impossible for it to be my code.


If you continue to attack people who are trying to help you, 
the moderators will stop approving your posts. The hostility is 
unwelcome here. If the number of your posts that have not been 
approved didn’t serve as a warning, then this does.



Quick google search to help you with your problem:

https://www.quora.com/How-do-I-develop-a-thick-skin-and-stop-getting-offended-over-everything

https://www.arkansasonline.com/news/2019/feb/05/too-thin-skin-20190205/

https://medium.com/the-mission/welcome-to-the-thin-skinned-generation-where-everything-is-a-bloody-problem-8bd5cb336361

http://dare.wisc.edu/survey-results/1965-1970/emotional-states-and-attitudes/gg8

http://meanttobehappy.com/10-ways-you-too-can-stop-being-so-easily-offended/


You can't police the world. You seem to live in a PC fantasy 
world where where every little booboo is treated as a life and 
death situation. You are not helping with the world with your 
need to control it. What are you going to do when things get 
really bad in the world? Have a nervous break down? If you think 
the shit I say is hostile and attacking people you really have no 
clue what the real world is like. You seem to have control issues 
that you should get addressed if you are going to threaten people 
over moronic statements that you interpret with your bias to be 
hostile. I'm sorry, but I'm not going to play your games. Did you 
go after FeepingCreature? He was clearly more hostile than I was 
but I bet you didn't say a god damn thing to him... You want me 
to stop being "hostile" then you need to throw your badge in the 
trash and stop trying to police every conversation because you 
really are in no position to judge people objectively. This isn't 
a nursery school and we are not 3 year olds... and if you want to 
turn it in to that kinda atmosphere then you kiss my ass.






macOS Mojave compatiblity

2019-04-11 Thread Joel via Digitalmars-d-learn
I've ordered a new computer, and it has Mojave OS. It's 64 bit 
only, so I'm wondering what difference would that make with 
things like with C bindings and stuff.


For example would https://code.dlang.org/packages/dsfml and 
https://code.dlang.org/packages/dlangui librarys work?


Re: bug in compiles?

2019-04-11 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 11 April 2019 at 22:41:32 UTC, Alex wrote:



Seriously? Do you think you have ESP? Your code isn't even 
close to was talking about ;/


Here is is updated that shows the error. You seem to fail to 
understand that it is impossible for it to be my code.


If you continue to attack people who are trying to help you, the 
moderators will stop approving your posts. The hostility is 
unwelcome here. If the number of your posts that have not been 
approved didn’t serve as a warning, then this does.


Re: bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn
On Thursday, 11 April 2019 at 19:42:05 UTC, Steven Schveighoffer 
wrote:

On 4/11/19 2:13 PM, Alex wrote:

The following code works when I comment out the static if

//static if (__traits(compiles, __traits(getAttributes, T)))
    static foreach(a;  __traits(getAttributes, T)) Attributes 
~=



There seems to be absolutely no reason why this code would 
fail with the static if but pass without it but in the first 
case I get no attributes because the __traits compiles fails.




__traits(compiles, __traits(getAttributes, T))

vs

__traits(getAttributes, T)

How could it not compile in the first case and yet work in the 
foreach?


It should. Do you have a larger example? One that can be played 
with?


-Steve


import std.stdio, std.traits, std.conv;


struct A(alias T)
{
static void foo()
{
		static if (__traits(compiles, __traits(getAttributes, T))) // 
Failing for some reason
		static foreach(a;  __traits(getAttributes, T)) pragma(msg, 
to!string(a), "-", typeof(a).stringof);

}
}

void main()
{
@(3) int a;

(A!a).foo();
}

Commenting out the static if allows the foreach to pass and 
everything works. The whole point of the static if is to let the 
foreach work.


Both are only dependent on

__traits(getAttributes, T)

So if that can't compile then how could the foreach work?

https://run.dlang.io/is/WlXCIZ




Re: bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn

On Thursday, 11 April 2019 at 20:49:45 UTC, bauss wrote:

On Thursday, 11 April 2019 at 18:13:48 UTC, Alex wrote:

The following code works when I comment out the static if

//static if (__traits(compiles, __traits(getAttributes, T)))
   static foreach(a;  __traits(getAttributes, T)) Attributes ~=


There seems to be absolutely no reason why this code would 
fail with the static if but pass without it but in the first 
case I get no attributes because the __traits compiles fails.




__traits(compiles, __traits(getAttributes, T))

vs

__traits(getAttributes, T)

How could it not compile in the first case and yet work in the 
foreach?


T is a local variable name passed to this code, which does 
generally return an

error when used in certain ways:


int x;

Code!x; // Basically the code at the top

if I try to do too much with x I get `cannot use local `x` as 
a parameter to a non-global template`. Usually when I try to 
pass T to another template I get this error.



But some things work. But I can't for the life of me 
understand why compiles is failing but the foreach loop is 
working.



The problem is that I am using compiles quite often and either 
I'm misusing it or it's got some bugs in it that worry me 
because maybe they are silently failing?


Note that I get no errors in my code and I do get the 
attributes so it is technically working.


It would be really nice to know why the compiles is failing, 
e.g.,


pragma(compilesmsg, __traits(getAttributes, T)) spits out the 
error.


Must be something else in your code because it works fine for 
me with this shortened example.


https://run.dlang.io/is/o8xESB


Seriously? Do you think you have ESP? Your code isn't even close 
to was talking about ;/


Here is is updated that shows the error. You seem to fail to 
understand that it is impossible for it to be my code. There is 
no way the static if should fail yet the static foreach pass. 
They both go together, that is is the whole point of the static 
if, to make sure the foreach works, yet it says it doesn't work 
when it in fact does(as commenting out the line proves).




import std.stdio, std.traits, std.conv;


struct A(alias T)
{
static void foo()
{
		static if (__traits(compiles, __traits(getAttributes, T))) // 
Failing for some reason
		static foreach(a;  __traits(getAttributes, T)) pragma(msg, 
to!string(a), "-", typeof(a).stringof);

}
}

void main()
{
@(3) int a;

(A!a).foo();


}



Re: bug in compiles?

2019-04-11 Thread bauss via Digitalmars-d-learn

On Thursday, 11 April 2019 at 18:13:48 UTC, Alex wrote:

The following code works when I comment out the static if

//static if (__traits(compiles, __traits(getAttributes, T)))
   static foreach(a;  __traits(getAttributes, T)) Attributes ~=


There seems to be absolutely no reason why this code would fail 
with the static if but pass without it but in the first case I 
get no attributes because the __traits compiles fails.




__traits(compiles, __traits(getAttributes, T))

vs

__traits(getAttributes, T)

How could it not compile in the first case and yet work in the 
foreach?


T is a local variable name passed to this code, which does 
generally return an

error when used in certain ways:


int x;

Code!x; // Basically the code at the top

if I try to do too much with x I get `cannot use local `x` as a 
parameter to a non-global template`. Usually when I try to pass 
T to another template I get this error.



But some things work. But I can't for the life of me understand 
why compiles is failing but the foreach loop is working.



The problem is that I am using compiles quite often and either 
I'm misusing it or it's got some bugs in it that worry me 
because maybe they are silently failing?


Note that I get no errors in my code and I do get the 
attributes so it is technically working.


It would be really nice to know why the compiles is failing, 
e.g.,


pragma(compilesmsg, __traits(getAttributes, T)) spits out the 
error.


Must be something else in your code because it works fine for me 
with this shortened example.


https://run.dlang.io/is/o8xESB


Re: bug in compiles?

2019-04-11 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/11/19 2:13 PM, Alex wrote:

The following code works when I comment out the static if

//static if (__traits(compiles, __traits(getAttributes, T)))
    static foreach(a;  __traits(getAttributes, T)) Attributes ~=


There seems to be absolutely no reason why this code would fail with the 
static if but pass without it but in the first case I get no attributes 
because the __traits compiles fails.




__traits(compiles, __traits(getAttributes, T))

vs

__traits(getAttributes, T)

How could it not compile in the first case and yet work in the foreach?


It should. Do you have a larger example? One that can be played with?

-Steve


bug in compiles?

2019-04-11 Thread Alex via Digitalmars-d-learn

The following code works when I comment out the static if

//static if (__traits(compiles, __traits(getAttributes, T)))
   static foreach(a;  __traits(getAttributes, T)) Attributes ~=


There seems to be absolutely no reason why this code would fail 
with the static if but pass without it but in the first case I 
get no attributes because the __traits compiles fails.




__traits(compiles, __traits(getAttributes, T))

vs

__traits(getAttributes, T)

How could it not compile in the first case and yet work in the 
foreach?


T is a local variable name passed to this code, which does 
generally return an

error when used in certain ways:


int x;

Code!x; // Basically the code at the top

if I try to do too much with x I get `cannot use local `x` as a 
parameter to a non-global template`. Usually when I try to pass T 
to another template I get this error.



But some things work. But I can't for the life of me understand 
why compiles is failing but the foreach loop is working.



The problem is that I am using compiles quite often and either 
I'm misusing it or it's got some bugs in it that worry me because 
maybe they are silently failing?


Note that I get no errors in my code and I do get the attributes 
so it is technically working.


It would be really nice to know why the compiles is failing, e.g.,

pragma(compilesmsg, __traits(getAttributes, T)) spits out the 
error.








Re: const of AliasSeq is silently ignored

2019-04-11 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/8/19 3:56 PM, Yuxuan Shui wrote:


In this example:

     const(AliasSeq!(int, int)) a;
     pragma(msg, typeof(a)); // (int, int)

This kind of make sense, since AliasSeq is not a "single" type. But 
silently dropping const seems bad, the compiler should probably report 
an error/warning in this case?


I agree with you, please file a bug. I would have expected it to be 
const(int), const(int).


I would expect this pattern to always hold, no matter what T is.

T var1;
const(T) var2;

static assert(is(typeof(var2) == const));

-Steve


Re: Cyclic dependency between module A and B

2019-04-11 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/10/19 2:52 PM, kdevel wrote:
Recently (before refactoring) my application complained right after 
invocation:


    object.Error@src/rt/minfo.d(371): Cyclic dependency between module 
Filebrowser and App

    Filebrowser* ->
    App* ->
    Filebrowser*

Is it possible to detect this dependency before the program is started?
Perhaps during linking?


Unfortunately not, because D supports separate compilation, and 
interface files (.di files). So the compiler can't necessarily know at 
compile time that there is a cycle.


The suckiest part is that once it's compiled, and doesn't detect a 
cycle, it's never going to have a cycle -- yet we run the algorithm to 
detect it on every start up (we actually have to in order to properly 
sort the static ctors). I'd love to get rid of that penalty.


-Steve


DUB conditional subPackage possible?

2019-04-11 Thread wjoe via Digitalmars-d-learn
I want to include subPackages depending either on the presence of 
command line options, or the availability of dependencies; think 
Gentoo USE flags.


As far as I can tell it's not possible to specify configurations 
in a modular  way, e.g.


 dub --config=withGUI --config=supportGTK --config=supportOpenGL 
--config=supportPhysFS


And specifying a non-existent dependency halts the build.

"subConfiguration" looks like what I want but I can't really make 
sense of it. There's just a one liner about it in the manual.


Is there a more verbose example ?


Re: how to define infix function

2019-04-11 Thread KnightMare via Digitalmars-d-learn

u can use infix function with 1arg without any parentheses.

UPD
with 2args
arg1 `infix func` arg2

latter I told about UFCS with 1arg
`UFCS func` arg1


Re: how to define infix function

2019-04-11 Thread KnightMare via Digitalmars-d-learn

On Saturday, 2 June 2018 at 22:01:02 UTC, Ali Çehreli wrote:

On 06/02/2018 02:44 PM, greatsam4sure wrote:
> is it possible to define infix function in D
> 3.min(5)// 3: where min is a function, works in D
> 3 min 5 // does not work.
This is called universal function call syntax (UFCS) in D.
Ali


UFCS is not same as infix functions.
infix allow to u write code like:

1)for (i in 0 to 10 step 2) // `in`(can be keyword too), `to` and 
`step` can be some functions that change range or something
2) auto shiftedRes = someVar shr 13; // `shr` is infix function 
too


u can use infix function with 1arg without any parentheses.
why this need? how it can be useful? look at Kotlin lang.
pure functional programming.
it can be useful for code looks like LINQ(.NET): DB, UI...

and I think UFCS should be improved too: function with 1arg can 
be written without parenthesis too. for example

some declarations:
class Task { .. };
Task asyncRead( File file ) { .. }
T await!(T)( Task task ) { .. }
we can use await like:
auto buf = asyncRead( file ).await();
or
auto buf = await( asyncRead( file )); // I like spaces between 
fn-names and args

but more clear IMO:
auto buf = await asyncRead( file ); // less parenthesis

more improvements:
1) see Kotlin passing lambda as last parameter
https://kotlinlang.org/docs/reference/lambdas.html#passing-a-lambda-to-the-last-parameter

2) Kotlin/when with pattern matching. dont need change current 
`switch` instruction. and we can make `when` as expression (look 
Kotlin samples)


3) scope functions 
https://kotlinlang.org/docs/reference/scope-functions.html

with(button) { text = "hello"; background = Colors.Yellow; }
text & background are props of some Button class for instance 
button. {} is a lambda as last arg


Re: D threading and shared variables

2019-04-11 Thread Kagamin via Digitalmars-d-learn
Well, if the code is too complex to debug, the usual solution is 
to try simpler code and see if it works.


Re: Efficient enum array keys?

2019-04-11 Thread Basile B. via Digitalmars-d-learn

On Thursday, 11 April 2019 at 07:56:42 UTC, Julian wrote:

On Thursday, 11 April 2019 at 06:45:23 UTC, Basile B. wrote:

On Thursday, 11 April 2019 at 06:20:05 UTC, Julian wrote:

I don't see a difference in micro-benchmarks. *shrug*


Your enum is int so in machine code it's exactly like processing 
a machine word.

It's not even worth benchmarking this ;)

As a side note, and in case you would not know it yet, there's 
this traits that's useful with enums: 
https://dlang.org/phobos/std_traits.html#EnumMembers


Re: Efficient enum array keys?

2019-04-11 Thread Julian via Digitalmars-d-learn

On Thursday, 11 April 2019 at 06:45:23 UTC, Basile B. wrote:

On Thursday, 11 April 2019 at 06:20:05 UTC, Julian wrote:

Is there a nicer way to have enum array keys in D?


No. I've myself written my own EnumIndexedArray [1] type. It's 
pretty simple. Just a couple of operator overload to preovide 
the syntax.


I went from ObjFPC/Delphi which has what you describe from Ada 
too and missed it.
(typically: `enum TStuff = (); var stuffStrings: array[TStuff] 
of string;` ...)


[1] 
https://github.com/Basile-z/iz/blob/9ce6fc0e2e0c74f97d530ce598a6842b7b048f25/import/iz/enumset.d#L1086


Thanks. That still seems like enough work that I'd rather
do things the D way. At least if I don't also want Enum sets.

That gave me the idea for this though:

  import std.stdio;

  struct EnumRange(E) {
  int begin = E.min;
  int end = E.max + 1;
  bool empty() { return begin == end; }
  void popFront() { ++begin; }
  E front() { return cast(E) begin; }
  }

  enum Days { Sunday, Monday, Tuesday, Wednesday, Thursday, 
Friday, Saturday }


  void main() {
  int[Days.max+1] worklog;
  ++worklog[Days.Saturday];
  writeln("- worklog");
  EnumRange!(Days) why;
  foreach (day; why)
  writefln("%5d %s", worklog[day], day);
  }

Which I'm still disappointed is not:

   foreach (day; EnumRange!(Days))

Also, this isn't too bad:

  void main() {
  int[Days.max+1] worklog;
  ++worklog[Days.Saturday];
  writeln("- worklog");
  foreach (day, count; worklog)
  writefln("%5d %s", count, cast(Days) day);
  }

I don't see a difference in micro-benchmarks. *shrug*


Re: DCD 0 symbols cached?

2019-04-11 Thread Laurent Tréguier via Digitalmars-d-learn

On Wednesday, 10 April 2019 at 18:39:23 UTC, Tom wrote:


Total newbie to D, trying to get it to play nice with Neovim 
using ncm2-d and DCD.


Issue: DCD never caches any symbols even when I point it 
directly to DMD's include files. Hate to ask for tech support 
on this forum but it's all I've got, Googling has brought no 
luck.


Using dcd version v0.11.0




Output from dcd-server -I /usr/include/dmd/phobos -I 
/usr/include/dmd/druntime/import :


2019-04-10T11:34:43.386 [info] main.d:130:runServer Starting 
up...
2019-04-10T11:34:43.386 [info] main.d:157:runServer Cleaning up 
old socket file at /run/user/1000/dcd.socket
2019-04-10T11:34:43.387 [info] main.d:164:runServer Listening 
at /run/user/1000/dcd.socket
2019-04-10T11:34:43.387 [info] main.d:181:runServer Import 
directories:

/usr/include/dmd/phobos
/usr/include/dmd/druntime/import
2019-04-10T11:34:43.387 [info] main.d:187:runServer 0 symbols 
cached.
2019-04-10T11:34:43.387 [info] main.d:188:runServer Startup 
completed in 0 milliseconds.


Any tips or guidance would be greatly appreciated. Thank you.


IIRC, with the latest versions, DCD will import symbols lazily; 
so it should only start caching symbols when they have been used 
because of a client request.
Have you tried using dcd-client nonetheless to see if you can get 
any result?