Compiler Error while using Validation in the hunt-framework

2022-10-19 Thread Roman Funk via Digitalmars-d-learn
this compiler: DMD64 D Compiler v2.100.2 under Linux. My current D knowledge is not sufficient to fix the bug. No idea how the annotation and mixin templates work together here. I didn't find any documentation, how to write custom annotations. Can somebody give me a hint? BR Roman

Re: Reading data from the network without knowing the size of the buffer that is coming

2019-03-21 Thread Roman Sztergbaum via Digitalmars-d-learn
On Thursday, 21 March 2019 at 18:27:56 UTC, Andre Pany wrote: On Thursday, 21 March 2019 at 16:54:01 UTC, Roman Sztergbaum wrote: [...] I am also not a expert in this area. If the message received from the server exceeds 256 bytes, you have to call the receive message several times until

Reading data from the network without knowing the size of the buffer that is coming

2019-03-21 Thread Roman Sztergbaum via Digitalmars-d-learn
Hello ! in my function : ```D private config_load_answer load_config(string[] args) in(args !is null, "args cannot be null") in(args.length == 2, "need 1 arguments") out(r; r.state == "SUCCESS", "load_config should succeed") out(r; !r.config_name.empty, "config_name should not

Re: is collectException working for every exceptions ?

2019-03-19 Thread Roman Sztergbaum via Digitalmars-d-learn
On Tuesday, 19 March 2019 at 00:07:44 UTC, Ali Çehreli wrote: On 03/18/2019 11:54 AM, Roman Sztergbaum wrote: > [...] with the > [...] Andre Pany has already explained. Otherwise, I was going to say "collectException can collect Exceptions, not exceptions." ;) [...] Hel

Re: is collectException working for every exceptions ?

2019-03-18 Thread Roman Sztergbaum via Digitalmars-d-learn
On Monday, 18 March 2019 at 18:54:22 UTC, Roman Sztergbaum wrote: Hello as the subject say i'm asking this question because with the following code [...] I'm asking myself if it's usefull to write unittest with contract programming also, but this is another subject i think

is collectException working for every exceptions ?

2019-03-18 Thread Roman Sztergbaum via Digitalmars-d-learn
Hello as the subject say i'm asking this question because with the following code ``` private config_create_answer create_config(string[] args) in { assert(args !is null, "args cannot be null"); assert(args.length == 2, "need 1 arguments"); } out (r) {

Re: D outperformed by C++, what am I doing wrong?

2017-08-13 Thread Roman Hargrave via Digitalmars-d-learn
On Sunday, 13 August 2017 at 06:09:39 UTC, amfvcg wrote: Hi all, I'm solving below task: given container T and value R return sum of R-ranges over T. An example: input : T=[1,1,1] R=2 output : [2, 1] input : T=[1,2,3] R=1 output : [1,2,3] (see dlang unittests for more examples) Below c++

Building with dub fails on Ubuntu 16.10.

2016-09-10 Thread Vlasov Roman via Digitalmars-d-learn
Hello, guys. I tried to build HelloWorld with dub, but i got strange linker error: Performing "debug" build using dmd for x86_64. test ~master: building configuration "application"... Linking... /usr/bin/ld:

Re: Error: module ctype is in file 'std/ctype.d' which cannot be read - when running dmd

2016-06-24 Thread Roman via Digitalmars-d-learn
On Friday, 24 June 2016 at 21:06:30 UTC, cym13 wrote: On Friday, 24 June 2016 at 21:01:11 UTC, Roman wrote: I should probably add that only importing std.ctype causes the error. I have a bunch of other imports: import std.stdio, std.string, std.algorithm, std.conv, std.ctype, std.regex

Re: Error: module ctype is in file 'std/ctype.d' which cannot be read - when running dmd

2016-06-24 Thread Roman via Digitalmars-d-learn
I should probably add that only importing std.ctype causes the error. I have a bunch of other imports: import std.stdio, std.string, std.algorithm, std.conv, std.ctype, std.regex, std.range; If I remove std.ctype, it compiles just fine.

Error: module ctype is in file 'std/ctype.d' which cannot be read - when running dmd

2016-06-24 Thread Roman via Digitalmars-d-learn
I've just tried to compile a program with `rdmd`, but get the following error: count_words.d(1): Error: module ctype is in file 'std/ctype.d' which cannot be read import path[0] = . import path[1] = /home/roman/dlang/dmd-2.071.0/linux/bin64/../../src/phobos import path[2

Compilation with dub + dmd: out of memory

2015-02-10 Thread Vlasov Roman via Digitalmars-d-learn
I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project this pair eating about 1.4~1.5 GB RAM. I solve this probleb by connecting swap partition, but it calls some freezes + it take ~10% of swap, and after compilation swap not released. At switching off swap

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread Vlasov Roman via Digitalmars-d-learn
On Tuesday, 10 February 2015 at 12:42:07 UTC, ketmar wrote: On Tue, 10 Feb 2015 11:44:09 +, Vlasov Roman wrote: On Tuesday, 10 February 2015 at 11:32:32 UTC, bearophile wrote: Vlasov Roman: I have the quite computer with 2 GB RAM. At compilation with dub and dmd of small project

Re: Compilation with dub + dmd: out of memory

2015-02-10 Thread Vlasov Roman via Digitalmars-d-learn
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, bearophile wrote: Vlasov Roman: I have the quite computer with 2

Re: Linking C library (.dll) to D on windows

2015-01-26 Thread Roman via Digitalmars-d-learn
On Monday, 26 January 2015 at 02:18:05 UTC, Mike Parker wrote: On 1/26/2015 5:45 AM, Roman wrote: Stuff: 1. There are C code module.c and module.h 2. MinGW 3. DMD 2.066.1 4. Window 8.1 module.c: #include module.h int add(int a, int b) {return a + b;} module.h: int add(int,int); I want

Linking C library (.dll) to D on windows

2015-01-25 Thread Roman via Digitalmars-d-learn
Stuff: 1. There are C code module.c and module.h 2. MinGW 3. DMD 2.066.1 4. Window 8.1 module.c: #include module.h int add(int a, int b) {return a + b;} module.h: int add(int,int); I want to use function add from D so i call cc -shared module.c -o module.dll Then D code main.d: import

mixin template had error by calling shared function

2014-12-10 Thread Vlasov Roman via Digitalmars-d-learn
I have this code import std.stdio; mixin template Template(void function() func1, void function() func2) { voidto() { func1(); func2(); } }; class SomeClass { mixin Template!(func, func23); void func() {

Re: mixin template had error by calling shared function

2014-12-10 Thread Vlasov Roman via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 10:34:25 UTC, Marc Schütz wrote: On Wednesday, 10 December 2014 at 09:41:43 UTC, Rikki Cattermole wrote: On 10/12/2014 10:10 p.m., Vlasov Roman wrote: I have this code import std.stdio; mixin template Template(void function() func1, void function() func2

auto attribute for interface functions

2013-10-08 Thread Roman
``` interface I { //auto foo(int i); //forbidden auto bar(T)(T i); //Error: function a.I.bar!(int).bar has no function body with return type inference } class A:I { int foo(int i) { return i; } T bar(T)(T i) {

Re: auto attribute for interface functions

2013-10-08 Thread Roman
On Tuesday, 8 October 2013 at 13:40:47 UTC, Roman wrote: ``` interface I { //auto foo(int i); //forbidden auto bar(T)(T i); //Error: function a.I.bar!(int).bar has no function body with return type inference } class A:I { int foo(int i) { return i

Re: Parser generator?

2012-07-06 Thread Roman D. Boiko
On Friday, 6 July 2012 at 06:10:28 UTC, Philippe Sigaud wrote: Roman recently templated the parse tree to allow multiple outputs and we didn't update the docs, sorry. That was https://github.com/chadjoan, not me :) But I was amazed that my needs have been met so well.

Re: Parser generator?

2012-07-06 Thread Roman D. Boiko
On Friday, 6 July 2012 at 06:10:28 UTC, Philippe Sigaud wrote: void buildGraph(Output o) { void parseToGraph(ParseTree p) { writeln(p.ruleName); } parseToGraph(o.parseTree); } What do parseToGraph and buildGraph do? buildGraph unwraps parseTree from

Re: Fixed size multidimensional array at runtime

2012-07-01 Thread Roman D. Boiko
On Sunday, 1 July 2012 at 09:52:22 UTC, Denis Shelomovskij wrote: 01.07.2012 13:46, Denis Shelomovskij пишет: So I deliberately disallow rule `matrix[x]` means `matrix[x, R[]...]` and made `byTopDimension` property for such iteration:

Re: Fixed size multidimensional array at runtime

2012-06-30 Thread Roman D. Boiko
On Saturday, 30 June 2012 at 20:06:58 UTC, Vidar Wahlberg wrote: On Saturday, 30 June 2012 at 19:35:33 UTC, Denis Shelomovskij wrote: You could be interested in my answer on this thread: http://forum.dlang.org/thread/mailman.1578.1339962782.24740.digitalmars-d-le...@puremagic.com Thanks for

Re: foreach syntax

2012-06-29 Thread Roman D. Boiko
On Friday, 29 June 2012 at 19:52:33 UTC, Timon Gehr wrote: On 06/29/2012 09:51 PM, Namespace wrote: But there is no overhead or something else _if_ i put the type, or? There is a slight typing and compilation overhead. Nothing significant. You missed a slight reading overhead.

Re: Removing from SList (std.container)...

2012-06-27 Thread Roman D. Boiko
On Wednesday, 27 June 2012 at 18:26:46 UTC, Steven Schveighoffer wrote: The thing that makes SList useless is the O(n) removal. Nobody will ever use SList when they can write a replacement that has O(1) removal in 10 minutes. Do you mean something like indexed/sorted dictionary? It doesn't

Re: Removing from SList (std.container)...

2012-06-27 Thread Roman D. Boiko
On Wednesday, 27 June 2012 at 19:10:24 UTC, Steven Schveighoffer wrote: On Wed, 27 Jun 2012 14:46:36 -0400, Roman D. Boiko r...@d-coding.com wrote: On Wednesday, 27 June 2012 at 18:26:46 UTC, Steven Schveighoffer wrote: The thing that makes SList useless is the O(n) removal. Nobody

Re: Removing from SList (std.container)...

2012-06-27 Thread Roman D. Boiko
On Wednesday, 27 June 2012 at 19:55:02 UTC, Roman D. Boiko wrote: Look up SList docs, even with a reference to a *specific element*, you cannot do O(1) removal. Ha-ha, didn't know SList doesn't support that. I somehow confused removal after a referenced element (which should be easy

Re: Removing from SList (std.container)...

2012-06-27 Thread Roman D. Boiko
On Wednesday, 27 June 2012 at 19:06:46 UTC, Timon Gehr wrote: On 06/27/2012 08:46 PM, Roman D. Boiko wrote: On Wednesday, 27 June 2012 at 18:26:46 UTC, Steven Schveighoffer wrote: The thing that makes SList useless is the O(n) removal. Nobody will ever use SList when they can write

Re: Removing from SList (std.container)...

2012-06-27 Thread Roman D. Boiko
On Wednesday, 27 June 2012 at 20:00:18 UTC, Roman D. Boiko wrote: Nice. But forces to use iterators everywhere. (I'm not against iterators, they are almost necessary in certain use cases, like this one.)

Re: Removing from SList (std.container)...

2012-06-27 Thread Roman D. Boiko
On Wednesday, 27 June 2012 at 20:14:53 UTC, Steven Schveighoffer wrote: Removal of that element is perfectly possible, you just need to maintain a reference to its predecessor. Which SList's range does not keep track of. It all depends on tradeoffs of what you want for performance, vs.

Re: Removing from SList (std.container)...

2012-06-27 Thread Roman D. Boiko
On Wednesday, 27 June 2012 at 21:22:31 UTC, Tobias Pankrath wrote: E.g., to point to an element in the middle of some range we would need to create another range and pass it to a function along with the original range. I would hesitate to call them ranges unless that is explicitly a goal for

Re: Removing from SList (std.container)...

2012-06-27 Thread Roman D. Boiko
On Wednesday, 27 June 2012 at 21:38:28 UTC, Jonathan M Davis wrote: On Wednesday, June 27, 2012 22:29:01 Roman D. Boiko wrote: On Wednesday, 27 June 2012 at 20:14:53 UTC, Steven Schveighoffer wrote: Removal of that element is perfectly possible, you just need to maintain a reference

front doesn't compile for arrays of immutable data

2012-06-25 Thread Roman D. Boiko
import std.range; struct Element { //immutable // uncomment to break compilation int _i; this(int i) { _i = i; } } void main() { auto arr = [Element.init]; arr.front; } Declaring _i immutable yields the following compilation error:

Re: front doesn't compile for arrays of immutable data

2012-06-25 Thread Roman D. Boiko
@property ref T front(T)(T[] a) if (!isNarrowString!(T[]) !is(T[] == void[])) { assert(a.length, Attempting to fetch the front of an empty array of ~ typeof(a[0]).stringof); return a[0]; } Why is front returned by ref even when it is not possible to do so?

Re: front doesn't compile for arrays of immutable data

2012-06-25 Thread Roman D. Boiko
On Monday, 25 June 2012 at 15:39:07 UTC, Jonathan M Davis wrote: On Monday, June 25, 2012 16:27:20 Roman D. Boiko wrote: @property ref T front(T)(T[] a) if (!isNarrowString!(T[]) !is(T[] == void[])) { assert(a.length, Attempting to fetch the front of an empty array

Re: front doesn't compile for arrays of immutable data

2012-06-25 Thread Roman D. Boiko
On Monday, 25 June 2012 at 15:38:09 UTC, Timon Gehr wrote: It should always be possible to do so. What you are experiencing seems to be a compiler bug. I couldn't find it reported before. The closest are: d.puremagic.com/issues/show_bug.cgi?id=6480

Re: front doesn't compile for arrays of immutable data

2012-06-25 Thread Roman D. Boiko
On Monday, 25 June 2012 at 15:58:14 UTC, Roman D. Boiko wrote: On Monday, 25 June 2012 at 15:38:09 UTC, Timon Gehr wrote: It should always be possible to do so. What you are experiencing seems to be a compiler bug. I couldn't find it reported before. The closest are: http://d.puremagic.com

Re: phobos and splitting things... but not with whitespace.

2012-06-24 Thread Roman D. Boiko
Just found a follow-up post: http://dblog.aldacron.net/2012/06/24/my-only-gripes-about-d/

AA with immutable values

2012-06-24 Thread Roman D. Boiko
immutable(SomeClass)[S] _map; _map[S.init] = null; // doesn't compile since _map[S.init] is immutable My current workaround is: immutable(SomeClass)*[S] _map; _map[S.init] = [null].ptr; But this introduces an additional level of indirection in a performance-critical part of my code.

Re: AA with immutable values

2012-06-24 Thread Roman D. Boiko
On Sunday, 24 June 2012 at 12:15:10 UTC, Ali Çehreli wrote: Although it sounds like a limitation, it may be due to the fact that AA may need to rehash, which may not be suitable with immutable values. Thanks, now I can see the motivation. The following are two ways of generating immutable AA

Re: AA with immutable values

2012-06-24 Thread Roman D. Boiko
On Sunday, 24 June 2012 at 12:21:50 UTC, Jonathan M Davis wrote: On Sunday, June 24, 2012 05:15:03 Ali Çehreli wrote: Although it sounds like a limitation, it may be due to the fact that AA may need to rehash, which may not be suitable with immutable values. const and immutable types as

Re: AA with immutable values

2012-06-24 Thread Roman D. Boiko
On Sunday, 24 June 2012 at 12:34:28 UTC, Jonathan M Davis wrote: On Sunday, June 24, 2012 14:24:48 Roman D. Boiko wrote: Yeah, but I wonder that such a core feature as AA doesn't support this use case better (I mean more efficiently). The current AA implementation is quite buggy. It works

Re: Immutability and other attributes, please review

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 06:25:59 UTC, Jacob Carlborg wrote: On 2012-06-14 17:32, Roman D. Boiko wrote: I agree, just looking how to accomplish my goals. I decided to get rid of casting, and will store everything on heap. I don't know how to put a variable of type float to the heap

Re: Immutability and other attributes, please review

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 08:31:08 UTC, dennis luehring wrote: Am 15.06.2012 08:25, schrieb Jacob Carlborg: On 2012-06-14 17:32, Roman D. Boiko wrote: I agree, just looking how to accomplish my goals. I decided to get rid of casting, and will store everything on heap. I don't know how

Re: Immutability and other attributes, please review

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 10:01:42 UTC, Dmitry Olshansky wrote: Suggest you revisit toNode function as it does return something strange :) Just looking at first - last lines: pure nothrow auto toNode(R)(R range, immutable(Maybe!Node) parent) if(isInputRange!R hasLength!R)

Re: Lazy KMP range

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 19:03:56 UTC, bearophile wrote: A lazy Knuth-Morris-Pratt that works on a Input Range: http://ideone.com/dUs5B Do you have suggestions for improvements of the code? Maybe do I have to turn it into a Forward Range if the first range is a Forward one? Is something

Re: Lazy KMP range

2012-06-15 Thread Roman D. Boiko
On Friday, 15 June 2012 at 19:41:35 UTC, Roman D. Boiko wrote: Pay attention to Licensed under the PSF License for your source implementation. You will not be able to include it into Phobos unless implementation details that you borrowed from Python implementation can be found elsewhere under

Immutability and other attributes, please review

2012-06-14 Thread Roman D. Boiko
I have not much experience in D programming yet, and one of things which I frequently mess up is usage of various attributes, especially immutable and related. Could anybody make a review my code at https://github.com/roman-d-boiko/functional-data-structures/blob/master/fds/persistent.d

Re: Immutability and other attributes, please review

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 09:51:45 UTC, Jacob Carlborg wrote: Just a note on the style. The convention is to but all attributes on front of the return type, except for const, when const is referring to that the method is const and not the return type. OK Another note. class _Module :

Re: Immutability and other attributes, please review

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 13:31:01 UTC, Roman D. Boiko wrote: On Thursday, 14 June 2012 at 13:21:34 UTC, Jacob Carlborg wrote: If you want that and have it immutable you need to make a deep copy of the passed in object to be safe. You could use const instead and also making the argument

Re: Immutability and other attributes, please review

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 13:33:43 UTC, Roman D. Boiko wrote: On Thursday, 14 June 2012 at 13:31:01 UTC, Roman D. Boiko wrote: On Thursday, 14 June 2012 at 13:21:34 UTC, Jacob Carlborg wrote: If you want that and have it immutable you need to make a deep copy of the passed in object

Re: Immutability and other attributes, please review

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 15:21:53 UTC, dennis luehring wrote: Am 14.06.2012 15:26, schrieb Roman D. Boiko: But now, with everything immutable, I had to comment out several test cases. I cannot pass an immutable struct allocated on stack, into a method by reference, and then store

Re: How to specialize templates for l-value and non-l-value arguments?

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 15:27:24 UTC, Roman D. Boiko wrote: I have a struct that holds an immutable pointer to some data. I would like to initialize it with a pointer to anything that is passed inside, so if it is a not an l-value, I would need to copy it to the heap first. How can I

Re: How to specialize templates for l-value and non-l-value arguments?

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 16:05:52 UTC, Timon Gehr wrote: You can overload based on 'ref'. auto just(ref immutable(T) data) { return Maybe!T(data); } auto just(immutable(T) data) { return Maybe!T([data].ptr); } Great! Thanks

Re: How to specialize templates for l-value and non-l-value arguments?

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 16:08:54 UTC, Roman D. Boiko wrote: On Thursday, 14 June 2012 at 16:05:52 UTC, Timon Gehr wrote: You can overload based on 'ref'. auto just(ref immutable(T) data) { return Maybe!T(data); } auto just(immutable(T) data) { return Maybe!T([data].ptr); } Great! Thanks

Re: How to specialize templates for l-value and non-l-value arguments?

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 16:29:31 UTC, Timon Gehr wrote: On 06/14/2012 06:20 PM, Roman D. Boiko wrote: On Thursday, 14 June 2012 at 16:08:54 UTC, Roman D. Boiko wrote: On Thursday, 14 June 2012 at 16:05:52 UTC, Timon Gehr wrote: You can overload based on 'ref'. auto just(ref immutable(T

Re: How to specialize templates for l-value and non-l-value arguments?

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 16:50:43 UTC, bearophile wrote: Roman D. Boiko: You have found a compiler bug. Looks like :) Please report it in bugzilla :-) Bye, bearophile I want to, just figuring out how to check for duplicates.

Re: How to specialize templates for l-value and non-l-value arguments?

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 17:05:52 UTC, Roman D. Boiko wrote: Looks like http://d.puremagic.com/issues/show_bug.cgi?id=6774, should I report my case there, or create a new issue (but reference 6774)? Added a comment there.

Re: Immutability and other attributes, please review

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 17:44:11 UTC, Jonathan M Davis wrote: I was just thinking that maybe we should make a generic function for this and add it to Phobos. Something like auto makePtr(T, U)(U value) if(is(U : T)) {} auto makePtr(T, Args...)(Args args) {} where the first one works with

Re: Immutability and other attributes, please review

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 17:58:25 UTC, Dmitry Olshansky wrote: On 14.06.2012 21:57, Roman D. Boiko wrote: Am I right that [2.0].ptr (instead of 2.0 could be a struct literal) doesn't involve copying, while such function would? Copying what? One word is surely cheap ;) That was just

Re: Immutability and other attributes, please review

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 18:01:06 UTC, Jonathan M Davis wrote: I think make new would be more self-explanatory. Ptr doesn't imply heap. Other then this, it looks useful. (I'd love to see an optional allocator parameter... but have to wait I guess) Well, we use make with std.container

Create an array with immutable elements

2012-06-14 Thread Roman D. Boiko
immutable struct Node{ string s; } Node[] f() { Node[] arr = ...? return arr; } How to fill an array, if its elements are immutable? I want to assign values calculated by some function.

Re: Create an array with immutable elements

2012-06-14 Thread Roman D. Boiko
On Thursday, 14 June 2012 at 23:57:36 UTC, Roman D. Boiko wrote: immutable struct Node{ string s; } Node[] f() { Node[] arr = ...? return arr; } How to fill an array, if its elements are immutable? I want to assign values calculated by some function. More specifically, given auto names

Re: Create an array with immutable elements

2012-06-14 Thread Roman D. Boiko
On Friday, 15 June 2012 at 00:08:33 UTC, Era Scarecrow wrote: On Thursday, 14 June 2012 at 23:57:36 UTC, Roman D. Boiko wrote: immutable struct Node{ string s; } Node[] f() { Node[] arr = ...? return arr; } How to fill an array, if its elements are immutable? I want to assign values

Re: Create an array with immutable elements

2012-06-14 Thread Roman D. Boiko
On Friday, 15 June 2012 at 00:14:11 UTC, bearophile wrote: Roman D. Boiko: immutable struct Node{ string s; } Node[] f() { Node[] arr = ...? return arr; } How to fill an array, if its elements are immutable? I want to assign values calculated by some function. In general sometimes it's

Re: Create an array with immutable elements

2012-06-14 Thread Roman D. Boiko
On Friday, 15 June 2012 at 00:18:23 UTC, Jonathan M Davis wrote: On Friday, June 15, 2012 01:57:35 Roman D. Boiko wrote: immutable struct Node{ string s; } Node[] f() { Node[] arr = ...? return arr; } How to fill an array, if its elements are immutable? I want to assign values calculated

Using keyword as package name

2012-06-09 Thread Roman D. Boiko
I generate bindings to a c library, and one of folders is named `shared`, which is a keyword and thus cannot be used as a package name. One option is to remove this package and put files to a parent directory, or simply rename it. Is there any way to avoid this and keep the name as is? What

Re: Sorry for posting this here. Not sure where else.

2012-05-23 Thread Roman D. Boiko
On Wednesday, 23 May 2012 at 15:29:40 UTC, Steven Schveighoffer wrote: You need to send an email to brad at dsource.org. The guy who does this is (or was) Brad Anderson. Depending on where you are planning to post, you may be in for more disappointment, many projects on dsource.org are

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Roman D. Boiko
On Thursday, 17 May 2012 at 04:16:10 UTC, Andrew Wiley wrote: On Wed, May 16, 2012 at 11:07 PM, H. S. Teoh hst...@quickfur.ath.cx wrote: Do unions suffer from this problem? Could this prevent alignment problems: short bytesToShort(ubyte[] b) in { assert(b.length==2); }

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Roman D. Boiko
On Thursday, 17 May 2012 at 07:07:58 UTC, Roman D. Boiko wrote: And what about the following code: // This implementation is optimized for speed via swapping endianness in-place pure immutable(C)[] fixEndian(C, Endian blobEndian = endian)(ubyte[] blob) if(is(CharTypeOf!C)) { import

Re: convert ubyte[k..k + 1] to int

2012-05-17 Thread Roman D. Boiko
On Thursday, 17 May 2012 at 08:39:21 UTC, Artur Skawina wrote: On 05/17/12 10:15, Roman D. Boiko wrote: I mean, is it safe (assuming that we are allowed to mutate blob, and its length is a multiple of C.sizeof)? I do casting from ubyte[] to C[]. Only if C.ptr ends up properly aligned

Re: struct vs class for a simple token in my d lexer

2012-05-15 Thread Roman D. Boiko
On Tuesday, 15 May 2012 at 06:17:31 UTC, Era Scarecrow wrote: On Monday, 14 May 2012 at 18:00:42 UTC, Roman D. Boiko wrote: On Monday, 14 May 2012 at 17:37:02 UTC, Dmitry Olshansky wrote: But hopefully you get the idea. See something simillar in std.regex, though pointer in there also serves

Re: struct vs class for a simple token in my d lexer

2012-05-15 Thread Roman D. Boiko
of multiple types as well as managing them using pointers and unions. A good portion of that can carry over for your lexer and project. Looks like I can introduce several lex/flex concepts in my lexer, thank you! I've created a task for myself to do this investigation: https://github.com/roman-d-boiko

struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
(Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here. I would appreciate any feedback. (Whether to reply in this or that thread is up to you.) Thanks

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 15:44:54 UTC, Tobias Pankrath wrote: On Monday, 14 May 2012 at 15:10:25 UTC, Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 15:53:34 UTC, Tobias Pankrath wrote: Quoting your post in another thread: On Monday, 14 May 2012 at 15:10:25 UTC, Roman D. Boiko wrote: Making it a class would give several benefits: * allow not to worry about allocating a big array of tokens. E.g., on 64-bit OS

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 16:41:39 UTC, Jonathan M Davis wrote: On Monday, May 14, 2012 17:10:23 Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here. I would

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 17:05:17 UTC, Dmitry Olshansky wrote: On 14.05.2012 19:10, Roman D. Boiko wrote: (Subj.) I'm in doubt which to choose for my case, but this is a generic question. http://forum.dlang.org/post/odcrgqxoldrktdtar...@forum.dlang.org Cross-posting here. I would appreciate

Re: struct vs class for a simple token in my d lexer

2012-05-14 Thread Roman D. Boiko
On Monday, 14 May 2012 at 17:37:02 UTC, Dmitry Olshansky wrote: But hopefully you get the idea. See something simillar in std.regex, though pointer in there also serves for intrusive linked-list. Thanks, most likely I'll go your way.