Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn

I wrote two regexp:


auto inlineCodeBlock = regex("`(.*?)`"); // -->  `(.*?)`
auto bigCodeBlock = regex("/`{3}[\\s\\S]*?`{3}/g"); // -->  
`{3}[\s\S]*?`{3}


First for for selection inline code block. Second for multi-line:

#Header
my header text

##SubHeader
my sub header text `foo inline code`

```
void foo()
{
   writeln("ppp");
}
```

###Sub3Header
my sub 3 text `bar inline code`

#Header2
my header2 text


It's work fine in online editor https://regex101.com/r/EC5WRu/1 
(sic! \\s\\S double escaped in D code).


But after compilation of code:

auto x = content.matchFirst(bigCodeBlock);
writeln(x);


print:
[]
[]

It's seems that D regexp work in another way. How can I test them?



Question about vibe.conf file

2017-03-05 Thread Suliman via Digitalmars-d-learn
I had seen some mentions about `vibe.conf` file in vibed docs. 
But can't understand it's structure and find examples of it's 
usage.





Re: Can't rending DT template

2017-02-26 Thread Suliman via Digitalmars-d-learn

On Sunday, 26 February 2017 at 12:31:21 UTC, Suliman wrote:

It's look like wrong error, because project is buildable.

So I have only one question. Can I do response not in .dt, but 
in .html?


It's seems that serveStaticFiles is only one normal way to get it 
work.


Re: Can't rending DT template

2017-02-26 Thread Suliman via Digitalmars-d-learn

It's look like wrong error, because project is buildable.

So I have only one question. Can I do response not in .dt, but in 
.html?


Can't rending DT template

2017-02-26 Thread Suliman via Digitalmars-d-learn

I have this code:

module pages;
import vibe.d;
import database;
import vibe.web.web;

class MyPages
{
  @path("/page1")  void getPage()
{
render!("home.dt");
}
}


The error: https://snag.gy/PtNeSs.jpg

Error: template instance 
vibe.web.web.render!"home.dt".render!("pages", 
"pages.MyPages.getPage").render.compileHTMLDietFile!("home.dt", 
req, DefaultFilters).exec!(StreamOutputRange!(OutputStream)) 
error instantiating


What I am doing wrong? Can I output html page instead of .dt?


Re: Vibe.d: Listening to port 8080 on external device doesn't work

2017-02-22 Thread Suliman via Digitalmars-d-learn

On Wednesday, 22 February 2017 at 00:38:30 UTC, aberba wrote:
Using vibe.d, I bind to port 8080 at 127.0.0.1 but I can't 
access server on my phone through hotspot using the external IP 
from ip addr on Linux. But 127.0.0 running Apache server works.


Don't if its vibe.d or OS (ubuntu 14.04)

How do I reached my vibe.d server in this case on my phone?


Not forget to open 8080 port of incoming connections.


Re: Multiplayer Game Project

2017-02-09 Thread Suliman via Digitalmars-d

Do you have skype?
I familiar with vibed and vue.js


Static array size?

2017-02-09 Thread Suliman via Digitalmars-d-learn

Docs says that:
"The total size of a static array cannot exceed 16Mb."
But when I am creation array of:
int [1000_000] x; // 1000_000 is equal ~ 0,95MB
app crush on start.

Should it's reserve this memory with guaranty? I mean that after 
app start it should take +0.95MB of RAM in task manager.


Re: mysql-native: preview3 (docs)

2017-02-07 Thread Suliman via Digitalmars-d-announce
@Nick, could you explain how connection working if I am close it 
after opening and only then do request to DB. See comments on SO.


Re: mysql-native: preview3 (docs)

2017-02-06 Thread Suliman via Digitalmars-d-announce

On Monday, 6 February 2017 at 20:32:24 UTC, Nick Sabalausky wrote:

https://github.com/Abscissa/mysql-native-experimental
Tag: v0.2.0-preview3

Just a few doc updates this time:

- Docs now include the `mysql.db.MysqlDB` to 
`mysql.pool.MySqlPool` change from preview2

- Clarified "Prepared" vs "PreparedImpl"
- Clarified "exec" vs "query"
- Rewrite the docs for ResultSet and ResultRange.

New docs:
http://semitwist.com/mysql-native-docs/v0.2.0-preview3


Big thanks! I am very glad that driver becoming better!
I have question about DB connection pattern if you could give any 
advices I would be very glad 
http://stackoverflow.com/questions/42083976/database-connection-pattern


Re: The reason of vibed slow down (request timeout)

2017-02-04 Thread Suliman via Digitalmars-d-learn

On Friday, 3 February 2017 at 07:44:15 UTC, crimaniak wrote:

On Friday, 3 February 2017 at 06:46:37 UTC, Suliman wrote:
If I open it's from VPS (as localhost:8080) it's work same as 
from Internet (no do not open at all).


If problem is reproducible on localhost - very good, just debug 
it. If you have memory leak and can't figure out source, try 
valgrind tool - it can help.



P.S. Русские комментарии в коде - плохой стиль.


This tool is nix only. I checked memory footprint, and it's show 
that app use impossible low memory


http://3.1m.yt/cCdzA.png

I reread sources and still don't understand where it can be 
problem place.


Re: Fiber overhead

2017-02-04 Thread Suliman via Digitalmars-d-learn

On Saturday, 4 February 2017 at 06:54:01 UTC, Ali Çehreli wrote:

On 02/03/2017 08:47 PM, Profile Anaysis wrote:

What is the overhead of using a fiber?


The performance overhead of call() and yield() are comparable 
to function calls because it's simply a few register 
assignments in each case. (Change the stack pointer, etc.)


Memory overhead is memory for call stack, size of which can be 
determined by the programmer.


Ali


Am I right understand that every yield(ed)/blocking function is 
delegate to processing in system thread?


But what will be if our code would do a lot of blocking 
functions? All of them will be delegate to system threads? If how 
many system threads will be used? I am asking because it will 
look like that in system threads we will get same problem that 
was solved by fibers.


The reason of vibed slow down (request timeout)

2017-02-02 Thread Suliman via Digitalmars-d-learn

I have simple web-app. Server part is based on vibed

http://194.87.235.42:8080/

I can't understand the reason of issue. after some days of work 
when I trying to open it in web-browser it's begin opening very 
slooowly, or like now does not opens at all. On mobile 
web-browser I am getting request-timeout.


How I can diagnostic the reason of such behavior?

The sources code is here https://github.com/bubnenkoff/Geoportal2


Re: mysql-native: preview2

2017-02-02 Thread Suliman via Digitalmars-d-announce
On Thursday, 2 February 2017 at 22:59:38 UTC, Nick Sabalausky 
wrote:

On 02/02/2017 09:46 AM, Suliman wrote:

Could you explain real case if rangification of ResultSet

http://semitwist.com/mysql-native-docs/v0.2.0-preview1/mysql/result/ResultSet.html


Does it's mean that I can write
foreach(x;result.empty) ? Or how to use it?


.empty just checks whether the range is empty, it returns 
true/false. You can't iterate over that. But yes, you can 
iterate over the ResultSet itself. Of course, ResultSet is 
random-access, so you can also index it like an array: 
"resultset[0]" returns the first row.


But how by looking at docs I can understand what data can be 
iterable, and what do not?


Re: mysql-native: preview2

2017-02-02 Thread Suliman via Digitalmars-d-announce
On Thursday, 2 February 2017 at 14:08:19 UTC, Steven 
Schveighoffer wrote:

On 2/2/17 1:50 AM, Suliman wrote:
On Thursday, 2 February 2017 at 05:28:10 UTC, Nick Sabalausky 
wrote:

Made a couple more long-needed changes while I'm at it:

https://github.com/Abscissa/mysql-native-experimental
Tag: v0.2.0-preview2

- For better clarity, renamed `mysql.db.MysqlDB` to
`mysql.pool.MySqlPool`.

- Package mysql.connection no longer acts as a package.d, 
publicly
importing other modules. To import all of mysql-native, use 
`import

mysql;`


Thanks! Could you explain about pool. I googled about it, and 
still

can't understand when it up new connections?

How can I imagine what connection is? Because without it hard 
to
understand what difference between connections with and 
without pool.


Am I right understand that if I use pool I can create 
connection
instance one time in DB class constructor end every new 
connection will

be created on demand?


Just to answer some of this, because I had questions about the 
pool as well.


