Re: could someone test support for Asian languages in nanogui port?

2018-05-05 Thread Binghoo Dang via Digitalmars-d-learn

On Friday, 4 May 2018 at 10:40:52 UTC, drug wrote:
I port nanogui, but besides porting I'd like to improve it 
using great capabilities of D language provides. One of them is 
utf support, so I added support for Asian languages to 
nanogui.TextBox. But I'm not sure I've did it well and so I'd 
like to ask someone to test it using the following:

```
git clone --recursive https://github.com/drug007/nanogui.git
cd nanogui
git checkout textbox # TextBox exists in this branch only
dub --config=sdl # Keyboard events provided only by SDL2 
backend only

```

On the right side there will be a window with four text boxes 
with russian, english, japanese and chinese text respectively. 
It would be nice to get some feedback from users - probably I 
did something totally wrong. Also I'm curious does it worth 
efforts?


hi,

I'm a Chinese, and I just have done the test. I also copied some 
Japanese text from Dlang twitter channel and added some Chinese 
wide punctuation Char.


And It's all seems displayed correctly.

The resulting screenshot is here:  
https://pasteboard.co/HjRmOYg.png


The only problem is that the font style simply looks strange. You 
can see the 'normal' text display in Win10 by default like this:  
https://pasteboard.co/HjRrigh.png


And the font problem is probably related to SDL or GL, for all UI 
based on GL or SDL, they all have the same problem. Dlangui also 
has the same situation, that's why I just did not use Dlangui for 
a production project.


But, Anyway, the text is displayed correctly.

Great work for doing this! Dlang needs a great GUI framework.


Re: Error: module `hello` is in file 'hello.d' which cannot be read

2018-05-05 Thread Alex via Digitalmars-d-learn
On Saturday, 5 May 2018 at 17:13:08 UTC, IntegratedDimensions 
wrote:


You need to make sure hello.d is in the current dir

dir C:\D

does hello.d show up?

If not, then dmd can't find it and you have to tell it where it 
is or be in the right location.


type

dmd ThereIsNowFileHere12342123242231231412.d

and you will get the same error message.


You have to be right. I removed the directory and started making 
de hello world file again and now it works.


Thank you to everyone?

Alex




Re: Error: cannot deduce function from argument types

2018-05-05 Thread Sisor via Digitalmars-d-learn

On Saturday, 5 May 2018 at 17:06:13 UTC, Neia Neutuladh wrote:

On Saturday, 5 May 2018 at 16:42:12 UTC, Sisor wrote:
Error: template std.string.stripRight cannot deduce function 
from argument types


You used 
http://dpldocs.info/experimental-docs/std.string.stripRight.html


This function only takes one argument and strips whitespace.

You want 
http://dpldocs.info/experimental-docs/std.algorithm.mutation.stripRight.1.html


This function can take two arguments and strips the second from 
the first.


https://dlang.org/phobos/std_string.html#.stripRight has an 
overload with a second argument.


The std.algorithm.mutation version does only work with my second 
solution, which solves the problem. So thanks!


But I still don't understand the problem.


Re: Error: module `hello` is in file 'hello.d' which cannot be read

2018-05-05 Thread Alex via Digitalmars-d-learn

On Saturday, 5 May 2018 at 12:26:20 UTC, Bauss wrote:

Try to add

module hello;

To the top of the file


Still not working. I tryed both module hello; and module 'hello';



C:\D\dmd2\sources>dmd hello.d
Error: module `hello` is in file 'hello.d' which cannot be read
import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import

C:\D\dmd2\sources>


Re: Error: module `hello` is in file 'hello.d' which cannot be read

2018-05-05 Thread IntegratedDimensions via Digitalmars-d-learn

On Friday, 4 May 2018 at 23:29:12 UTC, Alex wrote:

Hi

I just installed D on my windows 10 and want to try to compile 
a hello world. My source is a classical


import std.stdio;
void main() {
writeln("Hello, World!");
}

And I try to compile and get

C:\D>dmd hello.d
Error: module `hello` is in file 'hello.d' which cannot be read
import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import

What do I do wrong ?

D is installed at de root of C:, and the hello.d source code is 
at C:\D\dmd2\sources.


Thank you to you

Alex


You need to make sure hello.d is in the current dir

dir C:\D

does hello.d show up?

If not, then dmd can't find it and you have to tell it where it 
is or be in the right location.


type

dmd ThereIsNowFileHere12342123242231231412.d

and you will get the same error message.





Re: Error: cannot deduce function from argument types

2018-05-05 Thread Neia Neutuladh via Digitalmars-d-learn

On Saturday, 5 May 2018 at 16:42:12 UTC, Sisor wrote:
Error: template std.string.stripRight cannot deduce function 
from argument types


