Re: UTF-16 endianess

2016-01-30 Thread Marek Janukowicz via Digitalmars-d-learn
general. > > What I mean is that you can annotate your code with version statements like: > > version(LittleEndian) > { > // perform the byteswap > ... > } > > so your code is portable to BigEndian systems (where you would not want > to byte swap). That's a good point, thanks. -- Marek Janukowicz

Re: UTF-16 endianess

2016-01-29 Thread Marek Janukowicz via Digitalmars-d-learn
compile the correct code. This solution is of no use to me as I don't want to change the endianess in general. -- Marek Janukowicz

UTF-16 endianess

2016-01-29 Thread Marek Janukowicz via Digitalmars-d-learn
writefln( "proper: %s, reverse: %s", cast(wchar[])properOrder, cast(wchar[])reverseOrder ); } output: proper: 䈁, reverse: ł Is there anything I should know about UTF endianess? -- Marek Janukowicz

Re: multiline string literal with CRLF

2015-08-26 Thread Marek Janukowicz via Digitalmars-d-learn
\nworld" > > Or if you want to include the \n verbatim: > > "Hello\r > world" Thanks, this works - I don't know how I did it the first time, because I definitely tried that and failed. The other solution by Adam also works - thanks. -- Marek Janukowicz

multiline string literal with CRLF

2015-08-26 Thread Marek Janukowicz via Digitalmars-d-learn
Is there any way to input such a literal? Both `...` and q"EOS...EOS" do not allow escape sequences. I'm on Linux, but I need precisely CRLF, not just \n. -- Marek Janukowicz

std.concurrency.send problems with immutable

2015-08-07 Thread Marek Janukowicz via Digitalmars-d-learn
b") it compiles fine. Is this another bug or am I missing something? -- Marek Janukowicz

Syntax: how to return shared?

2015-08-07 Thread Marek Janukowicz via Digitalmars-d-learn
How do I mark a function as returning shared object? This won't compile: shared Foo foo () { ... } This does, but looks somewhat awkward to me: shared (shared Foo) foo () { ... } -- Marek Janukowicz

Subclasses in std.concurrency.receive pattern match

2015-07-31 Thread Marek Janukowicz via Digitalmars-d-learn
ceive than some type of multiple "cast & check" clauses. On a related matter - how does GC behave on such class objects (created in one thread, casted to shared and handled by another thread)? Won't the object get possibly GC'ed when it runs out of scope in origin thread

Re: Console widget library

2013-10-23 Thread Marek Janukowicz
or > linked me to it I played briefly and thought it was pretty boss. Wow, that was quick :) D-tui looks like something worth taking a look - thanks. -- Marek Janukowicz

Console widget library

2013-10-23 Thread Marek Janukowicz
Is there any console widget library available for D? I mean something like high level library on top of ncurses. Maybe anyone took a shot at libyui wrapper? -- Marek Janukowicz

Re: Compile time data structure

