Re: Fibers, what for?

2016-06-11 Thread Ali Çehreli via Digitalmars-d-learn

On 06/11/2016 07:58 PM, Era Scarecrow wrote:

>  recent DConf 2016 which sorta covers this

For convenience, here's the link:

  http://www.ustream.tv/recorded/86352137/highlight/699197

However although I'm very biased :), I still like the following fiber 
explanation that emphasizes function call stack:


  http://ddili.org/ders/d.en/fibers.html

Ali



Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 12 June 2016 at 04:19:33 UTC, Joerg Joergonson wrote:



1. I had an older distro(I think) of ldc. The ldc2.exe is 18MB 
while the "new" one is 36MB. I copied the old ldc bin dir to 
the new one and didn't change anything and everything compiled 
EXCEPT


That's just asking for problems. You may get lucky and find that 
it works, but in general you don't want to go around swapping 
compiler executables like that.





2. I got an error that I don't get with dmd:

Error: incompatible types for ((ScreenPainter) !is (null)): 
cannot use '!is' with types		


and I have defined ScreenPainter in my code. It is also in 
arsd's simpledisplay. I do not import simpledisplay directly:


The code is

import arsd.gamehelpers;
	auto window = create2dWindow(cast(int)width, cast(int)height, 
cast(int)ViewportWidth, cast(int)ViewportHeight, title);


// Let the gui handle painting the screen
window.redrawOpenGlScene = {
if (ScreenPainter !is null || !ScreenPainter()) <--- error
...
};

I have defined ScreenPainter elsewhere in the module.


So ScreenPainter is a *type* and not an instance of a type? That 
*should* be an error, no matter which compiler you use. You can't 
compare a type against null. What does that even mean? And if 
SimpleDisplay already defines the type, why have you redefined it?


Assuming ScreenPainter is a class, then:

if(ScreenPainter !is null) <-- Invalid

auto sp = new ScreenPainter;
if(sp !is null) <-- valid




I can fix this by avoiding the import... but the point is that 
it's different than dmd.


If ScreenPainter is defined as a type, it shouldn't ever compile. 
How have you defined it?




So ldc parses things differently than dmd... I imagine this is 
a bug!


LDC and DMD share the same front end, meaning they parse code the 
same. I really would like to see your code, particularly your 
definition of ScreenPainter.



Although, If I set the subsystem to windows I then get the error

 error LNK2019: unresolved external symbol WinMain referenced 
in function "int __cdecl __scrt_common_main_seh(void)" 
(?__scrt_common_main_seh@@YAHXZ)>

Which looks like it's not linking to runtime and/or phobos?


No, this has nothing to do with DRuntime, Phobos, or even D. It's 
a Windows thing. By default, when you compile a D program, you 
are creating a console system executable so your primary entry 
point is an extern(C) main function that is generated by the 
compiler. This initializes DRuntime, which in turn calls your D 
main function.


When using OPTLINK with DMD, the linker will ensure that the 
generated extern(C) main remains the entry point when you set the 
subsystem to Windows. When using the MS linker, this is not the 
case. The linker will expect WinMain to be the entry point when 
the subsystem is set to Windows. If you do not have a WinMain, 
you will see the error above. In order to keep the extern(C) main 
as your entry point, you have to pass the /ENTRY option to the 
linker (see[1]). LDC should provide a means for passing linker 
options. You can probably set in VisualD's project settings, but 
if there's no field for it then ldc2 --help may tell you what you 
need.


Alternatively, you can create a WinMain, but then you need to 
initialize DRuntime yourself. See [2], but ignore the .def file 
requirement since you are already setting the subsystem.





I seriously don't know how anyone gets anything done with all 
these problems ;/ The D community can't expect to get people 
interested in things don't work. If it wasn't because the D 
language was so awesome I wouldn't stick around! It's as if no 
one does any real testing on this stuff before it's released ;/


Then I would ask you to stop and think. There are a number of 
people using D without problems every day, including several 
companies. Obviously, they aren't having the same difficulties 
you are, else they wouldn't be successfully using D. You seem to 
be very quick to blame the tools rather than considering you 
might not fully understand how to use them. I don't mean that in 
a disparaging way. I've been there myself, trying to get 
something I wanted to use working and failing, then getting 
frustrated and blaming the tools. These days, I always blame 
yourself first. Sure, the tools sometimes have bugs and other 
issues, but more often than not it's because I'm using them the 
wrong way.


Right now, documentation on getting up to speed with LDC is 
sorely lacking. That's a valid criticism to make. For people who 
aren't familiar with it, or who aren't well versed in working 
with ahead of time compilers, whichever the case may be, it may 
not be the best choice for getting started with D. Since you seem 
to be having difficulties using LDC and since you've already told 
me that DMD is working for you, I strongly recommend that you use 
DMD instead for now. Once you are comfortable with D and the 
ecosystem, then look into using LDC.


Re: No triangle with OpenGL (DerelictGLFW and DerelictGL3)

2016-06-11 Thread Peter Lewis via Digitalmars-d-learn

On Sunday, 12 June 2016 at 03:46:31 UTC, Mike Parker wrote:

On Sunday, 12 June 2016 at 02:16:52 UTC, Peter Lewis wrote:

[...]


Your problem is this line:

glBufferData(GL_ARRAY_BUFFER, verts.sizeof, , 
GL_STATIC_DRAW);


[...]


Thank you very much. You are right, that fixed my issue


Books on D

2016-06-11 Thread Russel Winder via Digitalmars-d
Is anyone doing a "D in Action" with Manning?

-- 

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

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


Re: Parse File at compile time, but not embedded

2016-06-11 Thread Joerg Joergonson via Digitalmars-d-learn

On Friday, 10 June 2016 at 07:03:21 UTC, ketmar wrote:
On Thursday, 9 June 2016 at 22:02:44 UTC, Joerg Joergonson 
wrote:
Lol, who says you have access to my software? You know, the 
problem with assumptions is that they generally make no sense 
when you actually think about them.


oh, yeah. it suddenly reminds me about some obscure thing. 
other people told me that they were able to solve the same 
problems with something they called "build system"...


Mines not a build system...

In any case LDC does drop the data so it is ok.

The problem with people is that they are idiots! They make 
assumptions about other peoples stuff without having any clue 
what actually is going on rather than addressing the real issue. 
In fact, the thing I'm doing has nothing to do with SQL, 
security, etc. It was only an example. I just don't want crap in 
my EXE that shouldn't be there, simple as that. Also, since I'm 
the sole designer and the software is simple, I have every right 
to do it how I want.


What's strange, though, is my little ole app takes 300MB's and 
constantly uses 13% of the cpu... even though all it does is 
display a few images. This is with LDC release. Doesn't seem very 
efficient. I imagine a similar app in C would take about 1% and 
20MB. Hopefully profiling in D isn't as much a nightmare as 
setting it up.


BTW, I'm using simpledisplay... I saw that you made a commit or 
something on github. Are you noticing any similarities to cpu and 
memory usage?









Re: What's up with GDC?

2016-06-11 Thread Joerg Joergonson via Digitalmars-d-learn

On Sunday, 12 June 2016 at 03:22:06 UTC, Mike Parker wrote:

On Sunday, 12 June 2016 at 02:09:24 UTC, Joerg Joergonson wrote:
Ok, So I started an empty project and I found all the libs 
that are required from all of VS, SDK, LDC, DMD, etc and put 
them in 4 folders:


Libs\COFF\x86
Libs\COFF\x64
Libs\OMF\x86
Libs\OMF\x64


There's no need for OMF\x64. OPTLINK is 32-bit only. That's why 
DMD uses the MS tools for 64-bit. And you never need OMF for 
LDC.


Yeah, I know. That's why it's empty. I made it anyways though to 
be consistent and not knowing if there was possibly any use. I 
wanted to make sure to cover all cases.




fixed up sc.ini and VD to use them and worked on stuff until I 
had no lib errors with the test project. I could compile with 
all versions now(DMD x86/64, LDC x86/64)


You said in your previous post that DMD was working fine for 
you. I would recommend against editing sc.ini except in the 
case where you do manual installs of DMD and need to configure 
it to work with Visual Studio. It's a pain to have to do it 
every time you update. Much better to use the installer and let 
it configure the VS paths for you.


Well, it's never really worked before. I've always had to 
manually edit it and add the VS sdk paths to get DMD working. The 
problem is, when you have many SDK's and kits, nothing plays nice 
together.


What I have now is at least something that is consistent and I 
can simply archive it all and it should work in all future cases. 
Uninstalling a kit and reinstalling one isn't going to fubar dmd.


I'll keep it this way because it works and the only issue is 
keeping it up to date. At least I don't have to go looking in 
some crazy long path for VS libs like C:\program files 
(x86)\Visual Studio\VC\Lib\um\arm\x86\amd\aldlf\crapola\doesn't 
contain everything\1.0534.4303020453414159265.




So, ldc is essentially working... gdc probably is the same if 
I can figure out how to get the proper binaries(not that 
arm-unknown-linux crap) that are not so far out of date. At 
this point I still need to get ldc to work though.


I would recommend against GDC for now. Until someone steps up 
and starts packaging regular MinGW-based releases, it's 
probably not worth it.




Ok. I'll stick with LDC if it works since at least there is a 
something that can be used for properly releasing software.


I probably just need to figure out how to properly include the 
library files mentioned in my other post.


I did try to include the path to the files in VD's LDC 
settings section but it did nothing.


Did you also include the libraries in the project settings? You 
can:


A) Add the path to 'Library Search Path' and add the library 
names to 'Library Files' or,
B) Add the full path and filename for each library to 'Library 
Files'.


I strongly recommend against doing this for system libraries 
like OpenGL. If LDC is configured to know where your VS 
installation is (the only version of LDC I've ever used was an 
old MinGW-based one, so I don't know how the VS version finds 
the MS libraries), then you should only need to include the 
file name and it will use the one from the MS SDK.


Well, I don't know. I monitored LDC2 and it is actually searching 
for the modules with out the slash:


B:\Software\App\Test\libmBase.d

When it should be

B:\Software\App\Test\lib\mBase.d

I created a test project that mimics the main project and it 
works and does not have that issue... So possibly my project is 
"corrupt". I will try and mess with it later or move the project 
over into a new one incrementally until the issue happens.


---

Ok, tried a simple copy and paste type of thing and same issue. 
This seems to be a bug in ldc or visual d.


--

Ok, this is a bug in ldc.

1. I had an older distro(I think) of ldc. The ldc2.exe is 18MB 
while the "new" one is 36MB. I copied the old ldc bin dir to the 
new one and didn't change anything and everything compiled EXCEPT


2. I got an error that I don't get with dmd:

Error: incompatible types for ((ScreenPainter) !is (null)): 
cannot use '!is' with types		


and I have defined ScreenPainter in my code. It is also in arsd's 
simpledisplay. I do not import simpledisplay directly:


The code is

import arsd.gamehelpers;
	auto window = create2dWindow(cast(int)width, cast(int)height, 
cast(int)ViewportWidth, cast(int)ViewportHeight, title);


// Let the gui handle painting the screen
window.redrawOpenGlScene = {
if (ScreenPainter !is null || !ScreenPainter()) <--- error
...
};

I have defined ScreenPainter elsewhere in the module.


I can fix this by avoiding the import... but the point is that 
it's different than dmd.


So ldc parses things differently than dmd... I imagine this is a 
bug!


Fixing it though does produce an executable!

Although, If I set the subsystem to windows I then get the error

 error LNK2019: unresolved external symbol WinMain referenced in 
function 

Re: I'd love to see DScript one day ...

2016-06-11 Thread Laeeth Isharc via Digitalmars-d

On Sunday, 12 June 2016 at 00:37:50 UTC, Jonathan Marler wrote:

On Saturday, 11 June 2016 at 10:34:41 UTC, Chris wrote:

On Saturday, 11 June 2016 at 10:14:25 UTC, qznc wrote:


[...]


No, JS is here to stay, unfortunately.


Good news, take a look at asmjs.org

In the future you'll be able to compile your D code into 
javascript assembly, and run it in the browser.  I predict LLVM 
will have a javascript assembly backend, so LDC would get this 
for free.  Pretty cool stuff going on in the web world right 
now.


Emscripten has been able to compile C++ to asm.js for a while - 
uses modified llvm back end and ported C runtime.  I guess web 
assembly will take off, but somebody would still need to port the 
runtime for D and integrate with new llvm wasm back end when it 
is stable.  See binaryem in meantime.  I am not sure anyone is 
working on this for D currently, but we might put this up 
somewhere as a project in case volunteer comes along.


