Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-18 Thread ddos via Digitalmars-d-learn
thank you :) works now

[Code Example for Beginners (like me)] Sockets with Fibers

2015-09-18 Thread ddos via Digitalmars-d-learn
hello! yesterday i got curious about how fibers work, and if the can be used as a replacement in network programming. so i started hacking a small example together, which is hopefully useful to other D beginners too :) http://pastebin.com/Xg4GJbKE

bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread ddos via Digitalmars-d-learn
http://pastebin.com/fknwgjtz i tried to call fibers in a loop forever, to multiplex some networking client worker fibers and a listener fiber it seems to work correctly with for(int i=0;i<1;) with while(true) i get: C:\dev\server_client>dub Building server_client ~master configuration

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread ddos via Digitalmars-d-learn
using DMD32 D Compiler v2.068.0 on windows x64

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread ddos via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:43:02 UTC, H. S. Teoh wrote: On Thu, Sep 17, 2015 at 07:32:13PM +, ddos via Digitalmars-d-learn wrote: http://pastebin.com/fknwgjtz i tried to call fibers in a loop forever, to multiplex some networking client worker fibers and a listener fiber

Re: bug? for(int i=0;i<1;) vs while(true)

2015-09-17 Thread ddos via Digitalmars-d-learn
On Thursday, 17 September 2015 at 19:35:05 UTC, Adam D. Ruppe wrote: What's there? Anything after an endless loop is potentially unreachable and dub treats warnings as errors. i see, thx

Thrift

2015-09-16 Thread ddos via Digitalmars-d-learn
Looking for a RPC library, thrift looked promising, but i can't even compile the simple example given here https://thrift.apache.org/tutorial/d to compile i've 1. copied the thrift/lib/d/src/thrift folder to my source directory 2. copied the generated sources ( tutorial and share folder )

How do i sanitize a string for database query?

2015-07-21 Thread ddos via Digitalmars-d-learn
How do i sanitize a string for database query? Is there some builtin function? thx :)

Re: How do i sanitize a string for database query?

2015-07-21 Thread ddos via Digitalmars-d-learn
thx

Re: How do i sanitize a string for database query?

2015-07-21 Thread ddos via Digitalmars-d-learn
On Tuesday, 21 July 2015 at 17:58:55 UTC, Gary Willoughby wrote: On Tuesday, 21 July 2015 at 17:23:30 UTC, ddos wrote: How do i sanitize a string for database query? Is there some builtin function? thx :) Use prepared statements instead. https://en.wikipedia.org/wiki/Prepared_statement

Re: function shadowed

2015-04-09 Thread ddos via Digitalmars-d-learn
On Thursday, 9 April 2015 at 05:34:09 UTC, anonymous wrote: On Wednesday, 8 April 2015 at 22:53:39 UTC, ddos wrote: why not just make it callable without the alias? It's to prevent hijacking: http://dlang.org/hijack.html thx for the article!

function shadowed

2015-04-08 Thread ddos via Digitalmars-d-learn
i got two modules opengvg.d and vg.d vg.d contains calls to external c functions openvg.d should wrap and simplify some of those calls in openvg.d i make public import of submodule vg.d such that if openvg.d is imported the functions in vg.d can be called, this works as intended. but as soon

Re: function shadowed

2015-04-08 Thread ddos via Digitalmars-d-learn
On Wednesday, 8 April 2015 at 17:48:36 UTC, anonymous wrote: On Wednesday, 8 April 2015 at 12:05:00 UTC, ddos wrote: vg.d: module vg; extern (C) void vgSetParameterfv(VGHandle object, VGint paramType, VGint count, VGfloat *values); openvg.d module openvg; public import vg; void

Re: Troubles with devisualization/window

2015-04-06 Thread ddos via Digitalmars-d-learn
On Monday, 6 April 2015 at 22:56:15 UTC, Rikki Cattermole wrote: On 7/04/2015 10:34 a.m., ddos wrote: it's getting warmer, window doesnt freeze anymore and opengl calls don't crash the window, but it's still all white after calling glClearColor(1,0,1,1); glClear(GL_COLOR_BUFFER_BIT |

Re: Troubles with devisualization/window

2015-04-06 Thread ddos via Digitalmars-d-learn
it's getting warmer, window doesnt freeze anymore and opengl calls don't crash the window, but it's still all white after calling glClearColor(1,0,1,1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); updated src:

Troubles with devisualization/window

2015-04-06 Thread ddos via Digitalmars-d-learn
Hi! i'm trying to get devisualization/window [1] working with some simple opengl calls. I have created a windows with opengl context using Window window = new Window(800, 600, My window!w, WindowContextType.Opengl); If i run writeln(type: , context.type); writeln(toolkit version: ,

Re: How to generate D binding with SWIG?

2015-04-06 Thread ddos via Digitalmars-d-learn
On Monday, 6 April 2015 at 15:46:32 UTC, Jeremy DeHaan wrote: Do you even need to use swig? It looks like gdal has a C interface. I think that htod would be what you're looking for http://dlang.org/htod.html +1 for htod if there is a c interface!

linking C library with D, creating a OpenVG D port