The ConnectionPool is a mechanism to allow a limited resource 
(or a resource you want to limit, depending how you look at it) 
to be pooled for use. It's basically a free-list. It also 
abstracts away the details of opening a connection (i.e. server 
ip, username, password). It's nice because it makes opening a 
connection cleaner and straightforward.


The resulting connection can only be used in one fiber at a 
time, and the connection pool itself can only be used in one 
thread ever (there is no sharing of connection pools between 
threads). The resulting connection struct is reference counted, 
so it automatically releases back to the pool when it goes out 
of scope.


One issue I had with MysqlDB (now MySqlPool) is that it doesn't 
allow you to actually put a limit on the connections. In other 
words, you can't say "only allow 50 simultaneous connections". 
The effect is that you save the connection initialization, but 
you can't put a hard cap on connections used in your thread. If 
you have 10,000 fibers running at once, then you may get 10,000 
connections to the database that are left open. If each of 
those is a socket, you are consuming a lot of resources during 
down times.


Not to mention that the allocation of the 10,000th connection 
has to first go on a linear search through the 9,999 other 
connections to find an open one (this seems like it could be 
solved better with a linked-list freelist?).


See here: https://github.com/mysql-d/mysql-native/issues/74

BTW, I solved this by copying MysqlDB into my local project and 
adding the appropriate parameter to the constructor :)


-Steve


Do you mean that every new fiber open new connection? And when 
fiber is yield it's return connection to the pool?


Could you explain real case if rangification of ResultSet

http://semitwist.com/mysql-native-docs/v0.2.0-preview1/mysql/result/ResultSet.html

Does it's mean that I can write
foreach(x;result.empty) ? Or how to use it?


Re: mysql-native: API Refresh RC

2017-02-02 Thread Suliman via Digitalmars-d-announce
ResultSet querySet(Connection conn, string sql, 
ColumnSpecialization[] csa = null)


Could you explain last parameter?

`ColumnSpecialization[] csa = null`. I can't understand how to 
use it.


Could you give me your skype?

Also I think it's better to remove old deprecated methods at all, 
because it's add only mess.


Re: mysql-native: API Refresh RC

2017-02-02 Thread Suliman via Digitalmars-d-announce
On Thursday, 2 February 2017 at 04:04:15 UTC, Nick Sabalausky 
wrote:

On 02/01/2017 01:54 PM, Suliman wrote:
Also I can't understand what is SQL Command and what exec is 
doing if

it's returning ulong?




"struct Command" should not be used. It is old, and a bad 
design. This new release attempts to replace it with a better 
design. Hopefully, "struct Command" will be deleted in a later 
release.


The "exec" functions are for commands like INSERT, UPDATE, 
DELETE, CREATE, etc (it is *not* for SELECT). It is for things 
that do NOT return actual rows of data. The "exec" functions 
return "rows affected" - the number of rows that were affected 
by your INSERT, or UPDATE, etc. Usually people ignore that 
number, but it's information the server sends back, and is 
sometimes useful to some people. For example, SQL 
administration tools usually tell you "# rows affected" after 
you run an INSERT/UPDATE/etc.


If you are doing a SELECT, then you do NOT use "exec", you use 
"query" for SELECT. "query" returns a set of rows.


Summary:
-

SELECT: Use query() or querySet() or queryRow(), etc.

INSERT/UPDATE/DELETE/CREATE/DROP: Use exec(). Return value 
tells you how many rows were added/changed/deleted/etc.


Plz add this mention to readme.


Re: mysql-native: API Refresh RC

2017-02-02 Thread Suliman via Digitalmars-d-announce
mydb.lockConnection() does create a new connection if it needs 
to. And that WILL throw an exception if there's a problem 
connecting to the DB server. So your code above WILL catch an 
exception if the connection information (server 
address/port/login/etc) is wrong.


But it does not. I am getting Access Violation instead of the 
exception if connection credentials is wrong:


Authentication failure: Access denied for user 
'root'@'111.111.111.111' (using password: YES)


object.Error@(0): Access Violation

0x004436C0 in void database.Database.connect() at 
D:\code\CMS\source\database.d(34)

0x00403130 in _Dmain at D:\code\CMS\source\app.d(17)
0x00593C6F in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x00593C33 in void rt.dmain2._d_run_main(int, char**, extern (C) 
int function(char[][])*).runAll()

0x00593B34 in _d_run_main
0x004433CC in main at D:\code\CMS\source\app.d(7)
0x005F0929 in mainCRTStartup
0x769262C4 in BaseThreadInitThunk
0x774D0FD9 in RtlSubscribeWnfStateChangeNotification
0x774D0FA4 in RtlSubscribeWnfStateChangeNotification
Program exited with code 1





Re: mysql-native: preview2

2017-02-01 Thread Suliman via Digitalmars-d-announce

On Thursday, 2 February 2017 at 06:50:34 UTC, Suliman wrote:
On Thursday, 2 February 2017 at 05:28:10 UTC, Nick Sabalausky 
wrote:

Made a couple more long-needed changes while I'm at it:

https://github.com/Abscissa/mysql-native-experimental
Tag: v0.2.0-preview2

- For better clarity, renamed `mysql.db.MysqlDB` to 
`mysql.pool.MySqlPool`.


- Package mysql.connection no longer acts as a package.d, 
publicly importing other modules. To import all of 
mysql-native, use `import mysql;`


Thanks! Could you explain about pool. I googled about it, and 
still can't understand when it up new connections?


How can I imagine what connection is? Because without it hard 
to understand what difference between connections with and 
without pool.


Am I right understand that if I use pool I can create 
connection instance one time in DB class constructor end every 
new connection will be created on demand?


Ok, I read articles about pool, as I understood it's depend on of 
the implementation. For example method `close` in pool mode 
should not close connection, but return it to pool.


Could you tell about your implementation. Also actual question is 
can I open connection in constructor (during class instance 
creation) ?


Re: mysql-native: preview2

2017-02-01 Thread Suliman via Digitalmars-d-announce
On Thursday, 2 February 2017 at 05:28:10 UTC, Nick Sabalausky 
wrote:

Made a couple more long-needed changes while I'm at it:

https://github.com/Abscissa/mysql-native-experimental
Tag: v0.2.0-preview2

- For better clarity, renamed `mysql.db.MysqlDB` to 
`mysql.pool.MySqlPool`.


- Package mysql.connection no longer acts as a package.d, 
publicly importing other modules. To import all of 
mysql-native, use `import mysql;`


Thanks! Could you explain about pool. I googled about it, and 
still can't understand when it up new connections?


How can I imagine what connection is? Because without it hard to 
understand what difference between connections with and without 
pool.


Am I right understand that if I use pool I can create connection 
instance one time in DB class constructor end every new 
connection will be created on demand?


Re: mysql-native: API Refresh RC

2017-02-01 Thread Suliman via Digitalmars-d-announce
Also I can't understand what is SQL Command and what exec is 
doing if it's returning ulong?





Re: mysql-native: API Refresh RC

2017-02-01 Thread Suliman via Digitalmars-d-announce

On Wednesday, 1 February 2017 at 14:06:39 UTC, Suliman wrote:
Am I right understand that Connection instance should created 
at constructor and be one single for all class (and it will be 
reused by fibers) or am I wrong?


If yes, where I should to close it? To put
scope(exit) c.close();

In destructor?

If yes, does it behavior should be same as for working in vibed 
pool and without?


If I right understand class MysqlDB do not throw any exceptions, 
So I can't understand how to handle wrong connection.


if(connection is null)
{
try // useless
{
connection = mydb.lockConnection(); 
}
catch(Exception e)
{
writeln(e.msg);
}
}


Re: mysql-native: API Refresh RC

2017-02-01 Thread Suliman via Digitalmars-d-announce
Am I right understand that Connection instance should created at 
constructor and be one single for all class (and it will be 
reused by fibers) or am I wrong?


If yes, where I should to close it? To put
scope(exit) c.close();

In destructor?

If yes, does it behavior should be same as for working in vibed 
pool and without?


Re: Convert struct to set of fields and pass it's to constructor

2017-02-01 Thread Suliman via Digitalmars-d-learn

On Wednesday, 1 February 2017 at 13:51:28 UTC, Minty Fresh wrote:

On Wednesday, 1 February 2017 at 13:37:27 UTC, Suliman wrote:

Class constructor accept only set if fields like
this(string login, string pass)

Can I create structure, fill it, and than pass to constructor?

