Dub. Mercurial (bitbucket.org). Projects deployment

2014-06-10 Thread Uranuz via Digitalmars-d-learn
I have web-application project in D language hosted on bitbucket.org. So I using Mercurial repository. I exactly have two *logical* projects but currently they are in one repo. The first is my library that includes not only D code, but also some resources like HTML-page templates (not compiled

Re: Dub. Mercurial (bitbucket.org). Projects deployment

2014-06-10 Thread Uranuz via Digitalmars-d-learn
Also I have additional question to this post. 6. If I would convert my repo to git, but use anather hosting that github.org for example my own local server or bitbucket.org. How could I specify source for loading dependencies? This is unclear from dub documentation. Is it a tool for working

Re: Dub. Mercurial (bitbucket.org). Projects deployment

2014-06-13 Thread Uranuz via Digitalmars-d-learn
Thanks for all the answers) 8. I have another more simple question about rdmd utility. It takes one *.d file and searches for all dependencies. What if I need to pass independent *.d file or *.ddoc file directly to dmd compiler? How could I do that using dmd? I have no idea how I could

Question about iteger literals

2014-06-22 Thread Uranuz via Digitalmars-d-learn
I have the following programme import std.stdio; bool isDigit(char c) nothrow { return c = '0' c = '9'; } ushort hexValue(char c) nothrow { if( isDigit(c) ) return c - '0'; else if (c = 'a' c = 'f') return c - 'a' + 10; else if

Re: Question about iteger literals

2014-06-22 Thread Uranuz via Digitalmars-d-learn
ushort hexValue(in char c) pure nothrow @safe @nogc else return ushort.max; I understand what pure, nothrow and @safe mean there. But what @nogc changes in there so I should use this modifier? Is it logical specifier that this function can be used without garbage

Re: Question about iteger literals

2014-06-22 Thread Uranuz via Digitalmars-d-learn
In expression return c - 'a' + 10; I could think that 10 has type int and resulting value promoted to the largest type. But I don't understand why in expression where both of arguments have type char: return c - '0'; I have resulting type int. It's very strange for me and looks

Re: Question about iteger literals

2014-06-22 Thread Uranuz via Digitalmars-d-learn
In D operations among chars return a int. The same happens in C/C++. If you subtract a char from a char in general you can have a negative result, that can't fit in a char. So what's buggy is your thinking. Ok. Thank you! I never thought about it that way

Re: Question about iteger literals

2014-06-22 Thread Uranuz via Digitalmars-d-learn
Another stupid question. Using this logic substraction for two uint values should return int too, because it can produce negative result. Am I right or not?

Re: Question about iteger literals

2014-06-22 Thread Uranuz via Digitalmars-d-learn
On Sunday, 22 June 2014 at 11:57:48 UTC, Uranuz wrote: Another stupid question. Using this logic substraction for two uint values should return int too, because it can produce negative result. Am I right or not? Now this code import std.stdio; void main() { uint a = 50; uint

Re: Question about iteger literals

2014-06-22 Thread Uranuz via Digitalmars-d-learn
If these rules are not so clear and have some exceptions (but I don't understand why they are needed) then some documentation needed about this. But I would prefer to have result of uint substraction like uint, and char substraction like char. If we will changing all the types it will be kind

Using attributes inside template instantiation

2014-06-25 Thread Uranuz via Digitalmars-d-learn
I'm trying to declare format for database record in compile time. I consider to use attributes fo this. Can I do something similar to this code? struct RecordFormat(T) {} alias Format = RecordFormat!( @(cool) int ); pragma( msg, Format ); void main() { } Or I want something strange

Re: Using attributes inside template instantiation

2014-06-26 Thread Uranuz via Digitalmars-d-learn
But if I write @(hello) struct Hello {} so all of the variables that have type Hello will have attribute @(hello) like come type qualifier because attribute is a part of declaration of Hello. Do I understand correctly?

Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
Compiler can't deduce type for template struct Pair when using it with enum argument. There is an example import std.stdio; enum Category { first, second, third }; struct Pair(F, S) { F first; S second; this(F f, S s) { first = f;

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
On Friday, 27 June 2014 at 06:14:48 UTC, pgtkda wrote: On Friday, 27 June 2014 at 06:12:57 UTC, pgtkda wrote: How I could make this working without explicit specifying of types? sorry, i should read better Ok. Maybe it was discussed already somewhere, but I am not god in searching in

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
I think, D is a typesafe language, therefore you can't use variables with no type declaration. One thing you can search for, are templates but even there you have to define a type: import std.stdio; enum Category : string { first = first} template Pair(T) { T t; T cat; }

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
Seems that I found answer myself. As far as I understand type inference is working only for template functions but not struct or class templates. This is why this not working and enum is not responsible for that. I don't know why I use D enough long but I did not remember this fact.

Re: Enum type deduction inside templates is not working

2014-06-27 Thread Uranuz via Digitalmars-d-learn
There is proposal exists for this topic http://wiki.dlang.org/DIP40

Conflict between function and template with the same name

2014-06-29 Thread Uranuz via Digitalmars-d-learn
I have a question about this example code; import std.stdio; string getByName(string name) { return smth; } template getByName(string name) { enum //string getByName = getByName(name); } void main() { writeln(getByName!(name)); } This produces

Re: Conflict between function and template with the same name

2014-06-29 Thread Uranuz via Digitalmars-d-learn
import std.stdio; string getByName(string name) { return smth; } template getByName(string name) { enum getByName = .getByName(name); } void main() { writeln(getByName!(name)); } Thanks a lot! Very interesting. Do you see any reasoning why this happens?

How to test templates for equality?

2014-06-30 Thread Uranuz via Digitalmars-d-learn
I have a question. How could I know if some alias or template parameter is some template symbol. I want to not that I want to know that symbol is template symbol itself but not instance of template (std.traits.isInstanceOf give answer for that question). I'll give some example template

Re: How to test templates for equality?

2014-06-30 Thread Uranuz via Digitalmars-d-learn
I suddenly posted it for somehow. But I hope idea is clear. How could I test if symbol is equal to some concrete template. I tried these examples: template isFoo(alias F) { enum bool isFoo = is( F == Foo ); } template isFoo(alias F) { enum bool isFoo = F == Foo; } Could you advise

Re: How to test templates for equality?

2014-07-01 Thread Uranuz via Digitalmars-d-learn
On Tuesday, 1 July 2014 at 05:51:17 UTC, Peter Alexander wrote: template Foo(T...) {} template Bar(T...) {} template isFoo(alias F) { enum isFoo = __traits(isSame, F, Foo); } pragma(msg, isFoo!Foo); // true pragma(msg, isFoo!Bar); // false Thanks for quick response. I really forget

Re: How to test templates for equality?

2014-07-05 Thread Uranuz via Digitalmars-d-learn
I have another question about testing if given symbol is instance of the given template and geting it's template arguments. I'm talking about raw template symbols, but not struct or class templates. For case with struct or class template std.traits.isInstanceOf is working well. But using *raw*

Re: How to test templates for equality?

2014-07-05 Thread Uranuz via Digitalmars-d-learn
Suddenly posted. I don't know why it's happened)) template isMyInstanceOf(alias Templ, alias Inst) { alias Args = ???; //I don't have idea how to get it enum bool isMyInstanceOf = __traits(isSame, Templ!(Args), Inst); } Do you have any idea how to solve this? May be standad library

Re: How to test templates for equality?

2014-07-06 Thread Uranuz via Digitalmars-d-learn
template isMyInstanceOf(alias Templ, alias Inst) { alias Args = ???; //I don't have idea how to get it enum bool isMyInstanceOf = __traits(isSame, Templ!(Args), Inst); } Do you have any idea how to solve this? May be standad library could be improved with such type of test for

How to say to compiler that I want to inherit final template bethod of base interface into derived class

2014-07-20 Thread Uranuz via Digitalmars-d-learn
The question is in the header: How to say to compiler that I want to inherit final template bethod of base interface into derived class? I have the following example. I know that it is maybe overcomplicated but still I need this feature in my code. import std.stdio; interface IBase {

Re: How to say to compiler that I want to inherit final template bethod of base interface into derived class

2014-07-21 Thread Uranuz via Digitalmars-d-learn
On Sunday, 20 July 2014 at 12:48:09 UTC, anonymous wrote: import std.stdio; interface IBase { template getStr(string fieldName) { final string getStr() { return George; } }

Re: How to say to compiler that I want to inherit final template bethod of base interface into derived class

2014-07-21 Thread Uranuz via Digitalmars-d-learn
On Sunday, 20 July 2014 at 16:12:20 UTC, anonymous wrote: On Sunday, 20 July 2014 at 15:48:19 UTC, Uranuz wrote: Sorry, but this example doesn't work too. Ugh, 2.065 doesn't like it, but it works for me with git head (v2.066-devel-82b031c). Where did you get it? Or you compiled it yourself?

Re: Question about iteger literals

2014-07-21 Thread Uranuz via Digitalmars-d-learn
On Monday, 23 June 2014 at 18:32:38 UTC, Steven Schveighoffer wrote: On Sun, 22 Jun 2014 08:23:45 -0400, Uranuz neura...@gmail.com wrote: If these rules are not so clear and have some exceptions (but I don't understand why they are needed) then some documentation needed about this. See

Re: Question about iteger literals

2014-07-21 Thread Uranuz via Digitalmars-d-learn
In C/C++/D if you sum a types that are smaller than int, you obtain an int. D has copied C for backwards compatibility with C code. Bye, bearophile Is there any reasoning why this should remain unchainged? How could it break interface between languages? And also this code succesfully

Re: Question about iteger literals

2014-07-21 Thread Uranuz via Digitalmars-d-learn
I see these rules but when I compile following code and it fails with error it looks VERY stupid. import std.stdio; void main() { ubyte a = 15; ubyte b = 10; ubyte c = a + b; //What is happening there?! ARGH! Are you joking?! } Compilation output:

Help with porting grammar from PEGjs to D for dustjs project!

2014-08-03 Thread Uranuz via Digitalmars-d-learn
I want to try to implement web template engine dustjs: http://akdubya.github.io/dustjs/ At the first step implementing parser for it's grammar is needed. As far as code for parsing grammar was generated via PEGjs grammar generator the resulting code is enough long (about 4200 lines of code).

Re: Help with porting grammar from PEGjs to D for dustjs project!

2014-08-03 Thread Uranuz via Digitalmars-d-learn
I am real noob about grammar description languages so I need some explanation about it. As far as I understand expressions in curly bracers are used to modify syntax tree just in process of parsing instead of modifying it after? How I could use PEGGED to map some code to these parsed

Re: Help with porting grammar from PEGjs to D for dustjs project!

2014-08-05 Thread Uranuz via Digitalmars-d-learn
Different formats and also different languages. I don't see how you can compare a parse tree that's a D object and another tree made by dustjs: you never see the AST produced by dust, you only see the resulting JS code. Yes. That's a point. Thanks for all the explanations. I'll try to make

Re: Help with porting grammar from PEGjs to D for dustjs project!

2014-08-05 Thread Uranuz via Digitalmars-d-learn
On Tuesday, 5 August 2014 at 08:13:25 UTC, Uranuz wrote: Different formats and also different languages. I don't see how you can compare a parse tree that's a D object and another tree made by dustjs: you never see the AST produced by dust, you only see the resulting JS code. Yes. That's a

Re: Help with porting grammar from PEGjs to D for dustjs project!

2014-08-06 Thread Uranuz via Digitalmars-d-learn
What I was thinking about is possibility to change ParseTree struct with user-defined version of it. And I was thinking about setting tree type as template parameter to grammar: grammar!(MyParseTree)( Arithmetic: ... ); Or somethink like this. I think changing source code of library in

Question about operations on class/struct properties

2014-08-18 Thread Uranuz via Digitalmars-d-learn
I think there is something that I don't understand about concept of *properties*. I thing that property is sort of object attribute that belongs to it. Currently property considered as two functions: *get* and/or *set*. So we can do two sort of operations on concept that called *property*:

Re: Question about operations on class/struct properties

2014-08-18 Thread Uranuz via Digitalmars-d-learn
On Monday, 18 August 2014 at 18:07:09 UTC, Phil Lavoie wrote: All you said makes sense. If there is a direct connection between getter, setter and member than yes, returning it by reference is usually more convenient: private T _member; @property ref inout(T) member() inout {return _member;}

Re: Question about operations on class/struct properties

2014-08-18 Thread Uranuz via Digitalmars-d-learn
I posted it suddenly. I don't know why. I'll give short illustration. struct PropType { void append(int value) { //implementation } } class Test { PropType myProp() @property { return _propValue; } private PropType _propValue; } void main() { Test test

Re: Question about operations on class/struct properties

2014-08-19 Thread Uranuz via Digitalmars-d-learn
I have another similar example illustrating this problem at semantic level. import std.stdio, std.typecons; struct Test { //ref Nullable!int prop() @property { return _value; } private Nullable!int _value = 10; } void

Re: sdlang-d can not link after updating to dmd 2.066

2014-08-29 Thread Uranuz via Digitalmars-d-learn
On Thursday, 28 August 2014 at 10:16:15 UTC, Puming wrote: I updated dub to 0.9.22 and still got the same error... THis is the output of `dub build --force`: --- output --- ## Warning for package sdlang-d ## The following compiler flags have been specified in the package description file.

How to detect start of Unicode symbol and count amount of graphemes

2014-10-05 Thread Uranuz via Digitalmars-d-learn
I have struct StringStream that I use to go through and parse input string. String could be of string, wstring or dstring type. I implement function popChar that reads codeUnit from Stream. I want to have *debug* mode of parser (via CT switch), where I could get information about lineIndex,

Re: How to detect start of Unicode symbol and count amount of graphemes

2014-10-05 Thread Uranuz via Digitalmars-d-learn
You can use std.uni.byGrapheme to iterate by graphemes: http://dlang.org/phobos/std_uni.html#.byGrapheme AFAIK, graphemes are not self synchronizing, but codepoints are. You can pop code units until you reach the beginning of a new codepoint. From there, you can iterate by graphemes, though

Re: How to detect start of Unicode symbol and count amount of graphemes

2014-10-06 Thread Uranuz via Digitalmars-d-learn
Have a look here [1]. For example, if you have a byte that is between U+0080 and U+07FF you know that you need two bytes to get that whole code point. [1] http://en.wikipedia.org/wiki/UTF-8#Description Thanks. I solved it myself already for UTF-8 encoding. There choosed approach with

How to check i

2014-10-16 Thread Uranuz via Digitalmars-d-learn
I have some string *str* of unicode characters. The question is how to check if I have valid unicode code point starting at code unit *index*? I need it because I try to write parser that operates on string by *code unit*. If more precisely I trying to write function *matchWord* that should

Re: How to check i

2014-10-17 Thread Uranuz via Digitalmars-d-learn
This is

Re: How to match string by word

2014-10-17 Thread Uranuz via Digitalmars-d-learn
I haven't touched any key on a keyboard and haven't pressed *Send* but message was posted somehow. Thanks. Checking for UTF-8 continuation bytes is good idea. Also I agree that UTF-16 is more difficult. I will keep it for future release when implementation will start to work properly on UTF-8

Representing parse tree node

2014-11-02 Thread Uranuz via Digitalmars-d-learn
Now I'm working on implementation of Jinja template engine for web development on D language. http://jinja.pocoo.org I like it's explicit but still rather short syntax inherited from Python. I find it good for writing templates for web pages and other stuff such as configs or maybe CSS

Question about eponymous template trick

2014-11-03 Thread Uranuz via Digitalmars-d-learn
I have an example of code like this: template Node(String) { struct Node {} struct Name {} struct Attr {} } void main() { alias MyNode = Node!(string).Node; alias MyName = Node!(string).Name; alias MyAttr = Node!(string).Attr; }

Re: Question about eponymous template trick

2014-11-03 Thread Uranuz via Digitalmars-d-learn
Looks like compiler looks for Node, Name and Attr in Node struct, because of eponymous thing. I understand it but I want to know if it is documented behaviour or not. Could anybody clear what happens with eponymous stuff and why I can't get acces to *other* declarations inside eponymous

Re: Question about eponymous template trick

2014-11-03 Thread Uranuz via Digitalmars-d-learn
I think it's the intended behavior. I think documentation is outdated. Ali Thanks. So I will modify my programme to workaround this.

Re: Question about eponymous template trick

2014-11-03 Thread Uranuz via Digitalmars-d-learn
Also I failed to find any documentation about eponymous stuff in language reference. As far as I remember it was here but now looks like it is missing.

Passing reference data to class and incapsulation

2014-11-27 Thread Uranuz via Digitalmars-d-learn
In D we a several data types which are passed by reference: dynamic arrays, associative arrays. And sometimes we need to pass these reference data to class instance to store it inside. One of the principles of object-oriented programming is incapsulation. So all class data should be only

Re: Passing reference data to class and incapsulation

2014-11-28 Thread Uranuz via Digitalmars-d-learn
On Friday, 28 November 2014 at 08:31:26 UTC, bearophile wrote: Uranuz: Same situation happens when I assign reference data to properties. Someone has suggested to solve this problem with an attribute, like owned, that forbids to return mutable reference data owned by a class/struct

Re: Problem with using struct ranges with @disabled this(this) with some range functions

2015-09-02 Thread Uranuz via Digitalmars-d-learn
On Wednesday, 2 September 2015 at 07:34:15 UTC, Mike Parker wrote: On Wednesday, 2 September 2015 at 06:28:52 UTC, Uranuz wrote: As far as I understand to save current cursor of forward range I should always use *save* property. But sometimes range struct is just copied using postblit without

Problem with using struct ranges with @disabled this(this) with some range functions

2015-09-02 Thread Uranuz via Digitalmars-d-learn
As far as I understand to save current cursor of forward range I should always use *save* property. But sometimes range struct is just copied using postblit without using save (it happens even in Phobos). Is it correct behaviour to *pass ownership* for range structs via just copying of range

Question about OutputRange and std.range: put

2016-01-16 Thread Uranuz via Digitalmars-d-learn
Hello to forum readers! I have a question about using OutputRange and std.range: put. I have the following code snippet to illustrate my question: import std.range, std.stdio, std.string; void main() { string greating = "Hello, " ; string username = "Bob";

Re: Question about OutputRange and std.range: put

2016-01-16 Thread Uranuz via Digitalmars-d-learn
On Saturday, 16 January 2016 at 16:14:56 UTC, Jonathan M Davis wrote: On Saturday, January 16, 2016 12:11:11 Uranuz via Digitalmars-d-learn wrote: [...] There are a few problems here. First off, when put is used with an array, it fills the array. It doesn't append to it. So, you can't use

Need some help about error that I don't understand

2016-02-05 Thread Uranuz via Digitalmars-d-learn
In my custom multithreaded web-server (non vibe-based) I got error that is strange for me. I've was looking for a reason running app under GDB, but I don't understand how to interpret what I've got. It's interesting that it fails (without any error or segfault message) in the case when null

Re: Need some help about error that I don't understand

2016-02-05 Thread Uranuz via Digitalmars-d-learn
On Friday, 5 February 2016 at 17:39:55 UTC, Uranuz wrote: In my custom multithreaded web-server (non vibe-based) I got error that is strange for me. I've was looking for a reason running app under GDB, but I don't understand how to interpret what I've got. It's interesting that it fails

Stupid question about AA. The following code works but I don't undrstand why?!

2016-04-09 Thread Uranuz via Digitalmars-d-learn
I am stupid today :) So I have a question. The piece of code given: http://dpaste.dzfl.pl/523781df67ab It looks good, but I don't understand why it works?

Re: Stupid question about AA. The following code works but I don't undrstand why?!

2016-04-09 Thread Uranuz via Digitalmars-d-learn
On Saturday, 9 April 2016 at 16:44:06 UTC, ag0aep6g wrote: On 09.04.2016 18:13, Uranuz wrote: http://dpaste.dzfl.pl/523781df67ab For reference, the code: import std.stdio; void main() { string[][string] mapka; string[]* mapElem = "item" in mapka; //Checking if I

Re: Stupid question about AA. The following code works but I don't undrstand why?!

2016-04-10 Thread Uranuz via Digitalmars-d-learn
On Saturday, 9 April 2016 at 21:16:08 UTC, ag0aep6g wrote: On Saturday, 9 April 2016 at 19:31:31 UTC, Uranuz wrote: I think that we need to add warning about such case in documentation section: https://dlang.org/spec/hash-map.html#construction_and_ref_semantic in order to prevent this kind of

Re: Stupid question about AA. The following code works but I don't undrstand why?!

2016-04-09 Thread Uranuz via Digitalmars-d-learn
On Saturday, 9 April 2016 at 18:27:11 UTC, ag0aep6g wrote: On Saturday, 9 April 2016 at 18:06:52 UTC, Uranuz wrote: Thanks. It's clear now. AA holds not `array struct` itself inside, but pointer to it. How the array is stored in the AA doesn't matter, as far as I can see. The point is that

Re: Stupid question about AA. The following code works but I don't undrstand why?!

2016-04-09 Thread Uranuz via Digitalmars-d-learn
On Saturday, 9 April 2016 at 19:25:32 UTC, Uranuz wrote: On Saturday, 9 April 2016 at 18:27:11 UTC, ag0aep6g wrote: [...] Another observation is illustrated with the foloving code: http://dpaste.dzfl.pl/8d68fd5922b7 Because AA and arrays are not created before they were assigned some value

Problem with circular imports of modules with static ctors an immutable variables

2016-04-14 Thread Uranuz via Digitalmars-d-learn
In my program I have error with circular imports of modules with static ctors. So I decided to move ctors in separate file and import it only from the 1st file. But problem is that in the first file I have immutables that should be initialized in shared static ctor. However doing it from

static immutable and lambdas inside struct or class. Is that bug or not?

2016-08-14 Thread Uranuz via Digitalmars-d-learn
Greatings! I need help with these lines bellow. I don't understand why it doesn't compile. Is it bug somewhere in Phobos or compiler? Or just I wrote smth wrong? //- struct A { import std.algorithm: map; import std.array: array; import std.typecons: tuple;

Re: static immutable and lambdas inside struct or class. Is that bug or not?

2016-08-14 Thread Uranuz via Digitalmars-d-learn
On Sunday, 14 August 2016 at 15:53:21 UTC, ag0aep6g wrote: On 08/14/2016 04:27 PM, Uranuz wrote: [...] Looks like a compiler bug, since it works without the struct: import std.algorithm: map; import std.array: array; import std.typecons: tuple; immutable aaa = [ tuple("1",

Re: How to check member function for being @disable?

2016-09-13 Thread Uranuz via Digitalmars-d-learn
On Tuesday, 13 September 2016 at 15:32:57 UTC, Jonathan M Davis wrote: On Tuesday, September 13, 2016 08:28:10 Jonathan M Davis via Digitalmars-d- learn wrote: On Tuesday, September 13, 2016 04:58:38 Uranuz via Digitalmars-d-learn wrote: > In my code I iterate in CT over class methods mar

How to check member function for being @disable?

2016-09-12 Thread Uranuz via Digitalmars-d-learn
In my code I iterate in CT over class methods marked as @property and I have a probleme that one of methods is @disable. So I just want to skip @disable members. I found possible solution, but it's interesting to we if we have more clear and obvious way to test for @disable without using

Re: How to make rsplit (like in Python) in D

2016-10-03 Thread Uranuz via Digitalmars-d-learn
On Saturday, 1 October 2016 at 18:33:02 UTC, TheFlyingFiddle wrote: On Saturday, 1 October 2016 at 16:45:11 UTC, Uranuz wrote: [...] There are two reasons why this does not compile. The first has to do with how retro() (and indeed most function in std.range) work with utf-8 strings (eg the

Re: How to make rsplit (like in Python) in D

2016-10-03 Thread Uranuz via Digitalmars-d-learn
On Saturday, 1 October 2016 at 18:55:54 UTC, pineapple wrote: On Saturday, 1 October 2016 at 17:55:08 UTC, Uranuz wrote: On Saturday, 1 October 2016 at 17:32:59 UTC, Uranuz wrote: On Saturday, 1 October 2016 at 17:23:16 UTC, Uranuz wrote: [...] But these example fails. Oops. Looks like a

Re: How to make rsplit (like in Python) in D

2016-10-01 Thread Uranuz via Digitalmars-d-learn
On Saturday, 1 October 2016 at 17:32:59 UTC, Uranuz wrote: On Saturday, 1 October 2016 at 17:23:16 UTC, Uranuz wrote: [...] But these example fails. Oops. Looks like a bug( import std.stdio; import std.algorithm; import std.range; import std.string; [...] I created bug report on this:

How to make rsplit (like in Python) in D

2016-10-01 Thread Uranuz via Digitalmars-d-learn
How to make rsplit (like in Python) in D without need for extra allocation using standard library? And why there is no algorithms (or parameter in existing algorithms) to process range from the back. Is `back` and `popBack` somehow worse than `front` and `popFront`. I've tried to write

Re: How to make rsplit (like in Python) in D

2016-10-01 Thread Uranuz via Digitalmars-d-learn
On Saturday, 1 October 2016 at 16:45:11 UTC, Uranuz wrote: How to make rsplit (like in Python) in D without need for extra allocation using standard library? And why there is no algorithms (or parameter in existing algorithms) to process range from the back. Is `back` and `popBack` somehow

Re: How to make rsplit (like in Python) in D

2016-10-01 Thread Uranuz via Digitalmars-d-learn
On Saturday, 1 October 2016 at 17:23:16 UTC, Uranuz wrote: On Saturday, 1 October 2016 at 16:45:11 UTC, Uranuz wrote: How to make rsplit (like in Python) in D without need for extra allocation using standard library? And why there is no algorithms (or parameter in existing algorithms) to

Re: Question about alias and getOverloads

2020-01-28 Thread uranuz via Digitalmars-d-learn
I have read it two or three times just before writing my question: https://dlang.org/spec/declaration.html#alias And also a have read all the dlang docs several time few years ago... ;) But I don't see what do you you mean by writing that it was menioned here. I don't se any words or any

Re: D create many thread

2020-02-06 Thread uranuz via Digitalmars-d-learn
Is it also possible to set some custom thread name for GC threads in order to be distinguishable from other threads in utilities like `htop`? It would be handy...

Re: Question about alias and getOverloads

2020-01-30 Thread uranuz via Digitalmars-d-learn
I apologise that I need to revive this discussion again. But still I got answer to only one of my questions. I know that it is a common practice in programmers society that when someone asks more than 1 question. Then people who answer them usually choose only one of these questions that is

Question about alias and getOverloads

2020-01-28 Thread uranuz via Digitalmars-d-learn
Hello! I have a question about `alias` template parameter and getOverloads. For instance I have some code like this: // - import std; import core.thread; void foo(string param1) {} void foo(string param1, int param2) {} template Bar(alias Func) { // Next line is not valid now. This is

Re: Question about alias and getOverloads

2020-01-28 Thread uranuz via Digitalmars-d-learn
Thanks for advice ;) This looks like some `standard trick` that is yet not learnt or forgoten by me personally. The key was in using `parent` trait. This is what I failed to think of. This is working as expected: //- import std; import core.thread; import std.meta: AliasSeq; void

Re: Question about alias and getOverloads

2020-02-01 Thread uranuz via Digitalmars-d-learn
OK. Thanks. Created two reports related to these questions: https://issues.dlang.org/show_bug.cgi?id=20553 https://issues.dlang.org/show_bug.cgi?id=20555

Re: Difference between range `save` and copy constructor

2020-02-17 Thread uranuz via Digitalmars-d-learn
> Either way, generic code should never be using a range after > it's been copied, and copying is a key part of how > idiomatic, range-based code works in D. OK. Thanks for instructions. I shall give it a try.

Re: Difference between range `save` and copy constructor

2020-02-16 Thread uranuz via Digitalmars-d-learn
Actually, as I understand it, the main reason that save was introduced was so that classes could be forward ranges I have use of ranges as a classes in my code that rely on classes and polymorthism, but it's usually an InputRange that implements Phobos interface:

Re: Difference between range `save` and copy constructor

2020-02-16 Thread uranuz via Digitalmars-d-learn
It's very bad. Because there seem that when I use range based algorithm I need to take two things into account. The first is how algrorithm is implemented. If it creates copies of range inside or pass it by reference. And the second is how the range is implemented if it has value or reference

Re: Difference between range `save` and copy constructor

2020-02-16 Thread uranuz via Digitalmars-d-learn
On Sunday, 16 February 2020 at 12:38:51 UTC, Jonathan M Davis wrote: On Sunday, February 16, 2020 3:41:31 AM MST uranuz via Digitalmars-d-learn wrote: I have reread presentation: http://dconf.org/2015/talks/davis.pdf We declare that `pure` input range cannot be `unpoped` and we can't return

Re: Difference between range `save` and copy constructor

2020-02-16 Thread uranuz via Digitalmars-d-learn
Also I see the problemme that someone can think that it creates an input range, because he doesn't provide `save` method, but actually it creates forward range unexpectedly, because it is copyable. And it makes what is actually happening in code more difficult. Some algrorithm can take ranges

Re: Difference between range `save` and copy constructor

2020-02-16 Thread uranuz via Digitalmars-d-learn
In general for value-semantics and ref-semantics the different code is actually needed. But generic algorithm try to pretend that the logic is the same. But it's not true. But in wide subset of trivial algorithm it's true. So it's incorrectly interpolated that it's true for every case. The

Re: Difference between range `save` and copy constructor

2020-02-16 Thread uranuz via Digitalmars-d-learn
I have reread presentation: http://dconf.org/2015/talks/davis.pdf We declare that `pure` input range cannot be `unpoped` and we can't return to the previous position of it later at the time. So logically there is no sence of copying input range at all. So every Phobos algorithm that declares

Difference between range `save` and copy constructor

2020-02-15 Thread uranuz via Digitalmars-d-learn
I am interested in current circumstances when we have new copy constructor feature what is the purpose of having range `save` primitive? For me they look like doing basicaly the same thing. And when looking in some source code of `range` module the most common thing that `save` does is that it

Some code that compiles but shouldn't

2019-12-30 Thread uranuz via Digitalmars-d-learn
I have created library/ framework to handle JSON-RPC requests using D methods. I use some *template magic* to translate JSON-RPC parameters and return values from/ and to JSON. And I have encountered funny bug that at first was hard to find. My programme just segfaulted when call to this

Re: Some code that compiles but shouldn't

2019-12-30 Thread uranuz via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:09:13 UTC, MoonlightSentinel wrote: On Monday, 30 December 2019 at 18:18:49 UTC, uranuz wrote: So as you see I have added a lot of enforce to test if all variables are not null. But nothing was null and the reason of segfault were unclear. What about

Re: Some code that compiles but shouldn't

2019-12-30 Thread uranuz via Digitalmars-d-learn
On Monday, 30 December 2019 at 19:09:13 UTC, MoonlightSentinel wrote: On Monday, 30 December 2019 at 18:18:49 UTC, uranuz wrote: So as you see I have added a lot of enforce to test if all variables are not null. But nothing was null and the reason of segfault were unclear. What about

Why Throwable.message is not a property

2021-03-17 Thread uranuz via Digitalmars-d-learn
The question is why Throwable.message is not a @property?! It looks strange now, because "message" is not a *verb*, but a *noun*. So it's expected to be a property. Also because it is not a property in some contexts when I try to concatenate it with string without parentheses using "~"

Re: Why Throwable.message is not a property

2021-03-17 Thread uranuz via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 17:52:20 UTC, Adam D. Ruppe wrote: On Wednesday, 17 March 2021 at 17:46:27 UTC, uranuz wrote: Also because it is not a property in some contexts when I try to concatenate it with string without parentheses using "~" operator it fails Can you post some sample

Re: Why Throwable.message is not a property

2021-03-17 Thread uranuz via Digitalmars-d-learn
On Wednesday, 17 March 2021 at 19:38:48 UTC, Adam D. Ruppe wrote: On Wednesday, 17 March 2021 at 19:32:02 UTC, uranuz wrote: Seems that a problem with concatenation is because Throwable.message has const(char)[] type, but not string. This makes some inconvenience ;-) Yes, that's what I

std.file: read, readText and UTF-8 decoding

2023-09-21 Thread Uranuz via Digitalmars-d-learn
Hello! I have some strange problem. I am trying to parse XML files and extract some information from it. I use library dxml for it by Jonathan M Davis. But I have a probleme that I have multiple XML files made by different people around the world. Some of these files was created with Byte

Re: std.file: read, readText and UTF-8 decoding

2023-09-21 Thread Uranuz via Digitalmars-d-learn
Addition: Current solution to this problemme that I was found is: So I just check for BOM manually. Get length of bom.sequence and remove that count of items from beginning. But I dont' think that it's convenient solution, because `who knows` how much else issues with UTF could happend. And I

Re: std.file: read, readText and UTF-8 decoding

2023-09-22 Thread Uranuz via Digitalmars-d-learn
OK. Thanks for response. I wish that there it was some API to handle it "out of the box". Do I need to write some issue or something in order to not forget about this?