Then when that's done still need to write a library to do web 
things like provide access to DOM from D.


Emscripten already looks quite nice, and I was so wanting to be 
able to use it for serious work - it just doesn't seem to be 
there just yet.


But I agree with your basic point, and it would be great not to 
have to write js.




Re: No triangle with OpenGL (DerelictGLFW and DerelictGL3)

2016-06-11 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 12 June 2016 at 02:16:52 UTC, Peter Lewis wrote:

Hi all.
I am trying to create a basic OpenGL triangle in a GLFW 
instance. The window works, I can change the background colour 
and everything but for the life of me I can't get the triangle 
to show up. Instead of trying to put everything in the post, I 
have put it on github. (https://github.com/werl/d_glfw_tests) I 
am currently following a tutorial I found 
(http://learnopengl.com/#!Getting-started/Hello-Triangle).

Any help is appreciated, Thanks!


Your problem is this line:

glBufferData(GL_ARRAY_BUFFER, verts.sizeof, , 
GL_STATIC_DRAW);


First, the array declarations in the example C code create static 
arrays. Calling sizeof(array) on a static array in C will give 
you the combined size of all the elements. For a dynamic array, 
it will give you the size of a pointer.


The same is true in D, but there's a difference in the 
declaration syntax. float[9] foo; is a static array, but float[] 
bar; is *always* a dynamic array. foo.size of will give you 36. 
bar.size of will give you 8 in 32-bit and 16 in 64-bit, because 
its giving you the size of the length and pointer that make up 
the array itself, not of the contents.


Second,  is giving you a pointer to the array itself (i.e. 
the length and pointer pair) and *not* the contents. D arrays are 
not C arrays!


With the two changes below, your triangle renders fine.

glBufferData(GL_ARRAY_BUFFER, verts.length * float.sizeof, 
verts.ptr, GL_STATIC_DRAW);


Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 12 June 2016 at 02:09:24 UTC, Joerg Joergonson wrote:
Ok, So I started an empty project and I found all the libs that 
are required from all of VS, SDK, LDC, DMD, etc and put them in 
4 folders:


Libs\COFF\x86
Libs\COFF\x64
Libs\OMF\x86
Libs\OMF\x64


There's no need for OMF\x64. OPTLINK is 32-bit only. That's why 
DMD uses the MS tools for 64-bit. And you never need OMF for LDC.




fixed up sc.ini and VD to use them and worked on stuff until I 
had no lib errors with the test project. I could compile with 
all versions now(DMD x86/64, LDC x86/64)


You said in your previous post that DMD was working fine for you. 
I would recommend against editing sc.ini except in the case where 
you do manual installs of DMD and need to configure it to work 
with Visual Studio. It's a pain to have to do it every time you 
update. Much better to use the installer and let it configure the 
VS paths for you.




So, ldc is essentially working... gdc probably is the same if I 
can figure out how to get the proper binaries(not that 
arm-unknown-linux crap) that are not so far out of date. At 
this point I still need to get ldc to work though.


I would recommend against GDC for now. Until someone steps up and 
starts packaging regular MinGW-based releases, it's probably not 
worth it.


I probably just need to figure out how to properly include the 
library files mentioned in my other post.


I did try to include the path to the files in VD's LDC settings 
section but it did nothing.


Did you also include the libraries in the project settings? You 
can:


A) Add the path to 'Library Search Path' and add the library 
names to 'Library Files' or,
B) Add the full path and filename for each library to 'Library 
Files'.