You used 
http://dpldocs.info/experimental-docs/std.string.stripRight.html


This function only takes one argument and strips whitespace.

You want 
http://dpldocs.info/experimental-docs/std.algorithm.mutation.stripRight.1.html


This function can take two arguments and strips the second from 
the first.


Error: cannot deduce function from argument types

2018-05-05 Thread Sisor via Digitalmars-d-learn

Hi,

I have a function:

string strippedString(ubyte[] block) {
return (cast(string)block).stripRight("\0");
}

With dmd it compiles, with ldc it produces the following error 
message:


Error: template std.string.stripRight cannot deduce function from 
argument types !()(string, string), candidates are:
/usr/lib/ldc/x86_64-linux-gnu/include/d/std/string.d(2902,6): 
   std.string.stripRight(Range)(Range str) if (isSomeString!Range 
|| isRandomAccessRange!Range && hasLength!Range && 
hasSlicing!Range && !isConvertibleToString!Range && 
isSomeChar!(ElementEncodingType!Range))
/usr/lib/ldc/x86_64-linux-gnu/include/d/std/string.d(3015,6): 
   std.string.stripRight(Range)(auto ref Range str) if 
(isConvertibleToString!Range)

ldmd2 failed with exit code 1.

Why?

The modified function does not even compile with either compiler:

string strippedString(ubyte[] block) {
return cast(string)( block.stripRight(0) );
}

How can I make the function more specific, so that the compiler 
knows, which option to take?


Kind regards,
Sisor


Re: Windows to Linux Porting - timeCreated and timeLastAccessed

2018-05-05 Thread Russel Winder via Digitalmars-d-learn
On Fri, 2018-05-04 at 08:02 -0600, Jonathan M Davis via Digitalmars-d-learn
wrote:
> 
[…]
> Linux does not keep track of the creation time of a file. So, it will not
> work to have a program on Linux ask a file how long it's been since the file
> was created. If you want that information, you'll have to store it elsewhere
[…]

Linux itself doesn't but most filesystems certainly do.  Ext4 definitely does.


https://unix.stackexchange.com/questions/7562/what-file-systems-on-linux-store
-the-creation-time

-- 
Russel.
==
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


signature.asc
Description: This is a digitally signed message part


Re: Error: module `hello` is in file 'hello.d' which cannot be read

2018-05-05 Thread Bauss via Digitalmars-d-learn

On Friday, 4 May 2018 at 23:29:12 UTC, Alex wrote:

Hi

I just installed D on my windows 10 and want to try to compile 
a hello world. My source is a classical


import std.stdio;
void main() {
writeln("Hello, World!");
}

And I try to compile and get

C:\D>dmd hello.d
Error: module `hello` is in file 'hello.d' which cannot be read
import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import

What do I do wrong ?

D is installed at de root of C:, and the hello.d source code is 
at C:\D\dmd2\sources.


Thank you to you

Alex

Try to add

module hello;

To the top of the file



Re: Is HibernateD dead?

2018-05-05 Thread Bauss via Digitalmars-d-learn

On Friday, 4 May 2018 at 19:54:46 UTC, Matthias Klumpp wrote:
I've written an email to Vadim, maybe we get a reply on the 
status of both projects.



On Friday, 4 May 2018 at 07:18:09 UTC, bauss wrote:

[...]
Would it maybe be easier for you to base on ddbc[1] or 
another existing abstraction layer for database abstraction?
Ddbc is pretty neat, and even has support for reading structs 
directly from the database.




Perhaps, but it'd have to be a forked version as I don't 
really want to depend on something that isn't updated 
regularly.


ddbc's last commit was a year ago.


Yes, at the moment using ddbc and relying on it would mean 
taking over some maintenance of it. Ddbc is fairly complete 
though and might save you a lot of work, because it already 
abstracts a lot of (relational) database systems.



I can't seem to find a license for it though?


It's Boost licensed (BSL-1.0), but probably needs an explicit 
LICENSE file.
Maybe we can move ddbc to dlang-community, so more people can 
easily commit changes to it (provided it gets accepted there, 
and Vadim agrees with that move as well).


Perhaps I will end up having another "optional" dependency 
to it as a temporary until I can have a better 
implementation or something.


Taking over maintenance of it might be easier than 
reimplementing the database abstraction again though.
For Postgres, ddbc worked really well for me, and I assume its 
SQLite, MySQL and ODBC drivers are also still working well, 
meaning less work for you.
Without ddbc, you'd have to write new abstraction on top of 
some other libraries, like dpq2.


The frontend part of postgresql is almost finished, it's 
just having the postgresql driver working properly, which is 
where it's frozen right now.


Hmm... Does any public code for that exist already that I 
could play around with?
Unfortunately, I have a few more unusual requirements for 
Postgres, like:

 * UUIDs as primary keys, instead of integers