2015-04-03 Thread ddos via Digitalmars-d-learn
hi! i'm trying to run OpenVG examples in D. So far i have compiled ShivaVG (an implementation of OpenVG standard) in C++ and created a shared library. Now i'd like to link my OpenVG.lib with a D program. (the library was compiled with msvc2013x86, i'd like to avoid switching compiler) to

Re: linking C library with D, creating a OpenVG D port

2015-04-03 Thread ddos via Digitalmars-d-learn
progress ... i think in some forum posts i've read 64bit dmd uses a differnt linker which supports coff atleast i can now link my app in 64bit mode without errors dmd -m64 source/app.d OpenVG.lib also an exported test function prints to stdout, so my problem is solved for x64 :) if anyone

Re: linking C library with D, creating a OpenVG D port

2015-04-03 Thread ddos via Digitalmars-d-learn
thanks Rikki! also if anyone is interested in OpenVG i have now a running demo in D based on ShivaVG and derelict GLFW3, it's not beautiful but it works :D http://imgur.com/ZH0kD0q i'm pretty impressed how painless the compiling and interfacing to C was actually :) +1 for D

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread ddos via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 12:18:15 UTC, Vlasov Roman wrote: On Tuesday, 10 February 2015 at 11:55:43 UTC, Daniel Kozák wrote: V Tue, 10 Feb 2015 11:44:09 + Vlasov Roman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Tuesday, 10 February 2015 at 11:32:32 UTC,

Re: generate an array of 100 uniform distributed numbers

2015-01-22 Thread ddos via Digitalmars-d-learn
thx, alot :) works as intended iota(0,100).map!(v = uniform(0.0,1.0)).writeln;

generate an array of 100 uniform distributed numbers

2015-01-22 Thread ddos via Digitalmars-d-learn
hi guys, firstly this has no direct application, i'm just playing around and learning i want to create 100 uniform distributed numbers and print them my first attempt, just written by intuition: [0 .. 100].map!(v = uniform(0.0, 1.0).writeln); i found out i can't write [0 .. 100] to define a

histogram [last thread contd]

2015-01-22 Thread ddos via Digitalmars-d-learn
i wrote a histogram algorithm i tried to write it the shortest and most D way possible ... please tell me if you see any simpler way of doing it is there a simpler way of getting the minimum of a range? (by intuition i tried range.min) auto numbers = iota(0,1).map!(_ =

Trouble with std.Variant

2014-09-18 Thread ddos via Digitalmars-d-learn
struct Vec2 { float[2] vec; public float length() { return sqrt(vec[0]*vec[0]+vec[1]*vec[1]); } } int main(string[] argv) { Vec2 test; Variant v = test; return 0; }

Re: Trouble with std.Variant

2014-09-18 Thread ddos via Digitalmars-d-learn
The following code fails because Vec2.length() does not return int ... so Variant is only usable with types that do not have a method with name length() ?? i'm confused On Thursday, 18 September 2014 at 21:03:47 UTC, ddos wrote: struct Vec2 { float[2] vec; public float

iterate traits ?

2014-08-19 Thread ddos via Digitalmars-d-learn
Hi, i'm trying to create a dynamic vertex format for opengl, defined at compiletime by a struct e.g. struct Vertex {float[3] position, float[3] normal} i can get the name of all members with this: auto b = [ __traits(allMembers, VertexType) ]; but i can't iterate them at compiletime because

Re: iterate traits ?

2014-08-19 Thread ddos via Digitalmars-d-learn
On Tuesday, 19 August 2014 at 18:25:24 UTC, Justin Whear wrote: On Tue, 19 Aug 2014 18:15:33 +, ddos wrote: since i need to setup vertexpointers for opengl at runtime my next question? - is it possible to evaluate the traits also at runtime? but i'd also like to know how i can iterate

static array in templated struct/class

2014-08-05 Thread ddos via Digitalmars-d-learn
alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); class TVector(T,int n) { T[n] val; ... TVector as class does work as expected, as a struct i get the following errors, but why? struct Vector.TVector!(float, 4).TVector no size yet for forward reference struct

Re: static array in templated struct/class

2014-08-05 Thread ddos via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 19:13:31 UTC, Marc Schütz wrote: On Tuesday, 5 August 2014 at 18:36:35 UTC, ddos wrote: alias Vec4f = TVector!(float,4); alias Vec3f = TVector!(float,3); class TVector(T,int n) { T[n] val; ... TVector as class does work as expected, as a struct i get the

Re: static array in templated struct/class

2014-08-05 Thread ddos via Digitalmars-d-learn
i wasn't intentionally creating a functionpointer, i just liked the syntax x3 ... but i guess i should read into it now :) thx for you help ! On Tuesday, 5 August 2014 at 19:51:33 UTC, Philippe Sigaud via Digitalmars-d-learn wrote: http://pastebin.com/34sbffSa Your problem comes from

range foreach lambda

2014-07-17 Thread ddos via Digitalmars-d-learn
for example i have an array int[] a = [1,2,3,4,5]; and a function auto twice = function (int x) = x * 2; how can i apply the function to each element in a without using a forloop? - is there a function to do this? a.foreach(x = x * 2); a == [2,4,6,8,10]

Re: range foreach lambda

2014-07-17 Thread ddos via Digitalmars-d-learn
thx alot! its not important to me that the function is not evaluated in place since you gave me such a straight answer i'd like to bother you with another question :) for example i have now two ranges: immutable a = [1,2,3,4]; immutable b = [2,3,4,5]; how do i add the elements in a and b

templates

2014-07-17 Thread ddos via Digitalmars-d-learn
for example and learning purpose i want to create an arithmetic vector class. for a vector of arbitrary size i defined my opBinary like this: class TVector(T,int n) { T[n] val; . TVector opBinary(string op)(TVector rhs) { auto tmp =