I strongly recommend against doing this for system libraries like 
OpenGL. If LDC is configured to know where your VS installation 
is (the only version of LDC I've ever used was an old MinGW-based 
one, so I don't know how the VS version finds the MS libraries), 
then you should only need to include the file name and it will 
use the one from the MS SDK.





Re: Perl6 Unicode support

2016-06-11 Thread Andrew Godfrey via Digitalmars-d-announce

On Saturday, 11 June 2016 at 19:43:45 UTC, ag0aep6g wrote:

On 06/11/2016 09:25 PM, Andrew Godfrey wrote:
That's the distinction, yes. The article mentions both in a 
way that
makes me unsure if Perl 6 confused the terms (or maybe it's 
just the

article that isn't being clear).


But how would you "focus" on one or the other?
Is there any operation that works differently on graphemes than 
on grapheme clusters?
Counting/skipping/extracting graphemes is the same as counting 
grapheme clusters, no?


Eg it says ".chars returns the number of characters (aka 
graphemes)"


Does this count the number of graphemes, or the number of 
grapheme clusters? Later on with \r\n it pretty much says that it 
counts grapheme clusters. Here it says it counts graphemes.


Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 12 June 2016 at 03:11:14 UTC, Mike Parker wrote:


I think that's reasonable. All three compilers share the same


Sorry, I mean I *don't* think that's reasonable.


Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 12 June 2016 at 01:51:05 UTC, Joerg Joergonson wrote:


Well, it's definitely not as simple as you make it out to be. I 
have tried all kinds of combinations of libs and settings and 
nothing works. If it's not one error it's another and it 
becomes hard to know exactly what is going on because the 
people who created these applications didn't have the 
forethought to give meaningful error messages.


I believe the main problem now is that ldc is not linking 
phobo's or runtime or whatever because I get all kinds of weird 
export issues.



with x86 ldc I get

Error: module libsmBase is in file 'libsmBase.d' which cannot 
be read.


The module though is actually mBase and it is in libs\mBase. It 
removing the directory.


From the build:

echo libs\mBase.d >"Win32\Debug LDC\Test.build.rsp"

So, not sure if the error is just leaving out the '\' or what. 
Irregardless, please don't act like all this is my problem 
because most of it is due to crappy design and forethought.


This is a compiler error, not a linker error. "module foo is in 
file 'foo.d'" is the error you normally see when you've got a 
problem with your import path, or imported the wrong module name. 
Obviously, there's an issue here with the directory name being 
pushed onto the module name, but I can't even begin to guess why 
that happened. I assume you've imported mBase in another module. 
What was your import statement? Do you have a module declaration 
in mBase.d?


And I know you're frustrated, but please don't blame 'crappy 
design and forethought'. Plenty of people are using these tools 
just fine. That doesn't mean that there won't be bugs in them, or 
that they are implemented to the point that someone unfamiliar 
with them can use them out of the box. VisualD is developed by 
one person in his spare time. The LDC team is also small and work 
in their spare time. I think they've done a great job getting as 
far as they have. Once we figure out what your issue is, then you 
should be golden.




Maybe I am suppose to include the subdirs in my project in 
visual studio/D and the error message simply cannot find the 
modules? But how am I suppose to know that with an illogical 
error message like what is above?


That's not an illogical error message. It's coming from the DMD 
front end, which all of the major D compilers share. Anytime you 
see it, it means you've got an issue with your import path. I've 
never seen the specific error you've got, where the directory 
name is merged with the file name. That *is* weird, but the error 
message itself is normally very useful.




DMD works fine BTW. GDC and LDC should be a drop in 
replacement. Not a totally new setup that has it's own set of 
problems. I'm sure I'm not the only one put off by the 
compounding of problems when using D.


I think that's reasonable. All three compilers share the same 
fronted, but beyond that, they are quite different. IIRC, LDC 
does recognize some DMD switched, and there is a tool called GDMD 
that allows you to invoke GDC as if you were invoking DMD, but 
you can't expect the compilers to be drop-in replacements for 
each other. GDC has to fit in with the GCC ecosystem, which means 
it accepts a number of command line options that DMD does not 
support, and any that are specific to D must be consistent with 
other GCC tools in format. LDC also is a completely different 
tool. There will always be differences that prevent them from 
being interchangeable, which is why we have build tools and IDEs 
to hide the differences from us.


Re: No triangle with OpenGL (DerelictGLFW and DerelictGL3)

2016-06-11 Thread Joerg Joergonson via Digitalmars-d-learn

On Sunday, 12 June 2016 at 02:16:52 UTC, Peter Lewis wrote:

Hi all.
I am trying to create a basic OpenGL triangle in a GLFW 
instance. The window works, I can change the background colour 
and everything but for the life of me I can't get the triangle 
to show up. Instead of trying to put everything in the post, I 
have put it on github. (https://github.com/werl/d_glfw_tests) I 
am currently following a tutorial I found 
(http://learnopengl.com/#!Getting-started/Hello-Triangle).

Any help is appreciated, Thanks!


I had similar issues when I tried it and never got it to work 
either.


Try Adam Druppe's stuff on github. It works and he has some 
support for images and stuff. It's not perfect but at least it 
works out of the box compared to alot of the other stuff floating 
around that mostly is outdated.




Re: Fibers, what for?

2016-06-11 Thread Era Scarecrow via Digitalmars-d-learn

On Sunday, 12 June 2016 at 02:43:40 UTC, Patric Dexheimer wrote:
I learned about Fibers on D, and now I´m starting to read about 
it (Threads/Fibers/Coroutines) etc. But when I try to make 
something usefull with it I just fail to see the real advantage 
over a normal structured programming without it.


Can someone show some code with usefull/unique/advantageous use 
of fibers?

Thanks in advance!


 Fibers since they use the same thread as what calls them, it 
doesn't seem like it would help much. However if there is a delay 
for something for some reason (IO, or putting a delay in the 
current logic for a little while) then (to my understanding) 
Fibers kicks in and lets you keep going.


 A big reason you would want Fibers is not to lose the time slot 
your code has for working, not because it makes the program 
slower, but if the OS switches to another process, when it 
returns you have cold data (not cached).


 So, assuming you have stuff to work on and you want to open a 
file too, you might do it like this.


  work(someargs); //work could be moved after the reading of 
content too...

  string content = readFile("Some file.txt");

 This will process work and then open the file. However while the 
file is opening it may be a while before the file fully opens, or 
can be read the physical IO (spinning disks waiting on the OS, 
other delays) may end up dropping your current time slot.


 A fiber on the other hand you would do it this way: (API is 
probably wrong, so don't rely on this example to actually compile)


  Fiber fiber = new Fiber();
  Fiber.run(work, someargs);
  string content = readFile("Some file.txt");

 Now when the blocking IO happens during opening or reading, the 
Fiber takes over and does some work in the background. If you 
recently worked on any data that remains hot (cached) and you get 
better performance as long as it's hot.


 To note I am still watching the recent DConf 2016 which sorta 
covers this, which is much better than my reply :P


[Issue 16166] New: struct constructor and AliasSeq

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16166

  Issue ID: 16166
   Summary: struct constructor and AliasSeq
   Product: D
   Version: D2
  Hardware: x86
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: kap...@mail.ru

struct Window {
string title;
int x, y;
int w, h;

//this(T...)(T t){
//foreach(i, n; t) this.tupleof[i] = n;
//}
}

alias seq(T...) = T;

void main(){
Window a = seq!("Foo", 100, 100, 640, 480);
// or
import std.typecons;
Window b = tuple("Foo", 100, 100, 640, 480).expand;

writeln(a);
}

--


Re: What's up with GDC?

2016-06-11 Thread Mike Parker via Digitalmars-d-learn

On Saturday, 11 June 2016 at 14:10:07 UTC, Johan Engelen wrote:

On Saturday, 11 June 2016 at 08:48:42 UTC, Mike Parker wrote:
[... a lot ...]

This looks like a nice writeup Mike, could you get this on the 
Wiki or somewhere more permanent where people can find it?


-Johan


I've been meaning to slap together a tutorial on this for my 
long-neglected Learning D blog. once I finally get around to it, 
I'll add a link to the Wiki.


Fibers, what for?

2016-06-11 Thread Patric Dexheimer via Digitalmars-d-learn
I learned about Fibers on D, and now i´m starting to read about 
it (Threads/Fibers/Coroutines) etc.
But when i try to make something usefull with it i just fail to 
see the real advantage over a normal structured programming 
without it.


Can someone show some code with usefull/unique/advantageous use 
of fibers?

Thanks in advance!


No triangle with OpenGL (DerelictGLFW and DerelictGL3)

2016-06-11 Thread Peter Lewis via Digitalmars-d-learn

Hi all.
I am trying to create a basic OpenGL triangle in a GLFW instance. 
The window works, I can change the background colour and 
everything but for the life of me I can't get the triangle to 
show up. Instead of trying to put everything in the post, I have 
put it on github. (https://github.com/werl/d_glfw_tests) I am 
currently following a tutorial I found 
(http://learnopengl.com/#!Getting-started/Hello-Triangle).

Any help is appreciated, Thanks!


Re: What's up with GDC?

2016-06-11 Thread Joerg Joergonson via Digitalmars-d-learn
Ok, So I started an empty project and I found all the libs that 
are required from all of VS, SDK, LDC, DMD, etc and put them in 4 
folders:


Libs\COFF\x86
Libs\COFF\x64
Libs\OMF\x86
Libs\OMF\x64

fixed up sc.ini and VD to use them and worked on stuff until I 
had no lib errors with the test project. I could compile with all 
versions now(DMD x86/64, LDC x86/64)


So, ldc is essentially working... gdc probably is the same if I 
can figure out how to get the proper binaries(not that 
arm-unknown-linux crap) that are not so far out of date. At this 
point I still need to get ldc to work though.


I probably just need to figure out how to properly include the 
library files mentioned in my other post.


I did try to include the path to the files in VD's LDC settings 
section but it did nothing.










Re: What's up with GDC?

2016-06-11 Thread Joerg Joergonson via Digitalmars-d-learn

On Saturday, 11 June 2016 at 08:48:42 UTC, Mike Parker wrote:
On Saturday, 11 June 2016 at 06:22:27 UTC, Joerg Joergonson 
wrote:

[...]


That's not true unless I'm not suppose to import them 
directly. When I switch to 64-bit build I get same errors. 
Basically only dmd x86 works.


It's true if everything is configured properly.




1. How to tell the difference between different libs and what 
kind of libs are required for what kind of compiler and build.


  x86x64
DMD.  .
LDC.  .
GDC.  .

Please fill in the table for windows, linux, etc.


On Windows/Mac/FreeBSD, if you know how to configure libraries 
for gcc, then you know how to configure them with DMD. You 
install the packages you need from your package manager, they 
are installed by default in the appropriate system paths, and 
when DMD invokes the system linker they will be found.


Windows is only problematic because there's no such thing as a 
system linker, nor are there any standard system paths for 
libraries. Given the following command line:


dmd foo.d user32.lib

The compiler will invoke OPTLINK, which it ships with. This 
guarantees that you always have a linker if DMD is installed. 
You will find several Win32 libraries in the dmd2/windows/lib 
directory. They are all a in OMF format for OPTLINK and they 
are all a bit outdated. With the above command line, the 
user32.lib in that directory will be used. If you need a Win32 
system library that does not ship with DMD (such as 
OpenGL32.lib) you will need to provide it yourself in the OMF 
format to use it with OPTLINK.


Add either the -m32mscoff or -m64 command line switch and DMD 
will invoke whichever Microsoft linker it is configured to 
call, meaning it will no longer use the libraries that ship 
with DMD. If you've installed one of paid versions of VS, or 
one of the Community Editions, all of the Win32 libraries will 
be installed as well. If you're using one of the VS Express 
versions, you'll need a Windows SDK installed to have the Win32 
libraries.



2. How does the D build system fetch the libs? It uses the 
sci.ini path? What about Visual D?


Yes, on Windows, sc.ini is where the library paths are 
configured. If you installed DMD manually, or used the 
installer but installed Visual Studio after, then you will need 
to edit sc.ini to make sure the paths point to the proper VS 
locations. If run the DMD installer *after* installing Visual 
Studio, the installer will configure sc.ini for you. I 
recommend you take that approach. It just works.


On other systems, dmd.conf is used to configure the location of 
libphobos2, but system libraries are on the system path (just 
as when using gcc).




Where does D look for these? I assume in the "libs" directory?
   pragma(lib, "opengl32");
   pragma(lib, "glu32");



On Windows, it looks on the path configured in sc.ini or 
whatever import path you have provided on the command line with 
-I, just as it does with any libraries you pass on the command 
line. So that means that compiling without -m32mscoff or -m64, 
it looks win the dmd2/windows/lib directory. Since opengl32 and 
glu32 do not ship with DMD, it will not find them there. So you 
either need to put COFF format libs there or tell the compiler 
where to find them with -I. With -m32mscoff or -m64, it looks 
for the Microsoft version of those libraries in the Visual 
Studio or Windows SDK installation, which you should have 
configured in sc.ini as I explained above.


On other systems, the OpenGL libraries are found on the system 
library path.


3. How to get different compilers and versions to play along? 
I would eventually like to build for win/lin/osx for both x64 
and x86.


On Windows, Just make sure you provide any third-party 
libraries you need, along with any system libraries you need 
that DMD does not ship with, in the OMF format when using 
OPTLINK on Windows and tell DMD where to find them. When using 
the MS toolchain, the system libraries are all there, so you 
need not provide any. You'll just need to make sure any 
third-party libraries are in the COFF format (preferably 
compiled with the same version of Visual Studio you are using 
to link your D programs).


On Linuux and OSX, just make sure the dev packages of any 
libraries you need are installed. You do need to account for 
different libray names (e.g. Openg32.lib on Windows vs. 
libopengl elswhere, so your pragmas above should include '32' 
in the name only on Windows).


Alternatively, you might try one of the dynamic bindings[1] to 
a library you need, such as DerelictGL3. Then there is no link 
time dependency, as the shared libraries are loaded at runtime. 
On Windows, that completely eliminates the COFF vs. OMF issues. 
As long as the DLLs match your executable's architecture 
(32-bit vs. 64-bit), then it doesn't matter what compiler was 
used to create them when loading them at runtime.



I am using Visual D, BTW. It seems to have a lot of stuff 

Re: Parse File at compile time, but not embedded

2016-06-11 Thread Joerg Joergonson via Digitalmars-d-learn

On Saturday, 11 June 2016 at 13:03:47 UTC, ketmar wrote:

On Friday, 10 June 2016 at 18:47:59 UTC, Joerg Joergonson wrote:
In any case, this is impossible. D has no such concept as 
"compile-time-only" values, so any usage of a value risks 
embedding it into the binary.

sure, it has.

template ParseData (string text) {
  private static enum Key = "XXXyyyZZZ33322211\n";
  private static enum TRet = "int data = 3;";
  private static enum FRet = "int data = 4;";
  static if (text.length >= Key.length) {
static if (text[0..Key.length] == Key)
  enum ParseData = TRet;
else
  enum ParseData = FRet;
  } else {
enum ParseData = FRet;
  }
}

void main () {
  mixin(ParseData!(import("a")));
}


look, ma, no traces of our secret key in binary! and no traces 
of `int data` declaration too!


This doesn't seem to be the case though in more complex examples 
;/ enums seem to be compile time only in certain conditions. My 
code is almost identical do what you have written except 
ParseData generates a more complex string and I do reference 
parts of the "Key" in the generation of the code. It's possible 
DMD keeps the full code around because of this.






Re: What's up with GDC?

2016-06-11 Thread Joerg Joergonson via Digitalmars-d-learn
On Saturday, 11 June 2016 at 16:04:45 UTC, Christophe Meessen 
wrote:
Real professionals won't have difficulties to find binaries for 
ldc: https://github.com/ldc-developers/ldc/releases




They also don't waste their time posting asinine comments.


Re: I'd love to see DScript one day ...

2016-06-11 Thread Jonathan Marler via Digitalmars-d

On Saturday, 11 June 2016 at 10:34:41 UTC, Chris wrote:

On Saturday, 11 June 2016 at 10:14:25 UTC, qznc wrote:


[...]


No, JS is here to stay, unfortunately.


Good news, take a look at asmjs.org

In the future you'll be able to compile your D code into 
javascript assembly, and run it in the browser.  I predict LLVM 
will have a javascript assembly backend, so LDC would get this 
for free.  Pretty cool stuff going on in the web world right now.


Finish Winsock Bindings in DRuntime

2016-06-11 Thread Jonathan Marler via Digitalmars-d
I'd like to get the rest of winsock in druntime.  I'm willing to 
work on this and submit a PR but didn't want to work on something 
if someone else was already doing it or if it turns out that we 
don't actually want this in druntime.


We've discussed the best option moving forward here:

https://github.com/smjgordon/bindings/issues/4#issuecomment-225400745

TL;DR

We can't use the version in smjgordon's repo because it's based 
off the original winsock2 headers from Microsoft and those 
headers don't include a license.  Since they don't include a 
license, we have to assume any derivative work (like this 
implementation) has a risk of becoming a legal issue later on.  
We could base it off the MinGW headers, but it has an MIT license 
so any D applications using it would need to include the MIT 
license with their software.  So the best path forward (that 
we've thought of) is to enhance what is already in D runtime 
using the Windows documentation.  It seems silly that we can't 
use an implementation that we already have, but this sort of 
thing happens when you have to deal with licensing issues.  I've 
personally worked with the windows documentation quite a bit and 
have found it to be very comprehensive (in most cases).  For some 
things like private constant values we would need to compile and 
print them out (since we can't use the header files themselves), 
but it's definitely doable.


Thoughts, concerns, anything I'm missing?


[Issue 16165] New: Better error message for mismatched function argument types

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16165

  Issue ID: 16165
   Summary: Better error message for mismatched function argument
types
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: johnnymar...@gmail.com

Currently when a function call has mismatched argument types from the function
definition, an error message like this will get printed when compiling with
dmd:

Error: function myfunction(...) is not callable using argument types (...)

When a function has more than a couple arguments (like most Windows functions),
it can take a bit of effort to figure out which argument is incorrect. Adding
extra information like this: "Cannot convert argument 3 'message' from int to
string" or "you've called myfunction with 10 arguments but it only has 9",
would help developers save time trying to figure out what actually went wrong.

--


[Issue 16165] Better error message for mismatched function argument types

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16165

Jonathan Marler  changed:

   What|Removed |Added

   Priority|P1  |P3

--


Re: Trying to pass lambda to function gives strange error

2016-06-11 Thread Incognito via Digitalmars-d-learn

On Saturday, 11 June 2016 at 22:58:00 UTC, Incognito wrote:

function foo (double x, double y, bool function(bar) callback)
is not callable using argument types
(double, double, bool function() pure nothrow @nogc @safe 
function(bar w) pure nothrow @nogc @safe)


I've tried with passing a delegate.

I am calling it like

foo(0,0, (bar b) => { return true; });

It seems the only difference is all those attributes?!?! Surely 
I don't have to specify all that junk when creating a lambda?


Nevermind. The => is the problem. D should definitely give a 
better warning message than that!


dlang-requests 0.1.7 released

2016-06-11 Thread ikod via Digitalmars-d-announce

Hello,

Dlang-requests is library created under influence of 
Python-requests, with primary goal of easy to use and performance.


It provide interfaces for HTTP(S) and FTP requests. You can tune 
request details, but for most cases you will need single and 
simple API call.


Latest release added streaming content from server and some 
performance improvements (avoiding some of unnecessary buffer 
copying).


Code and docs available at https://github.com/ikod/dlang-requests 
or as dub package.


Thanks Dlang authors and community for excellent language.



Trying to pass lambda to function gives strange error

2016-06-11 Thread Incognito via Digitalmars-d-learn

function foo (double x, double y, bool function(bar) callback)
is not callable using argument types
(double, double, bool function() pure nothrow @nogc @safe 
function(bar w) pure nothrow @nogc @safe)


I've tried with passing a delegate.

I am calling it like

foo(0,0, (bar b) => { return true; });

It seems the only difference is all those attributes?!?! Surely I 
don't have to specify all that junk when creating a lambda?







Re: I implemented delegates in D

2016-06-11 Thread Martin Nowak via Digitalmars-d
On 06/10/2016 12:17 AM, Steven Schveighoffer wrote:
> On 6/9/16 6:06 PM, Mathias Lang via Digitalmars-d wrote:
>> To avoid the delegate being GC allocated, use `scope foo = (int i) { ...
>> }` at call site.
> 
> Is that true? At one point in D's past, this ONLY worked if you passed a
> delegate to a function accepting a scope delegate. Maybe it's been fixed.
> 
> -Steve

I fixed that more than 4 years ago, https://github.com/dlang/dmd/pull/625.


Re: I'd love to see DScript one day ...

2016-06-11 Thread Michael via Digitalmars-d
Having DScript running in the browser and D on the server would 
be an absolute dream to develop with. It might also turn a few 
heads our way.


Re: GTKD - Attach Button to Grid in specific column and row

2016-06-11 Thread Mike Wey via Digitalmars-d-learn

On 06/11/2016 04:57 PM, TheDGuy wrote:

Hi,
i am wondering why this code doesn't work, even though i set the column
and row position of the button it is always placed at the top left (so
basically first row and first column):

   ... Code ...


The way GTK manages width and height, usually widgets are given the 
minimum size they need. So when the button is the only widget in the 
grid the other rows and columns have a height/width of 0.


You can force the button / gird cell to the bottom left by setting the 
expand and alignment properties of the button.


this(int width, int height, string title){
super(title);
setDefaultSize(width,height);

Button btn = new Button();
btn.setSizeRequest(25,25);
btn.setLabel("Exit");
btn.setVexpand(true);
btn.setHexpand(true);
btn.setHalign(Align.END);
btn.setValign(Align.END);
auto call = 
btn.addOnEnterNotify(call);
btn.addOnLeaveNotify(call);

Grid grid = new Grid();
grid.setColumnSpacing(6);
grid.setRowSpacing(6);
grid.attach(btn,3,3,1,1);
add(grid);

showAll();
}

--
Mike Wey


Re: How to detect/filter modules in __traits(allMembers)?

2016-06-11 Thread Basile B. via Digitalmars-d-learn

On Saturday, 11 June 2016 at 19:45:56 UTC, Random D user wrote:

Any good ideas how to do that?

I couldn't figure it out in a short amount of time, but I 
expect that it's possible. I'm probably missing something 
obvious here. Probably because D's reflection/meta programming 
facilities are a bit all over the place (and unnecessarily 
convoluted IMO).
Also I'm not super familiar with every compile-time feature, 
which is why I want to learn and some meta functions/templates 
myself.


[...]


It will compile if you define the option informational warnings 
(-wi).


Re: I'd love to see DScript one day ...

2016-06-11 Thread Walter Bright via Digitalmars-d

On 6/11/2016 3:07 AM, yawniek wrote:

On Friday, 10 June 2016 at 22:01:53 UTC, Walter Bright wrote:

On 6/10/2016 3:55 AM, Chris wrote:
> Cool. I'd love to see `DScript` one day - and replace JS once
and for all ...
> well ... just day dreaming ...

Dreams are reality:

https://github.com/DigitalMars/DMDScript


unfortunately this is unmaintained,


It was working last year, when I got it up on Dub. Dmitry ported it to D2 a 
while ago.


There has been a lack of interest in it, and so it doesn't get exercised much. 
But it is a fully functional implementation of Javascript. For anyone wanting to 
add a scripting language to, say, an IDE written in D, it would be ideal. It 
would also be ideal as a starting point if one wanted to invent yet another 
scripting language.




has no docs


There is not much to document. Feed it a Javascript source file and it executes 
it.



and isn't working on linux/os x.


http://bugzilla.digitalmars.com/issues/buglist.cgi?quicksearch=.

It has in the past. Probably something trivial.



having an ecma script implementation that is able to access D data would be very
usefull
for performant scripting.


Pull requests are welcome.



http://www.roosterteeth.com/post/51267824

2016-06-11 Thread sddgfggcgb via Digitalmars-d

http://www.roosterteeth.com/post/51267824
http://www.roosterteeth.com/post/51267824

http://www.roosterteeth.com/post/51267824

http://www.roosterteeth.com/post/51267824


How to detect/filter modules in __traits(allMembers)?

2016-06-11 Thread Random D user via Digitalmars-d-learn

Any good ideas how to do that?

I couldn't figure it out in a short amount of time, but I expect 
that it's possible. I'm probably missing something obvious here. 
Probably because D's reflection/meta programming facilities are a 
bit all over the place (and unnecessarily convoluted IMO).
Also I'm not super familiar with every compile-time feature, 
which is why I want to learn and some meta functions/templates 
myself.


In my usecase I want to extract structs with UDAs from a module, 
which also imports bunch of stuff. Now __traits(allMembers) gives 
me the list of things (in strings) that the module contains. This 
includes module imports and when I do something like this (in 
pseudo D):


template
{
  foreach(name ; __traits(allMembers, MODULE) )
foreach(attr_name ; __traits(getAttributes, 
__traits(getMember, MODULE, name)))

  whatever logic...
}

I get "Deprecation: foo.bar is not visible from module baz" with 
2.071+ compiler (i.e. import symbol lookup rules changed) where 
foo.bar is an import in MODULE and baz is the module where the 
template for code above is located. And I'm calling the template 
from yet another module qux. This used to work with previous 
versions (modules were just skipped).
The trouble begins when an import module is passed to 
__traits(getMember). (however I can do __traits(hasMember) which 
is a bit weird, since I'd assume same visibility rules would 
apply).


Here's a pseudo example:

mymodule.d:
import foo.bar;
@uda
struct mystruct

baz.d
template get_uda_structs

qux.d
import mymodule.d
import baz.d
auto structs = get_uda_structs(mymodule, uda); // Won't compile: 
"Deprecation: foo.bar is not visible from module baz"


Re: Perl6 Unicode support

2016-06-11 Thread ag0aep6g via Digitalmars-d-announce

On 06/11/2016 09:25 PM, Andrew Godfrey wrote:

That's the distinction, yes. The article mentions both in a way that
makes me unsure if Perl 6 confused the terms (or maybe it's just the
article that isn't being clear).


But how would you "focus" on one or the other?
Is there any operation that works differently on graphemes than on 
grapheme clusters?
Counting/skipping/extracting graphemes is the same as counting grapheme 
clusters, no?


Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread Vladimir Panteleev via Digitalmars-d
On Saturday, 11 June 2016 at 19:20:56 UTC, Andrei Alexandrescu 
wrote:

On 6/11/16 12:31 PM, Jonathan M Davis via Digitalmars-d wrote:
Are_you_  going to spend time going through every single page 
in the
documentation, looking to see whether someone asked a question 
and then

reply to them if they did?


I get notified by disqus for new posts. The basic idea is if we 
don't prime it we'll never have it. -- Andrei


I think it wouldn't be too hard to embed DFeed as a comment 
system. What do you think? Then anyone can subscribe to new 
comments through the usual means. The same solution can be 
applied to the blog.


I understand that the current bottleneck is someone adding new 
groups to the NNTP server. Can that be resolved?




Re: Perl6 Unicode support

2016-06-11 Thread Andrew Godfrey via Digitalmars-d-announce

On Saturday, 11 June 2016 at 18:33:04 UTC, ag0aep6g wrote:

On 06/11/2016 06:47 PM, Andrew Godfrey wrote:
OTOH, it mentions both graphemes and grapheme clusters, 
without much
distinction. So I'm not exactly sure which is the default 
focus.


What distinction is there to be made? As far as I understand, a 
grapheme cluster is a sequence (or cluster) of code points that 
together represent one grapheme.


That's the distinction, yes. The article mentions both in a way 
that makes me unsure if Perl 6 confused the terms (or maybe it's 
just the article that isn't being clear).


Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread Andrei Alexandrescu via Digitalmars-d

On 6/11/16 12:31 PM, Jonathan M Davis via Digitalmars-d wrote:

Are_you_  going to spend time going through every single page in the
documentation, looking to see whether someone asked a question and then
reply to them if they did?


I get notified by disqus for new posts. The basic idea is if we don't 
prime it we'll never have it. -- Andrei


Re: Monads in D

2016-06-11 Thread Max Samukha via Digitalmars-d

On Saturday, 11 June 2016 at 18:27:19 UTC, deadalnix wrote:



I could go on, but this guy already did it way better that I 
can:

https://www.infoq.com/presentations/functional-pros-cons

The part about monad starts 25mins in.


The guy is good.


Re: I'd love to see DScript one day ...

2016-06-11 Thread qznc via Digitalmars-d
On Saturday, 11 June 2016 at 18:36:23 UTC, Ola Fosheim Grøstad 
wrote:

On Saturday, 11 June 2016 at 10:14:25 UTC, qznc wrote:
I have given up hope for different browser languages than 
Javascript. The problem is not finding a language. A lot of 
people would love to have Lua, Python, or something else and 
it has not happened yet. Dart was the most serious attempt. 
They had full-time people at Google working on it and they 
gave up.


They didn't give up as they use it internally for their 
advertising application. Dart 1.7 was out 2 days ago:


http://news.dartlang.org/2016/06/dart-117-more-performance-improvements.html


They gave up last year [0], when they abandoned 
Chrome-integration:


“In order to do what’s best for our users and the web, and not 
just Google Chrome, we will focus our web efforts on compiling 
Dart to JavaScript,” Dart co-founders Lars Bak and Kasper Lund 
wrote today. “We have decided not to integrate the Dart VM into 
Chrome.”


[0] http://news.dartlang.org/2015/03/dart-for-entire-web.html


RegisterClass fails with x64

2016-06-11 Thread Incognito via Digitalmars-d-learn

Hi,

I am trying to create a win32 window using RegisterClass(Ex). It 
fails on x64 but works on x86. The error code is 998 = 
ERROR_NOACCESS, Invalid access to memory location.


For x64 I used -L/ENTRY:mainCRTStartup because of link error(not 
finding entry point). Not sure if this is causing the problem or 
not.







Re: I'd love to see DScript one day ...

2016-06-11 Thread Basile B. via Digitalmars-d

On Saturday, 11 June 2016 at 17:18:59 UTC, Observer wrote:

On Saturday, 11 June 2016 at 09:23:55 UTC, Chris wrote:
However, with `DScript` I meant a new scripting language that 
can draw on the power of D, not necessarily a 
re-implementation of JS. Adam[1] and ketmar[2] have already 
worked on D based scripting languages. I wonder, if there is 
interest in creating a D-based (not `debased`) scripting 
language. D has features that are perfect for scripting or DS 
languages. Why not try something new? Having a child language 
might also help with D development in general, who knows.


I'm confused.  I thought I read in TDPL (don't have it handy 
here

to check) that you could just slap a shebang line on a D program
and you then have a runnable script.  Or something very close to
that construction.  So don't we already have what want?


this way (she bang rdmd) is for turning a module into something 
like a shell script.


You cannot use it dynamically in an application e.g with binding 
to the application variables and to the applications functions 
(like LUA in game or JS in web browsers).


Re: I'd love to see DScript one day ...

2016-06-11 Thread Ola Fosheim Grøstad via Digitalmars-d
On Saturday, 11 June 2016 at 18:36:23 UTC, Ola Fosheim Grøstad 
wrote:

On Saturday, 11 June 2016 at 10:14:25 UTC, qznc wrote:
I have given up hope for different browser languages than 
Javascript. The problem is not finding a language. A lot of 
people would love to have Lua, Python, or something else and 
it has not happened yet. Dart was the most serious attempt. 
They had full-time people at Google working on it and they 
gave up.


They didn't give up as they use it internally for their 
advertising application. Dart 1.7 was out 2 days ago:


I meant Dart 1.17... Duh.

Interestingly there was an interview related to Dart and Adwords 
UI


http://news.dartlang.org/2016/03/the-new-adwords-ui-uses-dart-we-asked.html

I found these quotes interesting:

«One thing we found out was that developers preferred even 
stronger type checking than what Dart was providing. So, we are 
very excited about the work on Dart Strong Mode. We are also 
looking forward to cross-browser, fast edit refresh with the 
upcoming Dart Dev Compiler.»


and

«With Angular2, the application performance and code size are 
very similar between the JS and Dart versions. So any team 
considering Angular2 should consider Dart as well.»


Dunno. Still not sure about the future of Dart, but stricter 
static typing is a good selling point.




Announcing TinyRedis v2.1.0

2016-06-11 Thread Adil via Digitalmars-d-announce
It's been a while since i announced a TinyRedis release. So here 
goes.


TinyRedis is a fast and simple Redis(http://redis.io) driver for 
D. It has no dependencies and makes working with Redis trivial.


This release brings TinyRedis up-to-date with dmd 2.071. 
Noteworthy improvements are :


- dub: An earlier version of TinyRedis put it up on 
http://code.dlang.org. In this version dub.json has been spruced 
up to provide feature parity with the Makefile. Now examples can 
also be compiled via dub.
- dmd 2.071: Updated to dmd 2.071. Thanks to a patch by 
@John-Colvin
- simpler imports: Imports have been clumped into one namespace. 
`import tinyredis;`
- `tinyredis.collections`: This is the start of some work that 
has been lying around in master for a while. I've been meaning to 
write simple OOP wrappers for common data types on Redis, but 
never got round to completing more than one. This release 
includes a basic class to simplify working with SETs.
- PubSub: This much requested feature has finally landed! All 
thanks to Ali Cehreli for building it out. PubSub is a Redis 
feature that works like a lightweight, centralised message queue. 
A new Subscriber class provides the complete range of 
functionality to work with message queues.


Download : https://github.com/adilbaig/Tiny-Redis/releases
GitHub : https://github.com/adilbaig/Tiny-Redis
Docs : http://adilbaig.github.io/Tiny-Redis/


Re: I'd love to see DScript one day ...

2016-06-11 Thread Ola Fosheim Grøstad via Digitalmars-d

On Saturday, 11 June 2016 at 10:14:25 UTC, qznc wrote:
I have given up hope for different browser languages than 
Javascript. The problem is not finding a language. A lot of 
people would love to have Lua, Python, or something else and it 
has not happened yet. Dart was the most serious attempt. They 
had full-time people at Google working on it and they gave up.


They didn't give up as they use it internally for their 
advertising application. Dart 1.7 was out 2 days ago:


http://news.dartlang.org/2016/06/dart-117-more-performance-improvements.html

I think most people outside Google has given up though. I've 
picked up Typescript and I suspect many others have as well. 
Typescript is close enough to Javascript to make debugging 
reasonable.




Re: Perl6 Unicode support

2016-06-11 Thread ag0aep6g via Digitalmars-d-announce

On 06/11/2016 06:47 PM, Andrew Godfrey wrote:

OTOH, it mentions both graphemes and grapheme clusters, without much
distinction. So I'm not exactly sure which is the default focus.


What distinction is there to be made? As far as I understand, a grapheme 
cluster is a sequence (or cluster) of code points that together 
represent one grapheme.


Re: Button: A fast, correct, and elegantly simple build system.

2016-06-11 Thread Jason White via Digitalmars-d-announce

On Saturday, 11 June 2016 at 02:48:59 UTC, H. S. Teoh wrote:
Finally got around to looking at this (albeit just briefly). It 
looks very nice!  Perhaps I'll try using it for my next project.


If you do end up using it, I'd be happy to iron out any 
irritations in Button that you encounter.


Button really needs a large project using it to help drive 
refinements.


I'm particularly pleased with the bipartite graph idea. It's a 
very nice way of sanely capturing the idea of build commands 
that generate multiple outputs.  Also big plusses in my book 
are implicit dependencies and use of inotify to eliminate the 
infamous "thinking pause" that older build systems all suffer 
from (this idea was also advanced by tup, but IMO Button looks 
a tad more polished than tup in terms of overall design).  Of 
course, being written in D is a bonus in my book. :-D Though 
realistically speaking it probably doesn't really matter to me 
as an end user, other than just giving me warm fuzzies.


Tup has had a big influence on the design of Button (e.g., a 
bipartite graph, deleting unused outputs, implicit dependencies, 
using Lua, etc.). Overall, I'd say Button does the same or better 
in every respect except maybe speed.


About it being written in D: If Rust had been mature enough when 
I first started working on it, I might have used it instead. All 
I knew is that I didn't want to go through the pain of writing it 
in C/C++. :-)


Unfortunately I don't have the time right now to actually do 
anything non-trivial with it... but I'll try to give feedback 
when I do get around to it (and I definitely plan to)!


Thanks! I look forward to it!


Re: Monads in D

2016-06-11 Thread deadalnix via Digitalmars-d

On Saturday, 11 June 2016 at 14:26:20 UTC, Atila Neves wrote:

I give you a facsimile of a Haskell do block:

with(Maybe!int) {
return_(5).bind!(a => return_(a + 
1)).shouldEqual(just(6));

nothing.bind!(a => return_(a + 1)).shouldEqual(nothing);
return_(8).bind!(a => nothing).bind!(a => return_(a + 
1)).shouldEqual(nothing);

}

with(Maybe!string) {
return_("foo").bind!(a => return_(a ~ 
"bar")).shouldEqual(just("foobar"));
nothing.bind!(a => return_(a ~ 
"bar")).shouldEqual(nothing);
return_("foo").bind!(a => return_(a ~ "bar")).bind!(a 
=> nothing).shouldEqual(nothing);

}


Why? Because I could, I don't plan on using this for anything 
serious. I think "with" is my favourite D feature right now. I 
also wrote the Writer and State monads (not that D needs them):


https://github.com/atilaneves/felix

I tried overloading `>>>` for bind (closest overloadable 
operator to `>>=`) but it went horribly wrong. I always get 
problems when I try to pass lambdas as runtime values instead 
of template parameters.



Atila


Honestly, the whole bind/return is just a giant NIH. >>> and >>= 
are its symptoms. There is a reason why nobody understands jack 
shit about monad even after 10s of tutorial when they aren't even 
hard in any way: because haskell and alike have made all that is 
in their power to obfuscate what is a monad.


I could go on, but this guy already did it way better that I can:
https://www.infoq.com/presentations/functional-pros-cons

The part about monad starts 25mins in.



Re: Version identifier for PS4

2016-06-11 Thread Johan Engelen via Digitalmars-d

On Saturday, 11 June 2016 at 17:21:18 UTC, Markus Pursche wrote:
On Saturday, 11 June 2016 at 17:09:59 UTC, David Nadlinger 
wrote:

On Friday, 10 June 2016 at 14:37:23 UTC, Markus Pursche wrote:

If this is the case we would want to use Orbis.


As Seb also pointed out on GitHub, I've seen LLVM use "PS4" 
internally, and it always seemed rather natural to me. On the 
other hand, with Orbis I would have had no idea what the code 
was about, and it's not like you can really install another 
operating system on a PS4 anyway. (Yes, I'm aware of the 
Jailbreak/Homebrew community, but that's rather besides the 
point.)


 — David


Another argument for PS4 is that if (when) a PS5 is released 
and we get D working on it they would follow a pattern instead 
of calling the PS5 whatever it's OS is nicknamed.


Because of that, I prefer "PlayStation". Any additions to a 
reserved identifier name are also reserved, so it would reserve 
"PlayStation4", "PlayStation5", "PlayStationOver9000"...

And just "PS" would be very tiny.


Re: Version identifier for PS4

2016-06-11 Thread Johan Engelen via Digitalmars-d

On Saturday, 11 June 2016 at 17:09:59 UTC, David Nadlinger wrote:

 with Orbis I would have had no idea what the code was about


+1


[Issue 16164] struct(class)'s template is difficult to use the default type

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16164

Tsukasa Sugawara  changed:

   What|Removed |Added

   Severity|minor   |trivial

--


[Issue 16164] struct(class)'s template is difficult to use the default type

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16164

--- Comment #1 from Tsukasa Sugawara  ---

I received advice;
 " rewrite S to S!() "

work correctly, since I will change state to trivial.

--


[Issue 16164] struct(class)'s template is difficult to use the default type

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16164

Tsukasa Sugawara  changed:

   What|Removed |Added

Summary|struct(class)'s template is |struct(class)'s template is
   |NOT available the default   |difficult to use the
   |type|default type

--


Re: Monads in D

2016-06-11 Thread Atila Neves via Digitalmars-d

On Saturday, 11 June 2016 at 16:50:15 UTC, qznc wrote:

On Saturday, 11 June 2016 at 14:26:20 UTC, Atila Neves wrote:
Why? Because I could, I don't plan on using this for anything 
serious. I think "with" is my favourite D feature right now. I 
also wrote the Writer and State monads (not that D needs them):


I also tried this. Instead of Write and State, I tried to model 
the Functor > Applicative > Monad > MonadFail type hierarchy. I 
found no way for a good "template inheritance" construct. 
Overall, I quickly forgot about it, because it looks ugly and 
seems to have no advantage.


I was thinking of doing that as well and was going to model the 
hierarchy like so:


alias isFunctor = isInputRange;
enum isApplicative(alias T, U...) = isFunctor!T && is(typeof() { 
... }));
enum isMonad(alias T, U...) = isApplicative!(T, U) && 
is(typeof(() { ... }));



Thinking more conceptually, Monads should be somewhat related 
to input ranges, as both model a linear sequence.


Monads are related to input ranges because every monad is a 
functor, and input ranges are functors.


Atila




Re: Monads in D

2016-06-11 Thread Atila Neves via Digitalmars-d

On Saturday, 11 June 2016 at 14:57:11 UTC, ArturG wrote:

On Saturday, 11 June 2016 at 14:26:20 UTC, Atila Neves wrote:



Why? Because I could, I don't plan on using this for anything 
serious. I think "with" is my favourite D feature right now. I 
also wrote the Writer and State monads (not that D needs them):


https://github.com/atilaneves/felix


Atila


im not an expert but is it something similar to this idea[1] as 
it seems to be used in a similar way.


[1] 
http://forum.dlang.org/thread/ltalqpmpscdoziser...@forum.dlang.org


Right, but that's only the Maybe monad. I was trying out monads 
in general.


Atila


Re: Version identifier for PS4

2016-06-11 Thread Markus Pursche via Digitalmars-d

On Saturday, 11 June 2016 at 17:09:59 UTC, David Nadlinger wrote:

On Friday, 10 June 2016 at 14:37:23 UTC, Markus Pursche wrote:

If this is the case we would want to use Orbis.


As Seb also pointed out on GitHub, I've seen LLVM use "PS4" 
internally, and it always seemed rather natural to me. On the 
other hand, with Orbis I would have had no idea what the code 
was about, and it's not like you can really install another 
operating system on a PS4 anyway. (Yes, I'm aware of the 
Jailbreak/Homebrew community, but that's rather besides the 
point.)


 — David


Another argument for PS4 is that if (when) a PS5 is released and 
we get D working on it they would follow a pattern instead of 
calling the PS5 whatever it's OS is nicknamed.


I am still leaning PS4, I guess the ultimate decision comes down 
to whomever can accept/reject the PR.


Re: I'd love to see DScript one day ...

2016-06-11 Thread Observer via Digitalmars-d

On Saturday, 11 June 2016 at 09:23:55 UTC, Chris wrote:
However, with `DScript` I meant a new scripting language that 
can draw on the power of D, not necessarily a re-implementation 
of JS. Adam[1] and ketmar[2] have already worked on D based 
scripting languages. I wonder, if there is interest in creating 
a D-based (not `debased`) scripting language. D has features 
that are perfect for scripting or DS languages. Why not try 
something new? Having a child language might also help with D 
development in general, who knows.


I'm confused.  I thought I read in TDPL (don't have it handy here
to check) that you could just slap a shebang line on a D program
and you then have a runnable script.  Or something very close to
that construction.  So don't we already have what want?


Re: Version identifier for PS4

2016-06-11 Thread David Nadlinger via Digitalmars-d

On Friday, 10 June 2016 at 14:37:23 UTC, Markus Pursche wrote:

If this is the case we would want to use Orbis.


As Seb also pointed out on GitHub, I've seen LLVM use "PS4" 
internally, and it always seemed rather natural to me. On the 
other hand, with Orbis I would have had no idea what the code was 
about, and it's not like you can really install another operating 
system on a PS4 anyway. (Yes, I'm aware of the Jailbreak/Homebrew 
community, but that's rather besides the point.)


 — David


[Issue 16164] New: struct(class)'s template is NOT available the default type

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16164

  Issue ID: 16164
   Summary: struct(class)'s template is NOT available the default
type
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: minor
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: mixedavocado+dl...@gmail.com

void main(){
S s;
}
struct S( T = size_t )
{
T buf;
}
> Error: struct temp.S(T = size_t) is used as a type


difficult to understand because there is no relation of default Type,
and difficult to notice rewriting S to S!size_t(work correctly).   

I think that DMD compiler should...
  use Template-Type-Parameter-Default and not return error (enh?bug?)
  or return error message about default value  with above message (bug)
  or return error message easier (enh?bug?)

--


Re: Andrei's list of barriers to D adoption

2016-06-11 Thread Nick Sabalausky via Digitalmars-d

On 06/06/2016 04:15 AM, Russel Winder via Digitalmars-d wrote:


3. Have one lightweight D realized cross platform IDE. Qt us probably
the best widget set to use for this. My model here is LiteIDE which is
a Qt-based Go IDE realized in C++. It should of course be realized in
Go, but there are no Qt bindings for Go, only QML ones.



One thing I've been really wanting to do for awhile (and even moreso 
after switching my main desktop to Linux) is take Programmer's Notepad 2 
(a windows program, but very lightweight and very nice) and try porting 
it to D+Qt (or maybe libui if it gets a Qt backend). Although I don't 
know how realistic Qt on D in right now, and I haven't been able to 
justify the personal time & energy investment, even as much as I'd like 
to :( Just can't find a linux editor I like as much as PN2 :(




The Offical Blog Theme is Now OSS

2016-06-11 Thread Jack Stouffer via Digitalmars-d

https://github.com/dlang/D-Blog-Theme


Re: Monads in D

2016-06-11 Thread qznc via Digitalmars-d

On Saturday, 11 June 2016 at 14:26:20 UTC, Atila Neves wrote:
Why? Because I could, I don't plan on using this for anything 
serious. I think "with" is my favourite D feature right now. I 
also wrote the Writer and State monads (not that D needs them):


I also tried this. Instead of Write and State, I tried to model 
the Functor > Applicative > Monad > MonadFail type hierarchy. I 
found no way for a good "template inheritance" construct. 
Overall, I quickly forgot about it, because it looks ugly and 
seems to have no advantage.


Thinking more conceptually, Monads should be somewhat related to 
input ranges, as both model a linear sequence.





Re: Perl6 Unicode support

2016-06-11 Thread Andrew Godfrey via Digitalmars-d-announce
On Wednesday, 11 May 2016 at 12:11:32 UTC, Guillaume Chatelet 
wrote:

It looks good:
https://perl6advent.wordpress.com/2015/12/07/day-7-unicode-perl-6-and-you/


Especially, it works in graphemes, and ".codes" lets you count 
code points. The article isn't even mentioning "code units".


OTOH, it mentions both graphemes and grapheme clusters, without 
much distinction. So I'm not exactly sure which is the default 
focus.


Re: foo => "bar" key/value literals in D!

2016-06-11 Thread ArturG via Digitalmars-d-announce
On Saturday, 11 June 2016 at 15:46:59 UTC, Vladimir Panteleev 
wrote:


Taking an address creates a function pointer, which loses the 
argument names. (Doesn't it?)


unfortunatly yes, but it works as a struct or class initializer
https://dpaste.dzfl.pl/6aad852aea90


Re: What's up with GDC?

2016-06-11 Thread Christophe Meessen via Digitalmars-d-learn
Real professionals won't have difficulties to find binaries for ldc: 
https://github.com/ldc-developers/ldc/releases

--
Bien cordialement,
Ch.Meessen

> Le 10 juin 2016 à 22:30, Joerg Joergonson via Digitalmars-d-learn 
>  a écrit :
> 
>> On Friday, 10 June 2016 at 19:51:19 UTC, Johan Engelen wrote:
>>> On Friday, 10 June 2016 at 19:37:13 UTC, Joerg Joergonson wrote:
>>> arm-linux-genuabi? arm-linux-gnueableihfqueridsofeyfh?  
>>> aifh-fkeif-f-fdsskjhfkjfafaa?
>> 
>> Rofl!
>> 
>>> and ldc requires building from sources(actually I didn't have too much 
>>> trouble with installing it but it doesn't work with my libs because of the 
>>> crappy coff issues that D has had since birth(it's like a tumor)).
>> 
>> Why do you have to build from sources? Any details about the problems you 
>> see?
>> 
>> Thanks,
>>  Johan
> 
> Well, the post was a bit incoherent because getting all this stuff working 
> is. I was searching for ldc and ran across some web site that had only the 
> sources(same for gdc).
> 
> The point of it all is that things seem to be a bit discombobulated and make 
> D look bad.  Professions won't use D if it can't be used professionally(not 
> that I'm a pro, just saying).
> 
> Why isn't there a proper binaries for ldc and gdc that work out of the box 
> like dmd?  There used to be. What's up with all this arm-linux-genuabi crap? 
> When one opens up the archive all the files are named that way too.  There is 
> no explanation of what that means. Did some kid write this stuff in his 
> basement or is this suppose to be serious? Do people think about the end user 
> when creating this stuff or is it just a eureka moment "Lightbulb: Lets 
> create some spaghetti!".
> 
> I would have thought things would have gotten easier and more logical but 
> that doesn't seem to be the case.
> 
> 


Re: foo => "bar" key/value literals in D!

2016-06-11 Thread Vladimir Panteleev via Digitalmars-d-announce

On Saturday, 11 June 2016 at 11:15:43 UTC, ArturG wrote:
On Saturday, 11 June 2016 at 09:07:43 UTC, Andrei Alexandrescu 
wrote:


No, both are nice to have. If one name is needed for both, 
"args" is indeed a good commonality. "Invoke function f with 
these args" and "Construct an object of type T with these 
args". The problem is it's not very intuitive in usage.


Perhaps "call" for functions and "make" for objects are 
better. If we add these to std.experimental.functional and 
std.experimental.conv and they get a lot of usage we might 
make a small change to the language.



Andrei


would'nt it be possible to take the type as a runtime param
and support struct, class and all callables?
e.g.

().args!(a=>5, b=>6);


Taking an address creates a function pointer, which loses the 
argument names. (Doesn't it?)




Re: Andrei's list of barriers to D adoption

2016-06-11 Thread Observer via Digitalmars-d

On Tuesday, 7 June 2016 at 23:05:49 UTC, Walter Bright wrote:

On 6/7/2016 2:28 PM, Steven Schveighoffer wrote:
I can attest that figuring out why something isn't inferred 
@safe isn't always
easy, and the "slap a @safe: tag at the top" isn't always 
going to help.


Having a -safe compiler switch to make @safe the default won't 
improve that in the slightest.


I think it's useful here to compare one aspect of Perl's approach 
to

security, its "taint" mode.  It tags insecure data to make sure it
does not affect the security of the application, and blocks 
actions

where insecure actions would otherwise occur.  The Perl invocation
accepts a couple of flags to control how taint mode works:

  -t  Like -T, but taint checks will issue warnings rather than 
fatal
  errors.  These warnings can now be controlled normally with 
"no

  warnings qw(taint)".

  Note: This is not a substitute for "-T"! This is meant to 
be used
  only as a temporary development aid while securing legacy 
code:
  for real production code and for new secure code written 
from

  scratch, always use the real -T.

  -T  turns on "taint" so you can test them.  Ordinarily these 
checks
  are done only when running setuid or setgid.  It's a good 
idea to
  turn them on explicitly for programs that run on behalf of 
someone
  else whom you might not necessarily trust, such as CGI 
programs or
  any internet servers you might write in Perl.  See perlsec 
for
  details.  For security reasons, this option must be seen by 
Perl

  quite early; usually this means it must appear early on the
  command line or in the "#!" line for systems which support 
that

  construct.

The point being, such flags provide a very simple means for the 
user
to check the execution of their code, without being terribly 
intrusive.
They can be a great convenience as a stepstone to discovering 
where

problems exist and addressing them.


GTKD - Attach Button to Grid in specific column and row

2016-06-11 Thread TheDGuy via Digitalmars-d-learn

Hi,
i am wondering why this code doesn't work, even though i set the 
column and row position of the button it is always placed at the 
top left (so basically first row and first column):


this(int width, int height, string title){
super(title);
setDefaultSize(width,height);

Button btn = new Button();
btn.setSizeRequest(25,25);
btn.setLabel("Exit");
auto call = 
btn.addOnEnterNotify(call);
btn.addOnLeaveNotify(call);

Grid grid = new Grid();
grid.setColumnSpacing(6);
grid.setRowSpacing(6);
grid.attach(btn,3,3,1,1);
add(grid);

showAll();
}


Re: Monads in D

2016-06-11 Thread ArturG via Digitalmars-d

On Saturday, 11 June 2016 at 14:26:20 UTC, Atila Neves wrote:



Why? Because I could, I don't plan on using this for anything 
serious. I think "with" is my favourite D feature right now. I 
also wrote the Writer and State monads (not that D needs them):


https://github.com/atilaneves/felix


Atila


im not an expert but is it something similar to this idea[1] as 
it seems to be used in a similar way.


[1] 
http://forum.dlang.org/thread/ltalqpmpscdoziser...@forum.dlang.org


Re: I'd love to see DScript one day ...

2016-06-11 Thread Chris via Digitalmars-d

On Saturday, 11 June 2016 at 13:41:32 UTC, ketmar wrote:
i'd also say: "JIT it from the start!" targeting LibJIT is very 
easy, and you will have nice machine code for x86, x86_64 and 
ARM, plus IR interpreter for any other "unsupported" arch.


Yes, I was thinking along the same lines. JIT from the start.


[Issue 16163] New: merge article pages with dlang blog

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16163

  Issue ID: 16163
   Summary: merge article pages with dlang blog
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: greensunn...@gmail.com

There's now quite some overlap with the Dlang Articles
(http://dlang.org/articles.html) and the Dlang Blog - ideally we can find a
solution to merge them. Some of the articles could go to a blog, but e.g. the C
to D guide should still be easily accessible for newcomers.

--


[Issue 16162] New: not reachable sites

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16162

  Issue ID: 16162
   Summary: not reachable sites
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: greensunn...@gmail.com

The following sites aren't reachable via the menu or other easy ways and should
either be linked somewhere findable or deprecated:

https://dlang.org/ascii-table.html
https://dlang.org/deprecate.html
https://dlang.org/gpg_keys.html
https://dlang.org/gsoc2012.html (and the others)
https://dlang.org/howto-promote.html
https://dlang.org/template-comparison.html
https://dlang.org/concepts.html
https://dlang.org/bugstats.php.html
https://dlang.org/tuple.html
https://dlang.org/windbg.html
https://dlang.org/wc.html
https://dlang.org/dll-linux.html

--


Monads in D

2016-06-11 Thread Atila Neves via Digitalmars-d

I give you a facsimile of a Haskell do block:

with(Maybe!int) {
return_(5).bind!(a => return_(a + 
1)).shouldEqual(just(6));

nothing.bind!(a => return_(a + 1)).shouldEqual(nothing);
return_(8).bind!(a => nothing).bind!(a => return_(a + 
1)).shouldEqual(nothing);

}

with(Maybe!string) {
return_("foo").bind!(a => return_(a ~ 
"bar")).shouldEqual(just("foobar"));
nothing.bind!(a => return_(a ~ 
"bar")).shouldEqual(nothing);
return_("foo").bind!(a => return_(a ~ "bar")).bind!(a => 
nothing).shouldEqual(nothing);

}


Why? Because I could, I don't plan on using this for anything 
serious. I think "with" is my favourite D feature right now. I 
also wrote the Writer and State monads (not that D needs them):


https://github.com/atilaneves/felix

I tried overloading `>>>` for bind (closest overloadable operator 
to `>>=`) but it went horribly wrong. I always get problems when 
I try to pass lambdas as runtime values instead of template 
parameters.



Atila



Re: What's up with GDC?

2016-06-11 Thread Johan Engelen via Digitalmars-d-learn

On Saturday, 11 June 2016 at 08:48:42 UTC, Mike Parker wrote:
[... a lot ...]

This looks like a nice writeup Mike, could you get this on the 
Wiki or somewhere more permanent where people can find it?


-Johan





Re: Andrei's list of barriers to D adoption

2016-06-11 Thread Observer via Digitalmars-d

On Tuesday, 7 June 2016 at 20:41:21 UTC, Jonathan M Davis wrote:
In principle, I think that you're very right that @safe needs 
to be implemented as a whitelist. Security in general does not 
work as a blacklist, and I think that @safe has the same 
problem. The problem is code breakage. Even assuming that the 
change in implementation were straightforward (and I have no 
idea whether it is or not), it would be pretty much guranteed 
that we would break a lot of code marked @safe if we were to 
switch to a whitelist. Some of that code is not truly @safe and 
really should be fixed, but just throwing the switch like that 
is too sudden. We'd probably be forced to have both a whitelist 
and a blaklist and treat the whitelist results as warnings 
temporarily before switching fully to the whitelist 
implementation. And that's likely feasible, but it seems like 
it would be a bit of a mess. So, I don't know if we reasonably 
can switch to a whitelist or not. But I think that it's clearly 
that we ideally would.


I think you meant "treat the non-whitelist results as warnings".

Seems to me the proper answer is simple.  Stuff on the whitelist
should pass without comment.  Stuff on neither the whitelist nor
the blacklist should generate warnings.  Stuff on the blacklist
should generate errors.  A compiler flag similar to gcc's -Werror
that turns all warnings into errors would allow the end-user to
select whether or not to worry, during a phase of transition.

This way, those warnings could be pushed back upstream to the
compiler maintainers as "hey, your whitelist/blacklist division
omits certain real-world cases".  And gradually, the graylist
would be narrowed over successive compiler releases.


Re: I'd love to see DScript one day ...

2016-06-11 Thread ketmar via Digitalmars-d
p.p.s. i'm slowly working on my own SSA-based codegen library 
too. no timelines are set, tho.


Re: [OT] Re: Andrei's list of barriers to D adoption

2016-06-11 Thread Ola Fosheim Grøstad via Digitalmars-d

On Saturday, 11 June 2016 at 12:19:52 UTC, Jonathan M Davis wrote:
LOL. 10x that would be cheap in the US, and I don't think that 
your average school will let folks sit in on courses (though 
some will). For your average college in the US, I would only 
expect anyone to take classes if they're actually working 
towards a degree, though I'm sure that there are exceptions in 
some places.


I remember that we sometimes had older programmers taking some 
courses, maybe to ge a degree? But not often. The $100/semester 
fee isn't for tuition though, it is for student 
activities/facilities, paper copies etc. Tuition is free.


It works better when the school itself is really hard to get 
into. For instance, my dad went to MIT, and according to him, 
you usually don't have much of a need for weeder courses there, 
because it was already hard enough to get into the school that 
folks who can't hack it won't even be there - and it's an 
engineering school, so you're typically going to get very 
smart, well-prepared students who want to do engineering.


It sorts itself out at higher levels, although I once had a 
project group at the master level that came to the hallway 
outside my office to get help, and it eventually dawned on me 
that none of the three boys knew that they should end sentences 
with ";"... I couldn't help laughing... and I kinda felt bad 
about it, but they laughed too, so I guess it was ok. I was so 
totally unprepared for that kind of problem at a master level 
course. I assume they came from some other field, as it was a 
web-oriented course.


These things with uneven knowledge levels are more of a problem 
in "hip" project oriented courses, not so much in the courses 
that are proper compsci and are based on individual final exams. 
It kinda work out ok as long as students of the same level go on 
the same group, but it creates a lot of friction if you get a 
mixed group where the better students feel the other ones are 
freeloaders.


You freqeuntly either end up with the school trying to weed out 
a lot of folks up front by having very hard beginning courses 
or making their beginning classes easy in an attempt to make it 
so that everyone has a chance, though I think that tends to 
just delay the inevitable for many students.


Yep, exactly, but the problem was that the introduction course in 
programming was required by other fields such as getting a master 
in bio-chemistry or so. That didn't go very well when the 
lecturer once came up with a "clever exam" where you got stuck if 
you didn't master the first task. So 40% failed on their final 
exam, 200 angry students? That would've made me feel bad. After 
that they softened the tasks a bit... making failure harder.


In the math department they had one more narrow calculus course 
for those who wanted to specialise in math and a broader more 
pragmatic calculus course for those who were more to use math as 
an applied tool in other fields. Probably a better solution.


to be able to program. So, I agree that it would be nice if 
there were some sort of aptitude test up front that at least 
indicated whether you were likely have a very hard time with 
programming. But I don't think that I've ever heard of any 
schools doing anything like that (though obviously, some could 
be, and I just haven't heard of it). And I don't know how you 
would even go about making such a test, though I expect that 
there are computer science professors out there who would.


Well, I don't know.  I guess having average or above in math 
would work out. Not that you have to know math, but general 
problem solving. I noticed that people from other fields that was 
working on their master picked up programming faster, perhaps 
because they had acquired skills in structuring and problem 
solving.


Then again, pure theoretical topics kill motivation for me. Like, 
I could never find any interest in solving tricky integrals 
analytically as it seemed like a pointless exercise. And to be 
honest, I've never found the need to do it. But as you said, some 
topics become more meaningful later in life and I'd probably put 
more energy into topics like program verification and 
combinatorics today than I did in my youth.




Re: I'd love to see DScript one day ...

2016-06-11 Thread ketmar via Digitalmars-d
i'd also say: "JIT it from the start!" targeting LibJIT is very 
easy, and you will have nice machine code for x86, x86_64 and 
ARM, plus IR interpreter for any other "unsupported" arch.


Re: I'd love to see DScript one day ...

2016-06-11 Thread ketmar via Digitalmars-d
p.s. i did a D wrapper for LibJIT, it is in DACS repo. i also 
talked with LibJIT maintainer, and that wrapper may be included 
in next LibJIT release.


Re: The Official D Blog is Live

2016-06-11 Thread Jacob Carlborg via Digitalmars-d-announce

On 2016-06-10 20:47, Jacob Carlborg wrote:


Unfortunately there doesn't seem to be an exact specification of what's
required for the reader mode to be available. I can do some digging to
see if I can find something.


At the bottom is the minimal amount of HTML code I could come up with 
that makes the reader mode available.


The number of letters in these paragraphs are important. If I remove 
some letters it will not make the reader mode available. But, it depends 
on the width of the browser window. The first paragraph below needs to 
not fit on one line to make the reader mode available. Below is the 
exact number of letters or words required to not make the text fit on 
one line on using a 1920px wide window.


An image is not required but I wasn't able to figure out what to use 
instead of the image below.


The document cannot be locale, i.e. file://.

I've not bother trying to make a multiple page article work.



   
 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 
eiusmod

 tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
 veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip 
ex ea

 commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
 velit esse cillum

 
   Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 
eiusmod

   tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
 

 
   Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do 
eiusmod

 

 

  

 
   


--
/Jacob Carlborg


Re: interfacing with C: strings and byte vectors

2016-06-11 Thread ag0aep6g via Digitalmars-d-learn

On 06/11/2016 01:59 PM, yawniek wrote:

i forgot to add a few important points:
- the strings in vec_t are not c strings
- vec_t might contain other data than strings

the original ctor i pasted actually doesn't even work, temporarly i
solved it like

 this(string s) {
 char[] si = cast(char[]) s; //i'm scared


Rightfully so. Casting away immutable shouldn't be done lightly.


 base = si.ptr;
 len = si.length;
 }
is there a better solution than to fearlessly cast away immutability?
i guess i could just make a second vec_t that has immutable base and length
that can be used in D to stay clean, would that be worth anything?


Sure. You wouldn't have to do the risky cast then.


now what i still don't have a proper idea for is how can i create
wrappers for the
methods accepting vec_t in a clean way.
for the vec_t that are allocated in D-land we can state that the C libs
will not modify the data.
there is a lot of functions that accept vec_t.
is there no way to have  strings auto cast to vec_t ?


I don't think so, no. You can make a new type and use alias this to have 
it convert implicitly to vec_t, but you can't enable that for string.


There is no feature to implicitly convert *from* another type, only *to* 
another type.



another way i see is a UDA that generates the wrapper function(s).
other ideas?


Generating the wrappers seems ok to me.

Regarding a UDA: I haven't really used them, but you'd still have to 
iterate over all functions that have the attribute, right? At that 
point, the UDA might be pointless. Can also iterate over everything and 
check if there's a vec_t parameter.


Re: How does one get to the root of a package in ddox?

2016-06-11 Thread Martin Nowak via Digitalmars-d
On 04/16/2016 07:38 AM, Sönke Ludwig wrote:
> Am 15.04.2016 um 22:38 schrieb Andrei Alexandrescu:
>> Say you're on https://dlang.org/library/std/range/primitives.html and
>> try to find your way to https://dlang.org/library/std/range.html.
>>
>> Clicking on "range" in the navigation panel doesn't help - it just
>> collapses/expands the tree branch.

Also the links in the fully qualified name (at the top) should include
links to the package.

Module std.range.primitives
(https://dlang.org/library/std/range/primitives.html)
  range -> std/range.html

Enum member std.range.primitives.isOutputRange
(https://dlang.org/library/std/range/primitives/is_output_range.html)
  range -> std/range.html
  primitives -> std/range/primitives.html



Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread Martin Nowak via Digitalmars-d
On 06/11/2016 02:24 PM, Jonathan M Davis via Digitalmars-d wrote:
> I'm fine with generating the docs with ddox if that works better, but I sure
> hope that we're not going to then change how we're doing the actual
> documenattion in the source files except that if ddox is smart enough that
> we don't need many of the linking macros, then I could see getting rid of
> some of those from the docs.
> 
> I expect to be able to use version(StdDdoc) and all that and have it do the
> right thing with ddox, or the switch to ddox is going to be very annoying
> from the standpoint of maintaining the code. However, I would assume that
> that's all already been sorted out, since we've been generating the docs
> with ddox alongside the normal documentation for some time now.
> 
> - Jonathan M Davis

It already does all of that (uses dmd's json output atm.), and of course
has a ddoc macro interpreter built-in (emulating all of it's quirks).


Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread Martin Nowak via Digitalmars-d
On 06/11/2016 02:31 PM, Jonathan M Davis via Digitalmars-d wrote:
>>> > > But the problem is, people will ask questions on these forums, and
>>> > > likely will not get answers.
>> >
>> > Why not? -- Andrei
> Are _you_ going to spend time going through every single page in the
> documentation, looking to see whether someone asked a question and then
> reply to them if they did?

There is obviously an overview page
https://disqus.com/home/forums/vibe-d/, but I doubt that we'll actively
administrate it.

Also look at ruby-doc, there is literally zero traffic on the comments.
https://disqus.com/home/forum/ruby-doc/.

Maybe it doesn't hurt much and might help to gather good ideas for some
entities.


Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread deed via Digitalmars-d

On Saturday, 11 June 2016 at 12:31:28 UTC, Jonathan M Davis wrote:
I really don't see how it's tractable to have hundreds (if not 
thousands) of pages on dlang.org where someone could ask a 
question.


Wouldn't that be solved by automatically posting the question to 
Learn with a link?


Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread Martin Nowak via Digitalmars-d
On 06/10/2016 07:33 PM, Andrei Alexandrescu wrote:
> I'm a bit bummed about that. I like it. Is my understanding incorrect
> that disqus is fairly established by now?

You need to create an account with a pay-by-data company to even post
something.


Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread Martin Nowak via Digitalmars-d
On 06/11/2016 03:02 PM, Martin Nowak wrote:
> On 06/10/2016 07:33 PM, Andrei Alexandrescu wrote:
>> I'm a bit bummed about that. I like it. Is my understanding incorrect
>> that disqus is fairly established by now?
> 
> You need to create an account with a pay-by-data company to even post
> something.

I'm mostly out at either of those steps.
Adding some simple comments, really doesn't require so much fanciness,
e.g. this
https://code.dawg.eu/reducing-vibed-turnaround-time-part-1-faster-linking.html
runs on a simple sqlite db (https://github.com/posativ/isso).



Re: Parse File at compile time, but not embedded

2016-06-11 Thread ketmar via Digitalmars-d-learn

On Friday, 10 June 2016 at 18:47:59 UTC, Joerg Joergonson wrote:
In any case, this is impossible. D has no such concept as 
"compile-time-only" values, so any usage of a value risks 
embedding it into the binary.

sure, it has.

template ParseData (string text) {
  private static enum Key = "XXXyyyZZZ33322211\n";
  private static enum TRet = "int data = 3;";
  private static enum FRet = "int data = 4;";
  static if (text.length >= Key.length) {
static if (text[0..Key.length] == Key)
  enum ParseData = TRet;
else
  enum ParseData = FRet;
  } else {
enum ParseData = FRet;
  }
}

void main () {
  mixin(ParseData!(import("a")));
}


look, ma, no traces of our secret key in binary! and no traces of 
`int data` declaration too!


Re: Andrei's list of barriers to D adoption

2016-06-11 Thread Chris via Digitalmars-d

On Saturday, 11 June 2016 at 12:44:54 UTC, ketmar wrote:

On Friday, 10 June 2016 at 15:29:01 UTC, Chris wrote:
DScript. Your scripting language already fulfills things that 
were on my wishlist (easy D interop).


hey, both GML and DACS has some of that too! ;-)

VM["print"] = (string s) { writeln(s); };
VM["add"] = (int a, int b) => a+b;

wow, now we can print things from script, and (for some unknown 
reason) use function to add two numbers. with DACS you still 
have to declare function prototypes, but with GML it will "just 
work" (including conversion from internal nan-boxed doubles to 
strings and ints, and back).


GML is somewhat limited, but can be extended, and it almost as 
fast as Lua. DACS, with it's JIT, is sometimes even comparable 
to gcc -O2 (but only sometimes, lol; and LuaJIT still makes it 
look like a snail).


Cool. Maybe we should continue this here

http://forum.dlang.org/thread/njfdch$2627$1...@digitalmars.com


Re: OT – the Javaverse [was Andrei's list of barriers to D adoption]

2016-06-11 Thread Chris via Digitalmars-d

On Friday, 10 June 2016 at 17:09:18 UTC, Russel Winder wrote:

Whatever you read, the writer didn't really know what they were 
talking about. At least not in general, and if they were 
talking of the Javaverse as a whole. Java 8 features such as 
lambda expressions, Streams, method references, etc. are no 
longer even controversial. There is a world-wide activity in 
transforming Java 6 and Java 7 code to Java 8. Yes some of this 
is pull rather than push, and I am sure there are islands of 
intransigence (*). However the bulk of Java programmers will 
eventually get and use the features.


Of course many people have stopped using Java and use Kotlin, 
Ceylon, or Scala (**). The crucial point here is that the 
Javaverse is much, much more than just the Java language.


This only proves my point. This happens in languages that are 
"feature resistant". For years you have to write awkward code[1], 
and once a feature got accepted you have to revise your old code 
and jazz it up. And then of course you get conservative 
programmers who loath changes, they are a direct consequence of 
feature resistance. The more progressive ones turn to other 
languages like Clojure and Kotlin.


All this proves that being feature resistant is not healthy for a 
language.


[1] E.g. Java event listeners, Runnable etc.

(*) Usually people who think Java 5 was a bad move and stick 
with Java

1.4.2.

(**) There are others but these are the main players.





Re: Andrei's list of barriers to D adoption

2016-06-11 Thread ketmar via Digitalmars-d

On Friday, 10 June 2016 at 15:29:01 UTC, Chris wrote:
DScript. Your scripting language already fulfills things that 
were on my wishlist (easy D interop).


hey, both GML and DACS has some of that too! ;-)

VM["print"] = (string s) { writeln(s); };
VM["add"] = (int a, int b) => a+b;

wow, now we can print things from script, and (for some unknown 
reason) use function to add two numbers. with DACS you still have 
to declare function prototypes, but with GML it will "just work" 
(including conversion from internal nan-boxed doubles to strings 
and ints, and back).


GML is somewhat limited, but can be extended, and it almost as 
fast as Lua. DACS, with it's JIT, is sometimes even comparable to 
gcc -O2 (but only sometimes, lol; and LuaJIT still makes it look 
like a snail).


Re: We want to start the 'Programming In D 'in Chinese, do you have any good suggestions?

2016-06-11 Thread mogu via Digitalmars-d

On Saturday, 11 June 2016 at 03:19:52 UTC, Meta wrote:

On Saturday, 11 June 2016 at 00:38:24 UTC, mogu wrote:

编 可以是 编写 的缩写
编 could be short for 编写(write)
程 可以是 程序 的缩写
程 could be short for 程序(program)
编程 即 编写程序
So 编程 means writing programs aka programming.


谢谢你纠正我,说中文不容易的。


哪里哪里,中文的确很难,但同时也是最有魅力的语言之一。


Re: [OT] Re: Andrei's list of barriers to D adoption

2016-06-11 Thread ketmar via Digitalmars-d

On Friday, 10 June 2016 at 15:35:32 UTC, jmh530 wrote:

On Friday, 10 June 2016 at 15:14:02 UTC, ketmar wrote:


1. this is heavily OT. ;-)


I didn't forget to mark it! :-)

2. you may take a look at my gml engine. it has clearly 
separated language parser and AST builder (gaem.parser), and 
AST->VM compiler (gaem.runner/compiler.d).


I couldn't for the life of me find a link to this.


sorry. Wyatt kindly fixed that for me. ;-)

also, you can replace code generation in compiler with direct 
execution, and you will get AST-based interpreter. just create a 
new AA with local variables on NodeFCall (this will serve as 
"stack frame"), and make `compileExpr` return value instead of 
stack slot index. then it is as easy as:


  (NodeBinarySub n) => compileExpr(n.el)-compileExpr(n.er);

and so on. also, fix `compileVarAccess` and `compileVarStore` to 
use your "stack frame" AA.


this whole bussines is not hard at all. i'd say it is easier than 
many other programming tasks.


Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread Jonathan M Davis via Digitalmars-d
On Saturday, June 11, 2016 08:45:08 Andrei Alexandrescu via Digitalmars-d 
wrote:
> On 6/10/16 5:46 PM, Steven Schveighoffer wrote:
> > On 6/10/16 1:33 PM, Andrei Alexandrescu wrote:
> >> On 6/10/16 3:17 PM, Martin Nowak wrote:
> >>> I'd want to disable or replace discourse before we make it our official
> >>> documentation. We could easily self-host some commenting functionality
> >>> if deemed necessary, but adding an unmaintained communication channel
> >>> isn't the best idea IMO.
> >>
> >> I'm a bit bummed about that. I like it. Is my understanding incorrect
> >> that disqus is fairly established by now? I see it on a bunch of legit
> >> sites, and it seems to add value to those as it could add to ours.
> >
> > I can see a good reason to have a disqus forum for each page, as I have
> > found tremendous value from the php.net forums on each symbol (with
> > common tricks to use with the given function).
> >
> > But the problem is, people will ask questions on these forums, and
> > likely will not get answers.
>
> Why not? -- Andrei

Are _you_ going to spend time going through every single page in the
documentation, looking to see whether someone asked a question and then
reply to them if they did? I'm sure not doing that, and I doubt that many of
us will be. I, for one, rarely even look at the online documentation. I
usually just look at the source code locally. And even if I did look at the
online docs on a regular basis, I'd only see comments on the symbols that I
happened to be looking up, and even then, only if I took the extra time to
look and see whether there were comments. I sure wouldn't be going to the
docs just to see whether someone asked a question - especially when there
so many pages to search through.

I really don't see how it's tractable to have hundreds (if not thousands) of
pages on dlang.org where someone could ask a question. They will
occasionally get an answer, but it's more likely to be from someone else who
doesn't know much than it is from anyone who could give a good answer, since
the folks who are most likely to give good answers won't even be looking.
What's far more likely is that folks will get frustrated, because they asked
a question on the documentation page for a symbol and never got an answer -
or if they did, it was weeks or months later.

- Jonathan M Davis



Re: Fixed date to move to ddox for Phobos documentation

2016-06-11 Thread Jonathan M Davis via Digitalmars-d
On Saturday, June 11, 2016 08:48:53 Andrei Alexandrescu via Digitalmars-d 
wrote:
> On 6/11/16 5:16 AM, Vladimir Panteleev wrote:
> > On Friday, 10 June 2016 at 17:33:01 UTC, Andrei Alexandrescu wrote:
> >> I should add that it would be valuable to keep the ddoc build as well.
> >
> > We need DDoc anyway for the website itself, as well as formats other
> > than the website (e.g. CHM and HTML files distributed with the
> > compiler), so it's not going away.
>
> I mean ddoc for the standard library code. -- Andrei

I'm fine with generating the docs with ddox if that works better, but I sure
hope that we're not going to then change how we're doing the actual
documenattion in the source files except that if ddox is smart enough that
we don't need many of the linking macros, then I could see getting rid of
some of those from the docs.

I expect to be able to use version(StdDdoc) and all that and have it do the
right thing with ddox, or the switch to ddox is going to be very annoying
from the standpoint of maintaining the code. However, I would assume that
that's all already been sorted out, since we've been generating the docs
with ddox alongside the normal documentation for some time now.

- Jonathan M Davis



Re: [OT] Re: Andrei's list of barriers to D adoption

2016-06-11 Thread Jonathan M Davis via Digitalmars-d
On Saturday, June 11, 2016 08:06:21 Ola Fosheim Grøstad via Digitalmars-d 
wrote:
> On Friday, 10 June 2016 at 18:59:02 UTC, Jonathan M Davis wrote:
> > then as it is later. In some ways, it would actually be very
> > beneficial to actually go back to school to study that stuff
> > after having programmed professionally for a while, but that's
> > a pain to pull off time-wise, and the classes aren't really
> > designed with that in mind anyway.
>
> I am definitively considering it, maybe on some topics that I've
> read on my own, to fill in the missing bits. Or topics that has
> had some advances since the 90s. It wouldn't be too much of a
> pain as I could get there in 15 minutes on a bike, so it would
> just be exercise. I believe lectures at the University of Oslo
> are open to the public if there is enough space, and the fee at
> the University of Oslo is at $100/semester so the threshold for
> signing up is low. And I don't even have to do the exam, which
> probably makes it more enjoyable.

LOL. 10x that would be cheap in the US, and I don't think that your average
school will let folks sit in on courses (though some will). For your average
college in the US, I would only expect anyone to take classes if they're
actually working towards a degree, though I'm sure that there are exceptions
in some places.

> > world.  I don't envy teachers having to figure out how to teach
> > basic programming concepts.
>
> Yes,  some people are simply never going to be able to do
> programming well... I'm talking having trouble reading code with
> basic input - output loops (not even writing it) after having it
> carefully explained to them many times. With some students you
> know they will never be able to pass the exam after the first few
> sessions. But you cannot tell them to quit... so you have to
> encourage them, basically encouraging them to strive towards a
> certain failure. That's frustrating.
>
> Educational institutions should probably have an aptitude test.
> At the entry level courses maybe 30% are never going to be able
> to become even mediocre programmers.

It works better when the school itself is really hard to get into. For
instance, my dad went to MIT, and according to him, you usually don't have
much of a need for weeder courses there, because it was already hard enough
to get into the school that folks who can't hack it won't even be there -
and it's an engineering school, so you're typically going to get very smart,
well-prepared students who want to do engineering.

Contrast that with schools where almost anyone can get in, and there are
always problems with folks entering engineering programs where they can't
hack it - especially computer science, since it doesn't obviously involve
the really hard math and science that would scare many of those folks away.
You freqeuntly either end up with the school trying to weed out a lot of
folks up front by having very hard beginning courses or making their
beginning classes easy in an attempt to make it so that everyone has a
chance, though I think that tends to just delay the inevitable for many
students.

I can appreciate wanting to give everyone a chance, and I'm sure that there
are folks who have a hard time at first who get it later, but many folks
just don't seem to think the right way to be able to program. So, I agree
that it would be nice if there were some sort of aptitude test up front that
at least indicated whether you were likely have a very hard time with
programming. But I don't think that I've ever heard of any schools doing
anything like that (though obviously, some could be, and I just haven't
heard of it). And I don't know how you would even go about making such a
test, though I expect that there are computer science professors out there
who would.

- Jonathan M Davis




[Issue 16149] foreach_reverse can't handle index variable of type int

2016-06-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16149

--- Comment #4 from Ketmar Dark  ---
while deep inside of me i think the same thing, it still sounds wrong, i
believe. if we'll enable such use of `foreach_reverse`, this will be the only
exception in D where it allows assignment of `ulong` to `int` without explicit
cast. of course, this will allow me to write portable code without `cast(uint)`
on each `.length` usage, but... but i'd rather keep writing casts. ;-)

--


Re: interfacing with C: strings and byte vectors

2016-06-11 Thread yawniek via Digitalmars-d-learn

On Saturday, 11 June 2016 at 10:26:17 UTC, Mike Parker wrote:

On Saturday, 11 June 2016 at 09:32:54 UTC, yawniek wrote:



thanks mike for the in depth answer.
i forgot to add a few important points:
- the strings in vec_t are not c strings
- vec_t might contain other data than strings

the original ctor i pasted actually doesn't even work, temporarly 
i solved it like


this(string s) {
char[] si = cast(char[]) s; //i'm scared
base = si.ptr;
len = si.length;
}
is there a better solution than to fearlessly cast away 
immutability?
i guess i could just make a second vec_t that has immutable base 
and length

that can be used in D to stay clean, would that be worth anything?

now what i still don't have a proper idea for is how can i create 
wrappers for the

methods accepting vec_t in a clean way.
for the vec_t that are allocated in D-land we can state that the 
C libs will not modify the data.

there is a lot of functions that accept vec_t.
is there no way to have  strings auto cast to vec_t ?
another way i see is a UDA that generates the wrapper function(s).
other ideas?


  1   2   >