As far as I remember the implementation of @DbId in Diamond, 
then it supports whatever type.


Native support for std.uuid.UUID would be neat :-) For 
Hibernated I use a mixin to convert a UUID into strings 
transparently, for database insertion.



Diamond doesn't care much about what type your primary key is.

I will make sure that's how it function of course, if it 
currently doesn't behave like it, but I'm pretty sure it does.


 * Ability to register custom datatypes with the ORM (version 
numbers in this case, the ORM can view them as text, but the 
database has a special type for them)


That could be done with some attribute that lets you handle 
columns yourself.


Do you have a good name for it?

I was thinking @DbProxy and then the function would be 
something like:

[...]


Registering a new type with Postgres yields a new OID to 
identify the type, so I would need a function to tell the 
Postgres backend to treat OIDs of a certain number like "text" 
types. Ideally, I would also need to annotate entity to set a 
specific column type, like:


```
class Entity {
UUID uuid;

@ColumType("versionnumber")
string _version;
}
```
(With the result of CREATE TABLE not setting a "text" type for 
the new version column, but a "versionnumber" type instead)


That would do it. For Hibernated, I have Hibernated create the 
table initially, and then fire an ALTER TABLE at it afterwards 
to change the column type, while at the same time registering 
the new type OID with ddbc to be treated as text.
As said, this is a very specific requirement very few people 
will have ^^


Much more frequently people will ask for JSONB and JSON type 
support for a postgres driver though, I guess. For that, 
specifying the column type explicitly could be quite helpful as 
well, so switch between JSONB and JSON.


 * Obviously the usual ORM stuff, one-to-many, many-to-many, 
etc. relations




Yes, relations is one thing I haven't added and I have been 
wanting to do it for a while.


I will definitely look into having it added as well.


That's kind of key for an ORM :-) Handling relations manually 
was what made me abandon my "I just write raw SQL for 
everything" ways, because it gets quite complex and annoying in 
the long run.


(Obviously not a must-have list, I added support for custom 
datatypes to my ddbc fork as well, because it's not really a 
feature many people need)


Well, that's kind of the key to most of the development in 
Diamond.


I usually add functionality that isn't widely used and in most 
cases people implement it themselves ex. the whole diamond.seo 
is not usually something a framework has.


I keep an eye on it - at the moment, Vibe.d satisfies all 
requirements I have on a web framework, but that might change.
A well integrated ORM would certainly be a game changer, since 
Vibe.d is limited to Mongo and Redis only.


Diamond is a neat project, I played around with it about half 
a year ago, but didn't test the ORM part at all back then.


It wasn't that goo

Re: Error: module `hello` is in file 'hello.d' which cannot be read

2018-05-05 Thread Alex via Digitalmars-d-learn

Thank you for you for your quick answer.

I think I allready tryed this, before asking, but ...

C:\>cd D\dmd2\sources

C:\D\dmd2\sources>dmd hello.d
Error: module `hello` is in file 'hello.d' which cannot be read
import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import

C:\D\dmd2\sources>


Re: Store any callable in an array

2018-05-05 Thread ag0aep6g via Digitalmars-d-learn

On 05/05/2018 02:30 AM, Neia Neutuladh wrote:

On Friday, 4 May 2018 at 19:12:16 UTC, ag0aep6g wrote:
If toDelegate isn't (always) @safe, how can you be sure that your 
wrapper is?

[...]
Looking at the code, I believe there are several casts that the compiler 
can't verify but are used safely.


If you're right and the casts are used safely, and if that's the one 
thing that makes toDelegate @system, then toDelegate should be marked as 
@trusted. Or the casts should be @trusted, if they can be isolated like 
that.


But belief isn't strong enough for that. You should be certain when 
applying @trusted. And thinking of all the ways that code might be 
unsafe is tricky, especially when you're dealing with arbitrary types in 
a template.



Also, TFunc may have an unsafe destructor.



[...]> If it's a user-defined type with
opCall, that's something to pay attention to, but it's beyond the scope 
of the original question.


That's the one. The scope of the original question doesn't matter if you 
don't restrain your function in the same way. Your function accepts 
structs, so you have to take them into account. Also, the thread is 
about "anything" callable. That includes structs with opCall.


Re: Is HibernateD dead?

2018-05-05 Thread Brian via Digitalmars-d-learn

On Thursday, 3 May 2018 at 10:27:47 UTC, Pasqui23 wrote:

Last commit on https://github.com/buggins/hibernated
was almost a year ago

So what is the status of HibernateD?Should I use it if I need 
an ORM? Or would I risk unpatched security risks?


You can use Entity & Database library:

https://github.com/huntlabs/entity
https://github.com/huntlabs/database