Like this:
```
import std.stdio;

struct ConnectSettings
{
string login;
string pass;
};
ConnectSettings cs;

void main()
{
 cs.login = "admin";
 cs.pass = "mypass";
}
```

and than pass to constructor it's like:

`... new SomeClass(cs)`


I tried, but get error, that ctor accept only fields list. Can 
I unroll struct to it?


tupleof is probably what you're looking for.
ie.

  new SomeClass(cs.tupleof);

That said, why not have the constructor accept the struct as a 
parameter?


Because it's implemented not by me, and I do not want to touch 
its realization.


Convert struct to set of fields and pass it's to constructor

2017-02-01 Thread Suliman via Digitalmars-d-learn

Class constructor accept only set if fields like
this(string login, string pass)

Can I create structure, fill it, and than pass to constructor?

Like this:
```
import std.stdio;

struct ConnectSettings
{
string login;
string pass;
};
ConnectSettings cs;

void main()
{
 cs.login = "admin";
 cs.pass = "mypass";
}
```

and than pass to constructor it's like:

`... new SomeClass(cs)`


I tried, but get error, that ctor accept only fields list. Can I 
unroll struct to it?










Re: Can't find the reason of issue: "std.file.FileException@std\file.d(360): path/to/file.conf:"

2017-02-01 Thread Suliman via Digitalmars-d-learn
Not even issue, but unhandled exception when access to 
nonexistent file.


Re: Can't find the reason of issue: "std.file.FileException@std\file.d(360): path/to/file.conf:"

2017-02-01 Thread Suliman via Digitalmars-d-learn

On Wednesday, 1 February 2017 at 11:39:46 UTC, Suliman wrote:

Full error log:

0x00580A4D in @trusted bool 
std.file.cenforce!(bool).cenforce(bool, const(char)[], 
const(wchar)*, immutable(char)[], uint)
0x00412AB6 in @safe void[] 
std.file.read!(immutable(char)[]).read(immutable(char)[], uint) 
at C:\D\dmd2\windows\bin\..\..\src\phobos\std\file.d(229)
0x00412060 in @safe immutable(char)[] 
std.file.readText!(immutable(char)[], 
immutable(char)[]).readText(immutable(char)[]) at 
C:\D\dmd2\windows\bin\..\..\src\phobos\std\file.d(417)
0x004116F2 in void 
dini.parser.IniSection.parse(immutable(char)[], bool) at 
C:\Users\Dima\AppData\Roaming\dub\packages\dini-2.0.0\dini\source\dini\parser.d(318)
0x00411EB7 in dini.parser.IniSection 
dini.parser.IniSection.Parse(immutable(char)[], bool) at 
C:\Users\Dima\AppData\Roaming\dub\packages\dini-2.0.0\dini\source\dini\parser.d(497)
0x004106AF in config.MyConfig config.MyConfig.__ctor() at 
D:\code\CoreCMS\source\config.d(30)

0x004033EA in _Dmain at D:\code\CoreCMS\source\app.d(7)
0x0055EBFB in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x0055EBBF in void rt.dmain2._d_run_main(int, char**, extern 
(C) int function(char[][])*).runAll()

0x0055EAC0 in _d_run_main
0x0041064C in main at D:\code\CoreCMS\source\APIInterface.d(7)
0x005BA001 in mainCRTStartup
0x73FC62C4 in BaseThreadInitThunk
0x77440FD9 in RtlSubscribeWnfStateChangeNotification
0x77440FA4 in RtlSubscribeWnfStateChangeNotification
Program exited with code 1

Can it be issue in external lib?


Yeah, it was issue in dini 2. dini 1 work fine.


Re: Can't find the reason of issue: "std.file.FileException@std\file.d(360): path/to/file.conf:"

2017-02-01 Thread Suliman via Digitalmars-d-learn

Full error log:

0x00580A4D in @trusted bool 
std.file.cenforce!(bool).cenforce(bool, const(char)[], 
const(wchar)*, immutable(char)[], uint)
0x00412AB6 in @safe void[] 
std.file.read!(immutable(char)[]).read(immutable(char)[], uint) 
at C:\D\dmd2\windows\bin\..\..\src\phobos\std\file.d(229)
0x00412060 in @safe immutable(char)[] 
std.file.readText!(immutable(char)[], 
immutable(char)[]).readText(immutable(char)[]) at 
C:\D\dmd2\windows\bin\..\..\src\phobos\std\file.d(417)
0x004116F2 in void 
dini.parser.IniSection.parse(immutable(char)[], bool) at 
C:\Users\Dima\AppData\Roaming\dub\packages\dini-2.0.0\dini\source\dini\parser.d(318)
0x00411EB7 in dini.parser.IniSection 
dini.parser.IniSection.Parse(immutable(char)[], bool) at 
C:\Users\Dima\AppData\Roaming\dub\packages\dini-2.0.0\dini\source\dini\parser.d(497)
0x004106AF in config.MyConfig config.MyConfig.__ctor() at 
D:\code\CoreCMS\source\config.d(30)

0x004033EA in _Dmain at D:\code\CoreCMS\source\app.d(7)
0x0055EBFB in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x0055EBBF in void rt.dmain2._d_run_main(int, char**, extern (C) 
int function(char[][])*).runAll()

0x0055EAC0 in _d_run_main
0x0041064C in main at D:\code\CoreCMS\source\APIInterface.d(7)
0x005BA001 in mainCRTStartup
0x73FC62C4 in BaseThreadInitThunk
0x77440FD9 in RtlSubscribeWnfStateChangeNotification
0x77440FA4 in RtlSubscribeWnfStateChangeNotification
Program exited with code 1

Can it be issue in external lib?


Can't find the reason of issue: "std.file.FileException@std\file.d(360): path/to/file.conf:"

2017-02-01 Thread Suliman via Digitalmars-d-learn

After building vibed project and running it I am getting error:

"std.file.FileException@std\file.d(360): path/to/file.conf: 
Системе не удается найти указанный путь." (System can't find 
selected path)


I even do not understand where is the error... It's do not seems 
that it's vibed issue.


Re: mysql-native: API Refresh RC

2017-02-01 Thread Suliman via Digitalmars-d-announce

Plz update dub package on code.dlang.org


Re: Why fatal log throw object.Error@(0) on console?

2017-01-30 Thread Suliman via Digitalmars-d-learn
I found in the docs mention "If data is logged with LogLevel 
fatal by default an Error will be thrown.". But what the reason 
of such behavior?


Why fatal log throw object.Error@(0) on console?

2017-01-30 Thread Suliman via Digitalmars-d-learn

import std.stdio;
import std.experimental.logger;

void main()
{
sharedLog = new FileLogger("New_Default_Log_File.log");

fatal("Fatal error: ");
}

All other log-levels write as expected log files, but `fatal` 
throw on console:



app.exe


object.Error@(0): A fatal log message was logged

0x0041291E
0x004138E7
0x0040206C
0x0040B277
0x0040B178
0x00407AB3
0x73FC62C4 in BaseThreadInitThunk
0x77440FD9 in RtlSubscribeWnfStateChangeNotification
0x77440FA4 in RtlSubscribeWnfStateChangeNotification

It's bug normal behavoiur?




When I should create structures with new keywords?

2017-01-26 Thread Suliman via Digitalmars-d-learn
In the past I asked Adam about when I should use keyword `new` 
with structures and got next answer:


"The File in the first one is put on the stack as a reference 
counted
local object whereas the second one would be on the garbage 
collected
heap, which often isn't what you want for files since you want to 
close

them when you're done.

Generally, D's structs often work best without the `new` keyword 
since

they can be made in place."

But I have read that stack size is very limited I tried to test 
two variants of reading big (20MB) text file:


auto file = File("test.txt", "r");
and
auto file = new File("test.txt", "r");

Tests does not show any significant difference in performance. 
But I still not understand where the data is location in first 
variant?


Re: Bug in documentation or misunderstanding it?

2017-01-26 Thread Suliman via Digitalmars-d-learn

On Thursday, 26 January 2017 at 18:42:29 UTC, Suliman wrote:

On Thursday, 26 January 2017 at 17:52:24 UTC, H. S. Teoh wrote:
On Thu, Jan 26, 2017 at 05:38:59PM +, Suliman via 
Digitalmars-d-learn wrote:
I read docs and can't understand what's wrong. Or I am do not 
understand it, or there is come mistake.


Let's look at function 
https://dlang.org/phobos/std_stdio.html#.File.byLine