2013-09-19 Thread Marek Janukowicz
Ali Çehreli wrote: > On 09/16/2013 01:24 PM, Marek Janukowicz wrote: > > >static string[string] columns () { > // ... > >} > > Although the function itself is static, it returns a dynamic value. > > > foreach( attr, col; columns() ) { >

Re: Mixin namespace ambiguity?

2013-09-16 Thread Marek Janukowicz
refore, even from main.d, the two mixed-in functions 'a' have > same closeness, and the call is ambiguous because they have > exactly same signature. -- Marek Janukowicz

Re: Compile time data structure

2013-09-16 Thread Marek Janukowicz
foreach( attr, col; columns() ) { __traits(getMember, me, attr) = typeof(__traits(getMember, me, attr)).init; } return me; } } class ExampleModel { @Attr() int id; @Attr( "field_id" ) int fieldId; mixin Model; } void main () { ExampleModel ex = ExampleModel.ini

Compile time data structure

2013-09-15 Thread Marek Janukowicz
any other way for columns() method to return a structure that could be further evaluated at compile time? -- Marek Janukowicz

Mixin namespace ambiguity?

2013-09-15 Thread Marek Janukowicz
oesn't when it's a mixed-in function with no mixin identifier. My first impression is that either both line 1 and 2 should work or neither of them should work. It's no surprise to me that line 3 works (and it matches the documentation), so I basically included that just for reference. -- Marek Janukowicz

Re: dmd memory usage/static lib/algorithm bug?

2013-08-28 Thread Marek Janukowicz
H. S. Teoh wrote: > On Thu, Aug 29, 2013 at 12:45:05AM +0200, Marek Janukowicz wrote: >> H. S. Teoh wrote: > [...] >> > Oh, and BTW, are you on Linux 32-bit or 64-bit? Don't know if that >> > makes a difference, but just in case. >> >> 64-bit > [

Re: dmd memory usage/static lib/algorithm bug?

2013-08-28 Thread Marek Janukowicz
H. S. Teoh wrote: > On Wed, Aug 28, 2013 at 11:02:17PM +0200, Marek Janukowicz wrote: >> I was finally able to create simple test case that probably reproduces >> the bug (probably, because the stack trace is completely different, >> but the code that is there is similar). T

Re: dmd memory usage/static lib/algorithm bug?

2013-08-28 Thread Marek Janukowicz
ced exactly the same way on 3 machines I tried. -- Marek Janukowicz

dmd memory usage/static lib/algorithm bug?

2013-08-28 Thread Marek Janukowicz
- how can I include a static library with my project? I can compile algorithm.d to a static lib, but how do I include this one explicitly with my project while the rest of Phobos should be taken from the stock libphobos2.a ? - any other ideas how to solve my problems on any level? -- Marek Janukowicz

Re: A template returning a delegate [was: template returning delegate]

2013-08-21 Thread Marek Janukowicz
Marek Janukowicz wrote: > Yet another problem I just spotted: > > --- > > import std.stdio, std.string; > > struct Val { > int i; > byte b; > } > > template templ( T ) { > >auto templ (T obj, string name) { &g

Re: A template returning a delegate [was: template returning delegate]

2013-08-21 Thread Marek Janukowicz
After I sent the message I realized my limited English knowledge made me make a subject that actually had quite a different meaning than I intended :) Now it's hopefully fine or at least less ambiguous. -- Marek Janukowicz

template returning delegate

2013-08-21 Thread Marek Janukowicz
"Version A" (which means I return the result directly instead of returning the delegate I get expected results: $ dmd -run member.d i i: 1 $ dmd -run member.d b b: 2 Also no ld warning in this case. -- Marek Janukowicz

Getting member by name in runtime

2013-08-21 Thread Marek Janukowicz
name) ... } Of course this looks suboptimal as I run the loop until I find a member matching the name. Is there any better way to do this? -- Marek Janukowicz

Re: ORM libraries out there

2013-08-20 Thread Marek Janukowicz
Dicebot wrote: > On Tuesday, 20 August 2013 at 15:47:42 UTC, Marek Janukowicz > wrote: >> Does anyone know about any decent ORM (Object Relational >> Mapping or whatever >> it stands for) libraries for D? If someone actually tried some >> of those it >

Re: Typeof woes

2013-08-20 Thread Marek Janukowicz
um Smth { A }; void list () { foreach( s; __traits(derivedMembers, typeof(this))) { static if (is (typeof(typeof(typeof(__traits(getMember, this, s == int)) { writefln ("%s is int", s ); } } } } void main () { A a = new A(); a.list(); } -- Marek Janukowicz

Re: Typeof woes

2013-08-20 Thread Marek Janukowicz
H. S. Teoh wrote: > On Wed, Aug 21, 2013 at 01:42:11AM +0200, Marek Janukowicz wrote: >> Given this short program: >> >> class A { >> >> int i; >> //enum Smth { X }; >> >> void list () { >> foreach( s; __traits(derivedMember

Typeof woes

2013-08-20 Thread Marek Janukowicz
ts(getMember, this, s))" might be used eg. in static if even for enums. Is this a bug or do I miss something (again)? -- Marek Janukowicz

Re: Struct - static initialization "on-the-fly"

2013-08-20 Thread Marek Janukowicz
Ali Çehreli wrote: > On 08/20/2013 03:47 PM, Marek Janukowicz wrote:> In this program: > > > > import std.stdio, std.json; > > > > void main () { > >JSONValue jsonSet; > >jsonSet.type = JSON_TYPE.OBJECT; > >JSONValue a = { type

Struct - static initialization "on-the-fly"

2013-08-20 Thread Marek Janukowicz
ires two lines instead of one and I have many such elements to set. I can't initialize all members of JSONValue, because there are many and I only need those two. -- Marek Janukowicz

ORM libraries out there

2013-08-20 Thread Marek Janukowicz
Does anyone know about any decent ORM (Object Relational Mapping or whatever it stands for) libraries for D? If someone actually tried some of those it would be a big plus. -- Marek Janukowicz

Re: Templated structs / variant values

2013-08-20 Thread Marek Janukowicz
Dicebot wrote: > On Tuesday, 20 August 2013 at 11:22:35 UTC, Marek Janukowicz > wrote: >>> if(is(type == Setting!U, U...)) >> >> This is not enough for me - I have many instantiations of >> Setting struct >> template and I need all of them, regardless of

Re: Templated structs / variant values

2013-08-20 Thread Marek Janukowicz
ing Setting. > > if(is(type == Setting!U, U...)) This is not enough for me - I have many instantiations of Setting struct template and I need all of them, regardless of parameters they were instantiated with. -- Marek Janukowicz

Re: Templated structs / variant values

2013-08-19 Thread Marek Janukowicz
H. S. Teoh wrote: > On Tue, Aug 20, 2013 at 01:09:16AM +0200, Marek Janukowicz wrote: >> Jacob Carlborg wrote: > [...] >> > In "settings" you should be able to: >> > >> > 1. Iterate over all fields of the type Setting using >> > __tratis

Re: Templated structs / variant values

2013-08-19 Thread Marek Janukowicz
Jacob Carlborg wrote: > On 2013-08-15 00:29, Marek Janukowicz wrote: >> I need to have a generalized "settings" functionality that should work >> like this: >> * I need to be able to add this to a class >> * each setting has its name, description, type and

Templated structs / variant values

2013-08-14 Thread Marek Janukowicz
escription above is a bit messy (it's quite late now), but hopefully you can get the picture. Any ideas how to approach this problem? -- Marek Janukowicz

Re: Namespace clash between modules

2013-08-13 Thread Marek Janukowicz
k the list first, hoping there might be some simple solution I don't know about. -- Marek Janukowicz

Namespace clash between modules

2013-08-13 Thread Marek Janukowicz
us name clash on the variable name "logger". I have many modules where I want to use logging, so things like static import are not an option. Is there any pattern I could use here? -- Marek Janukowicz

Re: Is it possible using reflection or similar to extract only public method names from classes?

2013-08-06 Thread Marek Janukowicz
them. See traits: http://dlang.org/traits.html Look for: getProtection, getVirtualFunctions, getVirtualMethods. -- Marek Janukowicz

Re: Getting number of messages in MessageBox

2013-08-06 Thread Marek Janukowicz
dennis luehring wrote: > the question is do the published counter then needs locking - and make > it slow for all - just for beeing getable? Good point - but I believe the code operating on the counter is synchronized already, so synchronized getter would not really slow things down. --

Re: Getting number of messages in MessageBox

2013-08-06 Thread Marek Janukowicz
vate... or should I file a bug (or rather feature request) about it? -- Marek Janukowicz

Re: Getting number of messages in MessageBox

2013-08-05 Thread Marek Janukowicz
Ali Çehreli wrote: > On 08/05/2013 04:18 PM, Marek Janukowicz wrote: >> I'm using std.concurrency message passing and I'd like to check which >> thread might be a bottleneck. The easiest would be check number of >> messages piled up for each of them, but I could n

Getting number of messages in MessageBox

2013-08-05 Thread Marek Janukowicz
I'm using std.concurrency message passing and I'd like to check which thread might be a bottleneck. The easiest would be check number of messages piled up for each of them, but I could not find a way to do that. Is it possible? Every detail about MessageBox seems to be hidden...

Re: Socket.select interrupted system call because of GC

2013-08-04 Thread Marek Janukowicz
is not being restarted, but you need to handle that yourself. -- Marek Janukowicz

Re: String representation of enum value

2013-08-04 Thread Marek Janukowicz
Robik wrote: > I think std.conv.to!string is what are you looking for :) > > http://dpaste.dzfl.pl/e1c38f8f Wow, so simple, thanks -- Marek Janukowicz

String representation of enum value

2013-08-04 Thread Marek Janukowicz
et string a "UNKNOWN". Of course I'd like to use something more consise and elegant than a switch :) -- Marek Janukowicz

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread Marek Janukowicz
ill run to completion before the program > terminates normally (see Thread.isDaemon). It's really nice to have some chat about the correctness of example code snippets, but can anyone help me with the original issue? :) -- Marek Janukowicz

Re: Socket.select interrupted system call because of GC

2013-08-03 Thread Marek Janukowicz
dennis luehring wrote: > Am 03.08.2013 08:38, schrieb Marek Janukowicz: >> void main () >> { >>writefln( "sa: %d", SA_RESTART ); >>(new Thread (&serverfunc)).start(); >>(new Thread (&clientfunc)).start(); >> } > > i h

Socket.select interrupted system call because of GC

2013-08-02 Thread Marek Janukowicz
ew Thread (&serverfunc)).start(); (new Thread (&clientfunc)).start(); } If I disable GC the problem does not occur. Any idea how to solve this? -- Marek Janukowicz

Thread-local copy of data structure

2013-07-30 Thread Marek Janukowicz
main copy. Is it possible to somehow create copy automatically when creating a task, or do I need to create it myself? If the latter - is there anything in std lib that helps with creation of deep clones or an I completely on my own? -- Marek Janukowicz

Re: mixin string to template - advice needed

2013-07-27 Thread Marek Janukowicz
implement with a regular template. -- Marek Janukowicz

mixin string to template - advice needed

2013-07-26 Thread Marek Janukowicz
Hello I have a repetitive piece of code that I'm now generating using string mixin. I humbly ask someone more skilled with D to review the code and help me transforming it into regular template mixin (as I would gladly avoid string mixin if possible). string flaggedAttr(string type, string n