auto byLine(Terminator = char, Char = char)(KeepTerminator 
keepTerminator =

No.keepTerminator, Terminator terminator = '\x0a')

what does mean first groups of scope: (Terminator = char, 
Char = char) ?


Those are compile-time parameters. You specify them in a 
compile-time argument list using the !(...) construct, for 
example:


auto lines = File("myfile.txt")
.byLine!(dchar, char)(Yes.keepTerminator, '\u263a');


T


So I am right about others items about for example that `=` is 
optional?


Why this code is work: `file.byLine(KeepTerminator.no, 'm')`


Re: Bug in documentation or misunderstanding it?

2017-01-26 Thread Suliman via Digitalmars-d-learn

On Thursday, 26 January 2017 at 17:52:24 UTC, H. S. Teoh wrote:
On Thu, Jan 26, 2017 at 05:38:59PM +, Suliman via 
Digitalmars-d-learn wrote:
I read docs and can't understand what's wrong. Or I am do not 
understand it, or there is come mistake.


Let's look at function 
https://dlang.org/phobos/std_stdio.html#.File.byLine


auto byLine(Terminator = char, Char = char)(KeepTerminator 
keepTerminator =

No.keepTerminator, Terminator terminator = '\x0a')

what does mean first groups of scope: (Terminator = char, Char 
= char) ?


Those are compile-time parameters. You specify them in a 
compile-time argument list using the !(...) construct, for 
example:


auto lines = File("myfile.txt")
.byLine!(dchar, char)(Yes.keepTerminator, '\u263a');


T


So I am right about others items about for example that `=` is 
optional?


Bug in documentation or misunderstanding it?

2017-01-26 Thread Suliman via Digitalmars-d-learn
I read docs and can't understand what's wrong. Or I am do not 
understand it, or there is come mistake.


Let's look at function 
https://dlang.org/phobos/std_stdio.html#.File.byLine


auto byLine(Terminator = char, Char = char)(KeepTerminator 
keepTerminator = No.keepTerminator, Terminator terminator = 
'\x0a')


what does mean first groups of scope: (Terminator = char, Char = 
char) ?


The second one as I understand it's options symbol `=` mean that 
there is some default values, so if I will call function I can do 
not set them, so predefined values will be used.


Am I right? And If I do not want predefined I can pass my own 
like:

`byLine(No.keepTerminator, 'SomeLetter')`

for example: `file.byLine(No.keepTerminator, 'a')`

But when I compile simple example I am getting compilation error: 
`undefined identifier 'No'`


Where I am wrong?




Re: module std.stream is deprecated - Will be removed by phobos version 2.070

2017-01-23 Thread Suliman via Digitalmars-d

On Monday, 23 January 2017 at 17:39:00 UTC, ixid wrote:
On Friday, 11 September 2015 at 21:16:06 UTC, Brian Schott 
wrote:
On Friday, 11 September 2015 at 20:29:56 UTC, Vladimir 
Panteleev wrote:
Apparently it was decided at DConf 2015 to remove std.stream 
and friends from Phobos.


Kill it with fire.


Speaking of killing things with fire (OT) - what's happening 
with the comma operator? I want delicious tuples like Go.


I have seen thread about improving tuples, but now I can't find 
it, could you remember me what people decided about how they 
could look in D?


Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn

You have *two* distinct strings here.


Yes, I understand, I am trying to find out how it's work on low 
level. Any ideas why zero is used?


Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn

On Sunday, 22 January 2017 at 15:51:01 UTC, Suliman wrote:

string str = "abc";
writeln(str.ptr);
str = "def";
writeln("last data: ", *(str.ptr));
writeln("old data: ", *(str.ptr-1)); // print nothing
writeln("old data: ", *(str.ptr-2)); // print c

It's look like that there is some gap between data, because `d` 
minus 1 should be `c`, but `c` I am getting only if I am doing 
`-2`. Why?


writeln("old data: ", cast(int)*(str.ptr-1));

#old data: 0

String is gaping by zero?? I thought they are continuously like

abcdef
---↑

Where `↑` is equal to `ptr`.


Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn

string str = "abc";
writeln(str.ptr);
str = "def";
writeln("last data: ", *(str.ptr));
writeln("old data: ", *(str.ptr-1)); // print nothing
writeln("old data: ", *(str.ptr-2)); // print c

It's look like that there is some gap between data, because `d` 
minus 1 should be `c`, but `c` I am getting only if I am doing 
`-2`. Why?


Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
Supported answer: you don't, it has infinite lifetime and 
you're claiming it is immutable, but then trying to pull the 
memory out from under it! The supported solution is simply to 
let the garbage collector manage it.


But..

//GC.free(str_ptr.ptr); // Error: function 
core.memory.GC.free (void* p) is not callable using argument 
types (immutable(char)*)



If you must call the function though, you can simply 
`cast(void*) str.ptr`, or use `char[]` up above instead of 
`string` when declaring it, so it has a mutable pointer to 
begin with. Since you are using .dup anyway, both declarations 
are equally legal.


string str = "aaa";
writeln(str.length); // print 3

str = "";
 	writeln(str.length); //print 4 expected 3+4=7 [aaa][] (2 
blocks)

GC.free(cast(void*) str.ptr);
writeln(str.length); //print 4


Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
str_ptr.ptr returns exactly the same thing as str.ptr or 
(*str_ptr).ptr, a pointer to the contents. When you write 
str_ptr, you print the pointer to the container.


So str.ptr is just shortcut?

Ok, but how to free memory from first located value (from `aaa`)?

I changed my code to next:

import std.stdio;
import std.string;
import core.memory;

void main()
{
string str = "aaa".dup;
string *str_ptr = 

writeln("before: ", str_ptr.ptr);// address of structure
writeln(*str_ptr.ptr); // address of data
str = ""; // now writing to structure new data, so ptr 
would be point to them

writeln("after: ", str_ptr.ptr);
writeln("length: ", str_ptr.length);
writeln("str_ptr point to: ", *str_ptr.ptr);

writeln(str_ptr);

writeln("before dealloc: ", str_ptr.length);
//GC.free(str_ptr.ptr); // Error: function 
core.memory.GC.free (void* p) is not callable using argument 
types (immutable(char)*)

writeln(str_ptr);
writeln("after dealloc: ", str_ptr.length);

}

But I can't call `GC.free(str_ptr.ptr)` on string type, only on 
`char []`




Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
You do not append to anything, only overwrite it. There is no 
reallocation because

"aaa".length == "bbb".length.


I changed my code to:
  str_ptr.length +=1;
  str[] = ""[];

But now it's print length 4 before and after writing "bbb" to 
`str`. I expected that size will be 3+4=7.


Re: Release Candidate 2.073.0-rc1

2017-01-20 Thread Suliman via Digitalmars-d-announce
If you just want a single executable, the default (libcmt) is 
good enough. It adds the C runtime as a static library in the 
link step.


I already tried it, but app is still require msvcr120.dll when 
run it's on another PC.


Re: Release Candidate 2.073.0-rc1

2017-01-19 Thread Suliman via Digitalmars-d-announce
On Thursday, 19 January 2017 at 19:22:07 UTC, Rainer Schuetze 
wrote:



On 19.01.2017 08:32, Suliman wrote:

http://dlang.org/changelog/2.073.0.html#mscrtlib-option
How can I set this flag in dub.json? I tried:
"dflags": [ "-mscrt=msvcrt" ]
but got error:
Error: unrecognized switch '-mscrt=msvcrt'


Ouch, the switch is actually called -mscrtlib. We need to fix 
the documentation...


Thanks! Now it's compile.

What version of cruntime (I tried: libcmtd, msvcrt msvcrtd) I 
should use to prevent depending my project on `msvcr120.dll`. Now 
when I try run vibed-based project on another PC it's give me 
error about absent `msvcr120.dll`.


Re: What do you use to generate documentation?

2017-01-19 Thread Suliman via Digitalmars-d-learn

On Thursday, 19 January 2017 at 18:09:20 UTC, Basile B. wrote:

On Thursday, 19 January 2017 at 15:20:37 UTC, Suliman wrote:
What do dflag: `-c do not link`. Should I pass it during the 
generation of the docs? dub is append it's automatically, but 
if I want to generate new docs every rebuild of app what is 
the reason to use this flag?


Oh no 2013 !! I thought it was a hot conversation. I've been 
trapped. Why didn't you create your own subject ?


It's seems that there is no any big changes in this deal.

ok. I know that there is a lot of other docs-gen, but who can 
give me answer about flag `-c` why its used?


Re: What do you use to generate documentation?

2017-01-19 Thread Suliman via Digitalmars-d-learn
What do dflag: `-c do not link`. Should I pass it during the 
generation of the docs? dub is append it's automatically, but if 
I want to generate new docs every rebuild of app what is the 
reason to use this flag?


Re: Release Candidate 2.073.0-rc1

2017-01-18 Thread Suliman via Digitalmars-d-announce

On Wednesday, 18 January 2017 at 13:48:06 UTC, Martin Nowak wrote:

First release candidate for 2.073.0.

http://dlang.org/download.html#dmd_beta 
http://dlang.org/changelog/2.073.0.html


Comes with a couple of more fixes: 
https://github.com/dlang/dmd/compare/v2.073.0-b2...v2.073.0-rc1 
https://github.com/dlang/druntime/compare/v2.073.0-b2...v2.073.0-rc1 https://github.com/dlang/phobos/compare/v2.073.0-b2...v2.073.0-rc1 https://github.com/dlang/dub/compare/v1.2.0-beta.2...v1.2.0-rc.1


Please report any bugs at https://issues.dlang.org

-Martin


http://dlang.org/changelog/2.073.0.html#mscrtlib-option
How can I set this flag in dub.json? I tried:
"dflags": [ "-mscrt=msvcrt" ]
but got error:
Error: unrecognized switch '-mscrt=msvcrt'


Re: Why my app require MSVCR120.dll?

2017-01-18 Thread Suliman via Digitalmars-d-learn

On Wednesday, 18 January 2017 at 09:54:43 UTC, Suliman wrote:

On Friday, 6 November 2015 at 18:34:45 UTC, Cauterite wrote:

On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote:
On Windows 7 it's work fine. On Windows 10 (clean install) 
it's do not start and require MSVCR120.dll


D doesn't make particularly heavy use of the C runtime, so 
there's a good chance you can link against a different C 
runtime DLL — preferably one that's always available by 
default like msvcrt.dll.


How can I link with msvcrt.dll ?


Or maybe there is way to statically link with MSVCR120.dll?


Re: Why my app require MSVCR120.dll?

2017-01-18 Thread Suliman via Digitalmars-d-learn

On Friday, 6 November 2015 at 18:34:45 UTC, Cauterite wrote:

On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote:
On Windows 7 it's work fine. On Windows 10 (clean install) 
it's do not start and require MSVCR120.dll


D doesn't make particularly heavy use of the C runtime, so 
there's a good chance you can link against a different C 
runtime DLL — preferably one that's always available by default 
like msvcrt.dll.


How can I link with msvcrt.dll ?


Re: Lets talk about fibers

2017-01-08 Thread Suliman via Digitalmars-d
"The type of concurrency used when logical threads are created is 
determined by the Scheduler selected at initialization time. The 
default behavior is currently to create a new kernel thread per 
call to spawn, but other schedulers are available that multiplex 
fibers across the main thread or use some combination of the two 
approaches" (с) dlang docs


Am I right understand that `concurrency` is just wrapper that 
hide implementation of tasks and fibers? So programmer can work 
with threads like with fibers and vice versa?


If yes, does it's mean that spawns is planing not but with system 
Scheduler, but with DRuntime Scheduler (or how it's can be 
named?) and all of them work in user-space?


Re: Lets talk about fibers

2017-01-08 Thread Suliman via Digitalmars-d
Simply picking a worker thread + worker fiber when task is 
assigned and sticking to it until finished should work good 
enough. It is also important to note though that "fiber" is not 
the same as "task". Former is execution context primitive, 
latter is scheduling abstraction. In fact, heavy load systems 
are likely to have many more tasks than fibers at certain spike 
points.


Could you explain difference between fibers and tasks. I read a 
lot, but still can't understand the difference.




Re: How to detect free/unfree memory segments?

2016-12-23 Thread Suliman via Digitalmars-d-learn

On Saturday, 24 December 2016 at 01:15:43 UTC, jkpl wrote:

On Friday, 23 December 2016 at 06:18:02 UTC, Suliman wrote:
I would like to visualize how GC works and display free/not 
free memory segments.

How I can understand which of them are used and which not?

Could anybody explain what dangerous of memory fragmentation 
in languages without GC? Am I right understand that there is 
stay some small memory chunks that very hard to reuse?


You start with a wrong assumption. The C malloc functions is 
not just a nasty and mean memory provider. Several 
implementations uses internally freelists. Which means that the 
gaps created by a free() may be filled again.


For example
- TCMallocator use free lists
- GCC C malloc use free lists (as stated here 
http://www.gnu.org/software/libc/manual/html_node/Freeing-after-Malloc.html)

- for snn.lib malloc (used by DMD win32) I can't say.


So there is no any problems with memory fragmentation and all 
used memory arr successfuly reuse?





Re: D future ...

2016-12-19 Thread Suliman via Digitalmars-d
The whole focus on C++ people marketing is simply wrong! Every 
time this gets mentioned in external forums, the language gets a 
pounding by people with the same argumentation. Why go for D 
when C++ 20xx version does it also.


+100

I totally agree with another part of post. Plus the docs is 
really suks, not only I can't write code without copy-past 
examples, because it's simply very hard to understand how to use 
one ore another function. Even simple writeln docs very bloated 
and 80% (mostly format futures) do not needed in real life


Re: Linux Kernel in D?

2016-12-17 Thread Suliman via Digitalmars-d

On Friday, 16 December 2016 at 16:12:38 UTC, D.Rex wrote:

A D port of the Linux Kernel?

https://github.com/whatsthisnow/ProjectD

Any thoughts on the project?


Linux is too bloated and there is no any reasons to re-implement 
it.


Re: DIP10005: Dependency-Carrying Declarations is now available for community feedback

2016-12-14 Thread Suliman via Digitalmars-d
On Wednesday, 14 December 2016 at 07:17:57 UTC, Jacob Carlborg 
wrote:

On 2016-12-14 03:23, Andrei Alexandrescu wrote:

On 12/13/16 9:22 PM, Hatem Oraby wrote:



with(import std.range)
bool equal(R1, R2) if (isInputRange!R1 && isInputRange!R2)
{ ... }


I considered this, then figured with is superfluous. -- Andrei


It could allow to have a better control of the scope which the 
import affects, i.e.:


with(import std.range)
{
  void foo(T) if (isInputRange!T)
  void bar(T) if (isInputRange!T)
}


Look very nice!


Re: DIP10005: Dependency-Carrying Declarations is now available for community feedback

2016-12-13 Thread Suliman via Digitalmars-d
On Tuesday, 13 December 2016 at 22:33:24 UTC, Andrei Alexandrescu 
wrote:

Destroy.

https://github.com/dlang/DIPs/pull/51/files


Imho such syntaxis construction make language harder to learn. D 
is already pretty complex, but DIPs should simplify language, but 
do not make its harder


Re: [OT] Is there anybody from D-community in Tel Aviv?

2016-12-11 Thread Suliman via Digitalmars-d
On Sunday, 11 December 2016 at 11:37:39 UTC, Shachar Shemesh 
wrote:

On 11/12/16 12:02, Suliman wrote:
On Saturday, 10 December 2016 at 08:10:46 UTC, Shachar Shemesh 
wrote:

On 10/12/16 09:25, Suliman wrote:
I plan to visit Tel Aviv from 31 December to 6-th of January 
of next

year.
Is there anybody who take part in D-community there?


There are about 30 D programmers in the Weka.io offices in 
Tel Aviv.
We'll gladly offer you coffee and conversation, if you want 
to drop by

the offices.

Shachar


Where do Weka.IO located? Could you give me any contacts, with 
to

talk/write, when I will be on place?


It's on our web site: http://weka.io. At the bottom of the page 
you can find the address. It's Beit Shamai 10, Tel Aviv.


You can coordinate when it's a good time to come with me :-)


Is 31 dec - 6 jan is working days
in Israel?


Work days in Israel are Sunday - Thursday. Otherwise, these are 
regular working days here. Note that Hanukkah is December 25 - 
January 1st this year, so many people might take leave of 
absence during those dates.


Shachar


Could you mail me your phone number to bubnenkoff at gmail com ?
I also have few question about transport that quite offtop for 
this thread.


Re: [OT] Is there anybody from D-community in Tel Aviv?

2016-12-11 Thread Suliman via Digitalmars-d
On Saturday, 10 December 2016 at 08:10:46 UTC, Shachar Shemesh 
wrote:

On 10/12/16 09:25, Suliman wrote:
I plan to visit Tel Aviv from 31 December to 6-th of January 
of next year.

Is there anybody who take part in D-community there?


There are about 30 D programmers in the Weka.io offices in Tel 
Aviv. We'll gladly offer you coffee and conversation, if you 
want to drop by the offices.


Shachar


Where do Weka.IO located? Could you give me any contacts, with to 
talk/write, when I will be on place? Is 31 dec - 6 jan is working 
days in Israel?


Re: [OT] Is there anybody from D-community in Tel Aviv?

2016-12-10 Thread Suliman via Digitalmars-d
On Saturday, 10 December 2016 at 08:10:46 UTC, Shachar Shemesh 
wrote:

On 10/12/16 09:25, Suliman wrote:
I plan to visit Tel Aviv from 31 December to 6-th of January 
of next year.

Is there anybody who take part in D-community there?


There are about 30 D programmers in the Weka.io offices in Tel 
Aviv. We'll gladly offer you coffee and conversation, if you 
want to drop by the offices.


Shachar


Cool! Thank! The first plan was just to visit Israel, but does 
Weka hire new people? I am looking for any related with D job.




function is not callable using argument types ()

2016-12-10 Thread Suliman via Digitalmars-d-learn

import std.stdio;
import std.concurrency;

void main()
{

void sp(int i)
{
receive((int i)
{
writeln("i: ", i);
});
}

auto r = new Generator!int(
{
foreach(i; 1 .. 10)
yield(i);
});

foreach(e;r)
{
		sp.send(e); //Error: function app.main.sp (int i) is not 
callable using argument types ()

}

}


What I am doing wrong? How "receive" can be named? Is it's method 
or what? Why it's without return type?







[OT] Is there anybody from D-community in Tel Aviv?

2016-12-09 Thread Suliman via Digitalmars-d
I plan to visit Tel Aviv from 31 December to 6-th of January of 
next year.

Is there anybody who take part in D-community there?


Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
As an aside, for security reasons you should use a prepared 
statement.
Even if it's server-side code and there is no any iteration with 
user data (they come as JSON)


Also, this is a decent usecase for scope(exit) but it should be 
put earlier in the function.


Am I right understand that `scope(exit)` should be always at top, 
otherwise it would not work (it's very strange because by the 
docs it's calling every time when function out of the scopes)?


Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
Looks like you forgot a call to format before the opening 
parenthesis.


should be:
string sqlinsert = format(`INSERT INTO usersshapes (userlogin,
 uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s',
 '%s') `, login, uploading_date, geometry_type, data);

because what ends up happening is :
string sqlinsert = data;
which is almost certainly not what you want.


So all string substitute must be called with `format`?



because what ends up happening is :
string sqlinsert = data;
which is almost certainly not what you want.


I thought it's possible to write:

string data = "foo"
string sqlinsert = data

or am I wrong?




Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn

On Sunday, 27 November 2016 at 11:21:58 UTC, drug007 wrote:

On 27.11.2016 14:07, Suliman wrote:

I am getting deprecation message:
"Using the result of a comma expression is deprecated" on this 
code:


string sqlinsert = (`INSERT INTO usersshapes (userlogin, 
uploading_date,

geometry_type, data) VALUES ('%s', '%s', '%s', '%s') `, login,
uploading_date, geometry_type, data);

What's wrong with it?
Didn't you miss something like class/structure/function before 
"(`INSERT..."? What result do you expect?


	void dbInsert(string login, string uploading_date, string 
geometry_type, string data)

{

Statement stmt = conn.createStatement();
		string sqlinsert = (`INSERT INTO usersshapes (userlogin, 
uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', 
'%s') `, login, uploading_date, geometry_type, data);

stmt.executeUpdate(sqlinsert);
scope(exit) stmt.close(); // closing
}

full code.


Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn

I am getting deprecation message:
"Using the result of a comma expression is deprecated" on this 
code:


string sqlinsert = (`INSERT INTO usersshapes (userlogin, 
uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', 
'%s') `, login, uploading_date, geometry_type, data);


What's wrong with it?


Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
On Thursday, 17 November 2016 at 18:02:02 UTC, Jesse Phillips 
wrote:

On Thursday, 17 November 2016 at 17:54:23 UTC, Suliman wrote:
Ok, but when the logger class may be more helpful that 
function usage?


You'd use the logger class when you need to make customizations 
or have multiple logging schemes.


I'd expect Vibe.d allows you to override the global logging 
object. You could then inherit from the Logger class, customize 
the behavior and assign it to the global logger which is used 
by all the libraries which just call the log() function.


For example I need to write all logs to file. I see this 
function, that seem set some global file name.

"setLogFileSets a log file for disk file logging."

But would it name accessible from anywhere or it would be visible 
inly from this scope? If yes is there any way to make it's global?


Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn

On Thursday, 17 November 2016 at 17:45:31 UTC, Stefan Koch wrote:

On Thursday, 17 November 2016 at 17:42:44 UTC, Suliman wrote:
On Thursday, 17 November 2016 at 16:46:37 UTC, Steven 
Schveighoffer wrote:

On 11/17/16 11:28 AM, Suliman wrote:

[...]


D does not require classes to write functions. All a class 
member function is anyway is a function with an implied class 
instance parameter.


-Steve


Ok, but what profit? Could you give me an example (for example 
with logger)?


for example writeln.
You would not want to create a stdio object just to call 
writeln.


Ok, but when the logger class may be more helpful that function 
usage?


Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
On Thursday, 17 November 2016 at 16:46:37 UTC, Steven 
Schveighoffer wrote:

On 11/17/16 11:28 AM, Suliman wrote:
There is some functions that can be called without creation of 
class.

For example: http://vibed.org/api/vibe.core.log/

As I understand I can create write log in two way. First 
create instance

of Logger, second simply call function.

Why it's done so? Just as shortcut? But is I create class it's 
look very
poor http://vibed.org/api/vibe.core.log/FileLogger and I have 
only one

needed method: ` put Writes part of a log line message. `


D does not require classes to write functions. All a class 
member function is anyway is a function with an implied class 
instance parameter.


-Steve


Ok, but what profit? Could you give me an example (for example 
with logger)?


Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
There is some functions that can be called without creation of 
class.

For example: http://vibed.org/api/vibe.core.log/

As I understand I can create write log in two way. First create 
instance of Logger, second simply call function.


Why it's done so? Just as shortcut? But is I create class it's 
look very poor http://vibed.org/api/vibe.core.log/FileLogger and 
I have only one needed method: ` put 	Writes part of a log line 
message. `


Re: Earthquakes - New Zealand

2016-11-14 Thread Suliman via Digitalmars-d
On Monday, 14 November 2016 at 09:09:59 UTC, Paolo Invernizzi 
wrote:

On Sunday, 13 November 2016 at 18:03:59 UTC, Suliman wrote:

On Sunday, 13 November 2016 at 12:17:22 UTC, rikki cattermole

But it's very interesting that right now I am doing portal 
about Earthquakes on D. It's now not ready to work (because 
problem with new version of Vue-js)


I'm also using Vue 2 and D: it's really an interesting combo

/Paolo


Could you help me with migration to Vue2? I can't get it work :(
Give me you skype or email plz


Re: Earthquakes - New Zealand

2016-11-13 Thread Suliman via Digitalmars-d
On Sunday, 13 November 2016 at 12:17:22 UTC, rikki cattermole 
wrote:

Hello everyone!
So to summarize New Zealand right now is being hit with some 
major earthquakes.


But don't fret, I'm ok.
There is a couple of other members in NZ, so please do let us 
know that you're safe!


Now, for W, is there a plan for core members to report in to 
check that everyone is ok in an emergency (where ever they may 
be)?


P.S.
If you want live updates on what I'm going through, feel free 
to look at[0].


[0] http://www.canterburyquakelive.co.nz/Browse


My regrets :(

But it's very interesting that right now I am doing portal about 
Earthquakes on D. It's now not ready to work (because problem 
with new version of Vue-js)


The very early alpha is located here http://188.227.17.149:8080/
the server maybe not reachable.


Re: SecureD - A simple cryptography library for D

2016-11-13 Thread Suliman via Digitalmars-d-announce
It would take some research, but the native Botan library makes 
heavy use of C++ templates

There is native lib https://github.com/etcimon/botan

Some people with whom I talked said that botan is too low level 
for them and it's hard for them to use it. So your lib maybe very 
good wrap on top of it.


Re: SecureD - A simple cryptography library for D

2016-11-12 Thread Suliman via Digitalmars-d-announce
Is its possible to make its wrap on botan instead of openssl? 
Some of developers have problems with openssl because it's 
require openssl lib. But botan is more native but much more 
lowlevel.  So its hard to use.


Add format future to Phobos date time

2016-11-10 Thread Suliman via Digitalmars-d
Date formating is very common operation. Is it's possible to add 
this future to Phobos datetime module?


There is already external lib 
https://github.com/cmays90/datetimeformat but I think that is's 
much better to have in base lib.


Re: libcurl

2016-10-21 Thread Suliman via Digitalmars-d
On Saturday, 22 October 2016 at 01:20:52 UTC, Andrei Alexandrescu 
wrote:
Guess we need to get ready! 
https://curl.haxx.se/mail/lib-2016-10/0076.html -- Andrei


I think that it much better to force 
https://github.com/ikod/dlang-requests developing its much easier 
than curl and its native




Re: scone 1.2.0

2016-10-11 Thread Suliman via Digitalmars-d-announce

On Monday, 10 October 2016 at 19:50:53 UTC, vladdeSV wrote:
scone, Simple CONsole Engine, version 1.2.0 has just been 
released!

https://github.com/vladdeSV/scone/releases/tag/v1.2.0

This version includes a restructure of the whole project 
(should not affect applications), and the addition of a 
progress bar to the current UI library + bug fix.


Feedback is always appreciated!


Could you add example of progress bar?


Re: code-d 0.12.0 - The user friendly release (code-d for noobs)

2016-10-04 Thread Suliman via Digitalmars-d-announce

Please, add Sublime support


Re: [GSoC] std.experimental.xml is now a PR!

2016-10-02 Thread Suliman via Digitalmars-d-announce

On Sunday, 28 August 2016 at 06:28:35 UTC, NVolcz wrote:
On Wednesday, 24 August 2016 at 09:31:44 UTC, Lodovico Giaretta 
wrote:

Hi!

I'm pleased to announce that my GSoC project, a replacement 
for the outdated std.xml, is now a Phobos PR! [1] It is an 
(almost complete) mirror of my repository [2], which is also 
available on DUB [3].


I would like to thank my mentor Robert burner Schadek for his 
great support and everybody who already gave some feedback 
during these months.


The PR is not meant for immediate merging. Some things still 
need improvement (docs/unittests/...) while others will come 
in a second iteration (advanced DTD handling). It is meant to 
for some reviews, focusing mainly on the design and usability 
of the library.


In the PR description you will find all the details, including 
a nice "wishlist" of things that I found missing in D during 
the development and some open questions.


So, if you have any consideration/suggestion, drop a line here 
or on the PR, and if you find bugs, don't hesitate to file an 
issue on the issue tracker of my repository.


Thank you very much!

[1] https://github.com/dlang/phobos/pull/4741
[2] https://github.com/lodo1995/experimental.xml
[3] https://code.dlang.org/packages/std-experimental-xml


I like the new cursor API very much since it enables new use 
cases that are were hard to do with the old API. Thanks for 
your hard work!


Examples are a bit scares. I like the way Phobos documents 
every functions with an unittest/example. I'm all for that!


Another thing I encountered some days ago was that the default 
error handler is using asserts to signal error. 
https://github.com/lodo1995/experimental.xml/issues/30
It is not obvious from the API that you're required to have a 
error handler.

Two ideas:
Use exceptions instead of asserts. This way it is recoverable 
in the default use case.

Require a error handler in the constructor.


Examples still sucks. Hard to start use lib.


Re: Beta 2.072.0-b1

2016-10-02 Thread Suliman via Digitalmars-d-announce

On Saturday, 1 October 2016 at 20:57:17 UTC, Martin Nowak wrote:

First beta for the 2.072.0 release.

This release comes with many new phobos features, native TLS 
support on OSX, the first bunch of @safety enhancements (try 
-transition=safe), and a few smaller language and compiler 
additions.


This is also the first dmd release to include dub.

http://dlang.org/download.html#dmd_beta 
http://dlang.org/changelog/2.072.0.html


Unfortunately we still need to resolve a regression that causes 
issues with EncodingScheme.create 
(https://issues.dlang.org/show_bug.cgi?id=16291), you might run 
into problems when using std.net.curl.


In case you run into a yet unknown module cycle, this is
likely due to the fixed cycle detection.
We're still working on a -DRT-cyclecheck=printonly switch to 
allow

making those non-fatal.
https://github.com/dlang/druntime/pull/1602#issuecomment-248447332

Please report any bugs at https://issues.dlang.org

-Martin


Sorry, but when new libs will be included?
XML (from GSoC) https://github.com/lodo1995/experimental.xml
std_data_json https://github.com/s-ludwig/std_data_json

I think it's better to include them now to std.experimental to 
help people start adopt projects to them.


Re: Question about __treats

2016-09-21 Thread Suliman via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 07:09:01 UTC, rikki cattermole 
wrote:

On 21/09/2016 7:06 PM, Suliman wrote:
It's seems that __treats is language keyword that help to get 
info from

compile-time. But there is also lib named std.traits

and I can't understand difference

https://dlang.org/spec/traits.html
https://dlang.org/phobos/std_traits.html

Could you explain the difference?


Simple, __traits or __treats as you called it is implemented by 
the compiler.
But std.traits is all implemented in the standard library as 
user D code.


If you can do it with std.traits you should. Otherwise __traits.
So std.traits is a bit higher level and there are more things 
available there as adding more __traits is a bit rare.


So for example to get All Members of class I should use 
allMembers from __traits, because it's seems that std.traits do 
not have such future.


Question about __treats

2016-09-21 Thread Suliman via Digitalmars-d-learn
It's seems that __treats is language keyword that help to get 
info from compile-time. But there is also lib named std.traits


and I can't understand difference

https://dlang.org/spec/traits.html
https://dlang.org/phobos/std_traits.html

Could you explain the difference?


Re: dub: how to update package?

2016-09-17 Thread Suliman via Digitalmars-d-learn
On Saturday, 17 September 2016 at 07:25:29 UTC, Intersteller 
wrote:
I have a dub project, is there a way to update to get the 
latest package?


dub upgrade


Re: I hate new DUB config format

2016-09-14 Thread Suliman via Digitalmars-d
Sönke Ludwig, really sorry. It's look my big mistake. I looked at 
SDL more detail, and this format is much better than JSON.


I hope a lot of people is changed their position too.


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-08 Thread Suliman via Digitalmars-d-announce

On Wednesday, 7 September 2016 at 18:27:41 UTC, WebFreak001 wrote:

On Wednesday, 7 September 2016 at 18:14:29 UTC, Suliman wrote:

You could look my PC with TeamViewer


Ok problem fixed. The config was invalid, it needs to look like 
this:


{
"d.stdlibPath": [
"C:\\D\\dmd2\\src\\phobos",
"C:\\D\\dmd2\\src\\druntime\\import"
]
}

Just forgot these braces {} to make it valid json


It's possible to integrate workspace-d with Sublime?


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce

On Wednesday, 7 September 2016 at 18:10:23 UTC, WebFreak001 wrote:

On Wednesday, 7 September 2016 at 18:09:23 UTC, Suliman wrote:

On Wednesday, 7 September 2016 at 18:08:14 UTC, Suliman wrote:

If open working folder: https://snag.gy/MnTJtB.jpg


https://snag.gy/5r2REm.jpg


it should work now if you enter at least one character and then 
ctrl-space (and maybe also escape before that to close the 
vscode internal auto complete thing)


Do not work :(

You could look my PC with TeamViewer

ID 179 707 485
pass 6543


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce

On Wednesday, 7 September 2016 at 18:08:14 UTC, Suliman wrote:

If open working folder: https://snag.gy/MnTJtB.jpg


https://snag.gy/5r2REm.jpg


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce

If open working folder: https://snag.gy/MnTJtB.jpg


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce

On Wednesday, 7 September 2016 at 18:00:45 UTC, WebFreak001 wrote:

On Wednesday, 7 September 2016 at 17:55:59 UTC, Suliman wrote:
Sorry, I do not understand what do you mean? Clean solution 
with empty project? And what part? Just screenshot of main 
window?


Ctrl-Shift-P -> Toggle Developer Tools

then go to console at the top and there are a lot of debug 
messages from code-d


This?

https://snag.gy/QP0OCs.jpg
https://snag.gy/2VGoKF.jpg


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce

On Wednesday, 7 September 2016 at 17:26:04 UTC, WebFreak001 wrote:

On Wednesday, 7 September 2016 at 17:24:45 UTC, Suliman wrote:

On Wednesday, 7 September 2016 at 17:21:17 UTC, Suliman wrote:

On Wednesday, 7 September 2016 at 17:08:36 UTC, Suliman wrote:

"d.stdlibPath": [
 "C:\\D\\dmd2\\src\\phobos",
 "C:\\D\\dmd2\\src\\druntime\\import"
]

I check path, look like this is correct (al lst they are 
exists).


But I still do not getting surrestion for import like std. 
and for any Phobos functions like writeln etc


Hm... Does it's need time for cashing symbols? It's seems 
that work, but I still not understand if it's ok or not.


https://snag.gy/9QgzKn.jpg


that happens when it can't find any auto completions. Can you 
send a screenshot of the developer tools right after startup + 
attempt to autocomplete (try to avoid hovering over symbols to 
make the debug output smaller)


Sorry, I do not understand what do you mean? Clean solution with 
empty project? And what part? Just screenshot of main window?


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce

On Wednesday, 7 September 2016 at 17:21:17 UTC, Suliman wrote:

On Wednesday, 7 September 2016 at 17:08:36 UTC, Suliman wrote:

"d.stdlibPath": [
 "C:\\D\\dmd2\\src\\phobos",
 "C:\\D\\dmd2\\src\\druntime\\import"
]

I check path, look like this is correct (al lst they are 
exists).


But I still do not getting surrestion for import like std. and 
for any Phobos functions like writeln etc


Hm... Does it's need time for cashing symbols? It's seems that 
work, but I still not understand if it's ok or not.


https://snag.gy/9QgzKn.jpg


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce

On Wednesday, 7 September 2016 at 17:08:36 UTC, Suliman wrote:

"d.stdlibPath": [
 "C:\\D\\dmd2\\src\\phobos",
 "C:\\D\\dmd2\\src\\druntime\\import"
]

I check path, look like this is correct (al lst they are 
exists).


But I still do not getting surrestion for import like std. and 
for any Phobos functions like writeln etc


Hm... Does it's need time for cashing symbols? It's seems that 
work, but I still not understand if it's ok or not.


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce

"d.stdlibPath": [
 "C:\\D\\dmd2\\src\\phobos",
 "C:\\D\\dmd2\\src\\druntime\\import"
]

I check path, look like this is correct (al lst they are exists).

But I still do not getting surrestion for import like std. and 
for any Phobos functions like writeln etc





Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-07 Thread Suliman via Digitalmars-d-announce
And to get the visual studio code extension, simply search for 
`code-d` in >the extensions manager. It will pop up as `D 
Programming Language (code-d)`


So to get it work I should place dcd-client.exe dcd-server.exe 
dscanner.exe and workspace-d.exe in dir that set in PATH (for me 
it's C:\D\dmd2\windows\bin ) right?


But after it it's do not seems to be working:

http://img.ctrlv.in/img/16/09/07/57cfc3120b3c5.png

What I am doing wrong?


How it's better to store data from DB?

2016-09-05 Thread Suliman via Digitalmars-d-learn
Usually I am storing daba from DB as array of structures. 
Something like:


struct MyData
{
 int id;
 string name;
 int age;
}

MyData mydata;

Then I am creating array of structures:
MyData [] mydatas;

And fill data in my code. Then append it to `mydatas` to get it 
iterable.


But is it's good? Maybe there there is better way?

I need main -- be able iterate thru the data. Any other variants?


Re: Beta release vibe.d 0.7.30-beta.1

2016-09-01 Thread Suliman via Digitalmars-d-announce

On Thursday, 1 September 2016 at 07:32:43 UTC, Sönke Ludwig wrote:

Am 31.08.2016 um 16:56 schrieb Martin Tschierschke:
On Wednesday, 31 August 2016 at 09:00:47 UTC, Sönke Ludwig 
wrote:

Am 31.08.2016 um 10:57 schrieb Sönke Ludwig:

[...]

All changes:
https://github.com/rejectedsoftware/vibe.d/blob/master/CHANGELOG.md

DUB package:
http://code.dlang.org/packages/vibe-d/0.7.30-beta.1

[1]: http://code.dlang.org/packages/vibe-sdlang

[2]: http://code.dlang.org/packages/diet-ng

Nice to read on the ongoing progress!

Can you give a road map of what will be next, may be as an 
interview to

the D Blog?


My intention was to write something up since DConf this year, I 
just didn't manage to do it so far (the last months were 
extremely busy with other things). But it's still on the TODO 
list.



When do you think vibe's version will be 1.0.0?


I'm currently still working on vibe-core [1], which will be the 
1.0.0 of the core parts of the current vibe-d package. The API 
is more or less backwards compatible, but the insides have been 
thoroughly redesigned based on the experiences and language 
changes of the past years. I hope to get that into beta in 
weeks to (few) months and it is more or less just held back by 
the final decision for an event loop abstraction.


Similarly, diet-ng will be the 1.0.0 of the Diet template 
render module. The rest of the sub packages will get the same 
treatment once vibe-core is done. From then on, they will all 
receive their own individual version numbers, according to 
their particular development pace.


[1]: https://github.com/vibe-d/vibe-core


It's not problem with backward compatibility. Much important is 
easy to use and good docs.


Re: Do we need a FAQ page?

2016-08-29 Thread Suliman via Digitalmars-d
I already wrote one alternative version. Dlang.ru is down, but on 
page there is germany translation version 
http://forum.dlang.org/thread/vxmieatguqfkwgzli...@forum.dlang.org


D-ideas collection

2016-08-27 Thread Suliman via Digitalmars-d
We already have DIPs, but I think we should have place for 
collecting good ideas that can be integrated in D. Most people 
from here prefer posting it's on forum, but such topics (like 
ideas from new version of C#) is go down in few days.


Fro example now I read about interesting future in Dart:
With 1.19 we introduce support for an optional trailing comma 
after the last argument of a call and the last parameter of a 
function declaration. This makes code editing much easier:

https://2.bp.blogspot.com/-kVBJlnXby54/V8DJqaZsvwI/NeU/suPDhaZcdsEvN1DuYy8669JJ-W6x1zX1wCLcB/s1600/ReorderCode.gif

And I do not know where to post it.


Re: Few questions about concurrency

2016-08-27 Thread Suliman via Digitalmars-d-learn
Message passing is an alternative to relying on globals + 
mutex's. In the end its implemented by a global + stack FIFO 
(mailbox).


Where it's better? Could you give an example?


Ring transition e.g. system calls are not all that expensive.
Its what the kernel does with that system call that is 
problematic to performance.


Not fully understand. In first sentence you are saing that is not 
expensive and in second you are saying about "kernel does with 
that system call that is problematic to performance"


For example vibed is based on Fibers. Does it's mean that:

void handleRequest(HTTPServerRequest req,
   HTTPServerResponse res)
{
if (req.path == "/")
res.writeBody("Hello, World!", "text/plain");
}

is fiber-function?


Few questions about concurrency

2016-08-27 Thread Suliman via Digitalmars-d-learn
Hello! I am still attempt to better understand how concurrency 
works. I read a lot of info but still misunderstood some 
key-points.

Here is my thought about it and questions:

1. There is OS threads. Context-switching is very expensive 
because during it we should to save ALL CPU registers to RAM. 
Accessing to RAM is slowly up 200-300 times then accessing to 
registers, so dumping/restoring registers take a lot of time. 
Right?
1.1 During context-switching OS is go to kernel-mode (ring-0). I 
have heard opinion that it's cost a lot, but can't understand is 
it true and why it cost a lot?


2. Message passing is superstructure of threads. Right? When it 
can be helpful? Any user-case please.
2.1 Can simple threads pass data/messages to each other without 
message passing?


3. Fibers is threads that works in user-mode (rather in single 
kernel-thread OS do not see them, it see only 1 own Thread).
3.1 Fibers are switch explicitly. If do not call yield 
mother-thread will be hang on.
3.2 Where fibers store CPU register state in moment of switching 
between fibers? In memory? But then what difference with 
context-switching (that take a lot of time to save/restore 
registers state)?


Please correct me where I am wrong and highlight where I am right.


<    1   2   3   4   5   6   7   8   9   >