Re: New developments on topic of memset, memcpy and similar

2021-11-27 Thread MrSmith via Digitalmars-d-learn

On Saturday, 27 November 2021 at 11:15:45 UTC, Igor wrote:

Additionally, here is the twitter thread from the author: 
https://twitter.com/nadavrot/status/1464364562409422852


Re: Beta 2.094.0

2020-09-13 Thread MrSmith via Digitalmars-d-announce
On Sunday, 13 September 2020 at 15:12:00 UTC, Steven 
Schveighoffer wrote:
The first part of the change seems disruptive. If you just fix 
the second part (that you can now retrieve all members of std), 
doesn't it fix the problem?


-Steve


Main problem is that allMembers returns strings and you can't 
tell if member is an import from it. If it returned aliases then 
you could do is(m == module), etc.


Re: Beta 2.094.0

2020-09-13 Thread MrSmith via Digitalmars-d-announce

On Friday, 11 September 2020 at 07:48:00 UTC, Martin Nowak wrote:
Glad to announce the first beta for the 2.094.0 release, ♥ to 
the 49 contributors.


This is the first release to be built with LDC on all 
platforms, so we'd welcome some more thorough beta testing.


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

As usual please report any bugs at
https://issues.dlang.org

-Martin


One unfortunate sideeffect of allMembers change is that it breaks 
this king of loop:

```
foreach(m; __traits(allMembers, M)) { // M is module
alias member = __traits(getMember, M, m); // now fails 
because std.stdio is not a member of M

}
```

To fix I needed to rewrite it as:
```
foreach(m; __traits(allMembers, M)) { // M is module
static if (__traits(compiles, __traits(getMember, M, m)))
alias member = __traits(getMember, M, m);
}
```


Re: Article: The surprising thing you can do in the D programming language

2020-08-20 Thread MrSmith via Digitalmars-d-announce

On Thursday, 20 August 2020 at 10:12:22 UTC, aberba wrote:

Wrote something on OpenSource.com

https://opensource.com/article/20/8/nesting-d


The only nitpick, is that nested functions need to be declared 
before use, in order to compile.


Re: How to make the compile time red color warning ?

2020-06-03 Thread MrSmith via Digitalmars-d-learn

On Wednesday, 3 June 2020 at 11:48:27 UTC, Виталий Фадеев wrote:

Use case:
I have class for Windows OS.
I not implement class for Linux.
I want message about it. When code compiled under Linux.


You could use `static assert(false, "Message");` to make it an 
error.





Re: A D port of utf8proc

2020-04-12 Thread MrSmith via Digitalmars-d-announce

On Sunday, 12 April 2020 at 13:34:49 UTC, MrSmith wrote:
On Saturday, 11 April 2020 at 23:36:17 UTC, Ferhat Kurtulmuş 
wrote:
I could not find a similar library working with -betterC, so I 
ported utf8proc.


https://github.com/aferust/utf8proc-d

Please test it, contribute it, and enjoy!


in readme this expression is wrong: `(mstring.sizeof / 
ubyte.sizeof) * mstring.length`

should be `mstring.length` instead


Actually even `mstring.length + 1` to account for null byte. But 
you may pass mstring.length to `utf8proc_map` instead of 0 length.


Re: A D port of utf8proc

2020-04-12 Thread MrSmith via Digitalmars-d-announce
On Saturday, 11 April 2020 at 23:36:17 UTC, Ferhat Kurtulmuş 
wrote:
I could not find a similar library working with -betterC, so I 
ported utf8proc.


https://github.com/aferust/utf8proc-d

Please test it, contribute it, and enjoy!


in readme this expression is wrong: `(mstring.sizeof / 
ubyte.sizeof) * mstring.length`

should be `mstring.length` instead


Re: code.dlang.org reliability update

2020-03-03 Thread MrSmith via Digitalmars-d-announce

On Tuesday, 3 March 2020 at 08:26:19 UTC, Sönke Ludwig wrote:
Nope, should be right. At least on my machines, %APPDATA% 
points to AppData\Roaming, which is the right base folder.


My bad, confused %APPDATA% with AppData. It is indeed 
AppData\Roaming\dub\


Re: Can't compile dlangui

2020-03-03 Thread MrSmith via Digitalmars-d-learn

On Friday, 7 February 2020 at 12:04:10 UTC, A.Perea wrote:

Hi,

I'm trying to compile dlangide, and it fails when compiling the 
dependency dlangui. Trying to compile dlangui independently 
gives the same error message (see below for full stack trace)


[...]



On Friday, 7 February 2020 at 12:04:10 UTC, A.Perea wrote:


Here is reported issue: 
https://issues.dlang.org/show_bug.cgi?id=20623




Re: code.dlang.org reliability update

2020-03-02 Thread MrSmith via Digitalmars-d-announce

On Monday, 2 March 2020 at 19:17:59 UTC, Sönke Ludwig wrote:

settings.json is found/needs to be created in %APPDATA%\dub\ on 
Windows


I guess that should be %APPDATA%\Local\dub\


Re: Beta 2.080.1

2018-06-04 Thread MrSmith via Digitalmars-d-announce

On Monday, 4 June 2018 at 11:44:31 UTC, Martin Nowak wrote:

First beta for the 2.080.1 patch release.

Comes with a handful of fixes.

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


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

- -Martin


Is [1] included in that release?
[1] https://issues.dlang.org/show_bug.cgi?id=18821


Re: Tiny D suitable for embedded JIT

2018-05-28 Thread MrSmith via Digitalmars-d
On Wednesday, 23 May 2018 at 18:49:05 UTC, Dibyendu Majumdar 
wrote:
Now that D has a better C option I was wondering if it is 
possible to create a small subset of D that can be used as 
embedded JIT library. I would like to trim the language to a 
small subset of D/C - only primitive types and pointers - and 
remove everything else. The idea is to have a high level 
assembly language that is suitable for use as JIT backend by 
other projects. I wanted to know if this is a feasible project 
- using DMD as the starting point. Should I even think about 
trying to do this?


The ultimate goal is to have JIT library that is small, has 
fast compilation, and generates reasonable code (i.e. some form 
of global register allocation). The options I am looking at are 
a) start from scratch, b) hack LLVM, or c) hack DMD.


Regards
Dibyendu


You may like the project of a compiler I am doing 
https://github.com/MrSmith33/tiny_jit
TLDR: fully in D. No dependencies. Currently for amd64 + Win64 
calling convension.

P.S. Sorry for late response.


Re: Feature to get or add value to an associative array.

2018-04-17 Thread MrSmith via Digitalmars-d

On Tuesday, 17 April 2018 at 17:27:02 UTC, Giles Bathgate wrote:
I like the name. I think your version is quite low level which 
ultimately provides more power at the expense of making the 
callee code less clean. I am not sure with D which of those two 
aspects is preferred. Perhaps both functions could be provided? 
What is the use case for knowing whether a value was inserted.


You may need to perform extra logic when value is inserted in the 
container and something else when value already existed.


I have a special version of function for that:
Value* getOrCreate(Key key, out bool wasCreated, Value 
default_value = Value.init)


here is an example of usage: 
https://github.com/MrSmith33/voxelman/blob/master/plugins/voxelman/entity/entityobservermanager.d#L33


Re: Tuple DIP

2018-01-13 Thread MrSmith via Digitalmars-d

On Saturday, 13 January 2018 at 21:05:27 UTC, Timon Gehr wrote:

On 13.01.2018 21:49, Timon Gehr wrote:



auto (name, email) = fetchUser();
    vs
auto {name, email} = fetchUser();



BTW: What do you think each of those do?
I'd expect the following:

---
auto (name, email) = fetchUser();
=>
auto __tmp = fetchUser();
auto name = __tmp[0], email = __tmp[1];
---

---
auto {name, email} = fetchUser();
=>
auto __tmp = fetchUser();
auto name = __tmp.name, email = __tmp.email;
---

The DIP proposes only the first one of those features, and only 
for AliasSeq's or types that alias this to an AliasSeq (such as 
tuples).


How about this syntax for getting a tuple of fields:

---
auto (name, email) = fetchUser().(name, email);
---



Re: calloc for std.experimental.allocator

2018-01-11 Thread MrSmith via Digitalmars-d-learn

On Thursday, 11 January 2018 at 21:09:01 UTC, Nordlöw wrote:
Is there no equivalent of `calloc()` for 
`std.experimental.allocator`, something like


Allocator.zeroAllocate(size_t numberOfElements)

?


http://dpldocs.info/experimental-docs/std.experimental.allocator.makeArray.4.html


Re: Dll support: testers needed

2018-01-09 Thread MrSmith via Digitalmars-d
Is it possible to put common code in exe, and use that code from 
dlls? Or anything can be exported only by dll?


Is it possible to have circular dependencies between dlls?

Tips for doing dlls with dub?



Re: Dll support: testers needed

2018-01-07 Thread MrSmith via Digitalmars-d

On Saturday, 6 January 2018 at 19:32:51 UTC, Benjamin Thaut wrote:
You can find a quick start guide here: 
http://stuff.benjamin-thaut.de/D/getting_started.html
If you need more information and examples take a look here: 
https://github.com/Ingrater/DIPs/blob/ReviveDIP45/DIPs/DIP45.md


Does the implementation support dynamically loaded dlls?


Re: partial application for templates

2017-12-25 Thread MrSmith via Digitalmars-d-learn

On Monday, 25 December 2017 at 20:39:52 UTC, Mengu wrote:

is partially applying templates possible?


template A(X, Y, Z) {}
alias B(X, Y) = A!(X, Y, int);


Re: GUI app brings up console

2017-12-06 Thread MrSmith via Digitalmars-d-learn
On Wednesday, 6 December 2017 at 21:25:27 UTC, Ivan Trombley 
wrote:
I created a cross-platform app using gtk-d. Everything works 
fine but when I run it from Windows, a console window is 
opened. How can I tell Windows that it's a GUI application so 
that a console is not opened (keeping in mind that this app 
also needs to be compiled on Linux and Mac)?


Assuming that you use dub, add this to your dub.json

"lflags-windows" : ["/SUBSYSTEM:windows,6.00", 
"/ENTRY:mainCRTStartup"]


Re: Note from a donor

2017-11-17 Thread MrSmith via Digitalmars-d
On Friday, 17 November 2017 at 23:31:07 UTC, David Nadlinger 
wrote:
The more promising avenue would probably be to distribute LLD 
with DMD. This still leaves the system library licensing to 
deal with, but if I remember correctly, one of the usual 
suspects (Rainer? Vladimir?) was working on generating them 
from MinGW headers.


 — David


Btw, what about LIBC from DMC, is it open source now too? Can we 
use it with DMD?


Re: Project Elvis

2017-11-05 Thread MrSmith via Digitalmars-d
On Monday, 30 October 2017 at 19:46:54 UTC, Andrei Alexandrescu 
wrote:
I see from comments that different people think of it in a 
different way. I suggest them to read this section from Kotlin 
docs to understand the reasoning behind the elvis operator.


The principle of least astonishment indicates we should do what 
the lowering does:


expr1 ?: expr2
==>
(x => x ? x : expr2)(expr1)

An approach that does things any differently would have a much 
more difficult time. It is understood (and expected) that other 
languages have subtly different takes on the operator.


Andrei


I may add that the same logic is used in .get(key, defaultValue) 
method of Associative Arrays




Re: Improve "Improve Contract Syntax" DIP 1009

2017-11-05 Thread MrSmith via Digitalmars-d
On Saturday, 4 November 2017 at 15:38:42 UTC, Jonathan M Davis 
wrote:
In principle, that would be nice, but in practice, it's not 
really feasible. In the general case, there's no way to save 
the state of the parameter at the beginning of the function 
call (you could with some types, but for many types, you 
couldn't). IIRC, it's been discussed quite a bit in the past, 
and there are just too many problems with it.


- Jonathan M Davis


What about making definitions in "in" block visible in "out" 
block?


void fun(int par)
in {
int saved = par;
}
body {
par = 7;
}
out {
writeln(saved);
}


Re: Note from a donor

2017-11-05 Thread MrSmith via Digitalmars-d

On Saturday, 4 November 2017 at 08:16:16 UTC, Joakim wrote:
I was intrigued by someone saying in this thread that Go 
supports Win64 COFF out of the box, so I just tried it out in 
wine and indeed it works with their hello world example.  
Running "go build -x" shows that they ship a link.exe for Win64 
with their Win64 zip, guess it's the Mingw one?


Does Go need WinSDK though?


Re: Note from a donor

2017-10-28 Thread MrSmith via Digitalmars-d

On Saturday, 28 October 2017 at 09:20:40 UTC, MrSmith wrote:
error: test.obj: The file was not recognized as a valid object 
file


Ah, forgot to pass -m64 to dmd


Re: Note from a donor

2017-10-28 Thread MrSmith via Digitalmars-d

On Friday, 27 October 2017 at 16:05:10 UTC, Kagamin wrote:
With this the only missing piece will be the C startup code 
(mainCRTStartup in crtexe.c), though not sure where it's 
compiled.


How do I get lld-link to link .obj files?
Clang itself emits .o files, and those link successfully.
For .obj files

./lld-link test.obj
error: test.obj: The file was not recognized as a valid object 
file


Re: Note from a donor

2017-10-27 Thread MrSmith via Digitalmars-d

On Friday, 27 October 2017 at 09:56:25 UTC, Kagamin wrote:
MinGW compiles import libraries from text .def files that are 
lists of exported symbols: 
https://sourceforge.net/p/mingw-w64/mingw-w64/ci/master/tree/mingw-w64-crt/lib64/


I will test dmd + lld + use .def files instead of .lib files


Re: Note from a donor

2017-10-26 Thread MrSmith via Digitalmars-d

On Thursday, 26 October 2017 at 17:02:40 UTC, Mike Parker wrote:
That's exactly the kind of developer background I'm thinking 
of. Getting permission to redistribute from MS would be the 
ideal solution. If not, I'm sure someone will find a way to 
make it work with the LLVM or MinGW tools eventually.


Would it be possible to create import libs that for all 
winapi/crt libs, and redistribute them? Will such libs be legal 
to redist?
We have the tools (DMD/LLD), but the dependency on winsdk and VS 
libs is still there, unfortunatelly.


Re: DMD, Windows and C

2017-10-25 Thread MrSmith via Digitalmars-d-announce

On Wednesday, 25 October 2017 at 16:57:27 UTC, kinke wrote:
The MS libs are obviously still required. They can be 
compressed to ~32 MB. The redistribution of the static libs is 
unclear, that's why I haven't pursued this further, but that's 
basically the only thing standing in the way of releasing a 
fully self-contained LDC package with a compressed size of 
roughly 50 MB (64-bit libs only).


I wish we had zero-dependence distributions of all compilers for 
Windows. I want to redist compiler with my application for easy 
modding. And requiring VisualStudio / BuildToos is too much 
garbage for a small task. (Ideally it should be 20-30 MB at max).


Linking error: unresolved external symbol internal

2017-10-10 Thread MrSmith via Digitalmars-d-learn

I have a static library and an application.

When linking final executable I get:
lib.lib(texteditor_1d_40c.obj) : error LNK2001: unresolved 
external symbol internal
lib.lib(textbuffer_14_3ce.obj) : error LNK2001: unresolved 
external symbol internal


Happens on Windows 32 and 64 bit.
Only with debug build.
DMD 2.076.0
Error doesn't happen when I move code from library to the 
application.


Here is reduced test case (where 2 errors happen, 4 files): 
https://gist.github.com/MrSmith33/29125fa3538bb03637d0aebab6ccff7c
Here is smaller case (only 1 error, 2 files): 
https://gist.github.com/MrSmith33/dc53d8cb6ce642fcb6dbc5863d029cec



If this is relevant: 3 places I found in dmd where "internal" 
symbol is created:
* 
https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/backend/dt.c#L420
* 
https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/tocsym.d#L662
* 
https://github.com/dlang/dmd/blob/4d86fcba2fd2ef86cc85738cd2ac2b059dbb5800/src/ddmd/tocsym.d#L681


Re: D wish list roll call game

2017-07-05 Thread MrSmith via Digitalmars-d

On Monday, 26 June 2017 at 11:20:43 UTC, Andrey wrote:

Hi guys!!!

Let's play roll call. Add the desired feature in Dlang. Only 
one. I write my own. The following copy of the previous one and 
adds his. At the end will receive a list of.


ARM cortex lib


Seamless plugin support


Re: Playing with Entity System, performance and D.

2017-06-19 Thread MrSmith via Digitalmars-d-learn
You may find this interesting 
https://github.com/MrSmith33/datadriven





Re: Simulating reference variables using `alias this`

2017-05-10 Thread MrSmith via Digitalmars-d

On Wednesday, 10 May 2017 at 17:12:11 UTC, Carl Sturtivant wrote:
Here's the beginning of an interesting little experiment to 
simulate reference variables using `alias this` to disguise a 
pointer as a reference. Could add a destructor to set the 
pointer to null when a reference goes out of scope.

...


I've used this code for similar purpose:

alias TextEditorSettingsRef = TextEditorSettings*;
alias TextEditorSettingsConstRef = const(TextEditorSettings)*;
struct TextEditorSettings
{}

But you need to have two aliases (templates) for const and 
non-const refs, since using:

const TextEditorSettingsRef editor;
does:
const(TextEditorSettings*)
not
const(TextEditorSettings)*

What do you think?




Re: Introducing Diskuto - an embeddable comment system

2017-03-19 Thread MrSmith via Digitalmars-d-announce

On Tuesday, 14 March 2017 at 11:17:57 UTC, Sönke Ludwig wrote:
Any comments suggestions and especially helping hands are 
highly appreciated!


Would be nice to undo/change votes. I accidentally clicked -1 and 
can't undo it.


Re: Project Highlight: Voxelman

2017-01-01 Thread MrSmith via Digitalmars-d-announce

On Saturday, 31 December 2016 at 14:22:40 UTC, jkpl wrote:

dub build --build=release
Performing "release" build using dmd for x86_64.
dmd failed with exit code 1.


I've fixed compilation on linux on 2.072. However you need to use 
--DRT-oncycle=ignore when starting, due to new cycle handling in 
2.072.


Re: Project Highlight: Voxelman

2016-12-31 Thread MrSmith via Digitalmars-d-announce

On Saturday, 31 December 2016 at 11:48:34 UTC, jkpl wrote:
I don't blame your personally but the last time a blog post 
presented a game (it was the one made by the author of dlib) 
there was also a similar problem. Were you aware that something 
gonna be posted and that necessarily people would try to build 
it ?


I haven't really got to building the whole thing on linux. For 
full functionality it needs LMDB, LZ4, GLFW3, Enet and IMGUI 
libs. Ideally there should be a linux build with all dependencies 
in releases.


Re: Project Highlight: Voxelman

2016-12-30 Thread MrSmith via Digitalmars-d-announce

On Friday, 30 December 2016 at 13:28:12 UTC, Mike Parker wrote:
Voxelman is a plugin-driven voxel game engine that is built 
around a client-server architecture and sports multi-threaded 
world & mesh generation.


I stumbled across a post on /r/VoxelGameDev a few weeks back 
and recognized the handle of MrSmith33 from these forums. That 
prompted me to click through and I was DlighteD to discover it 
was created with that language I can't seem to stop writing 
about.


The post:
http://dlang.org/blog/2016/12/30/project-highlight-voxelman/

Reddit:
https://www.reddit.com/r/programming/comments/5l3eej/introducing_voxelman_a_plugindriven_voxel_game/


Thanks for doing this blog post, Mike!


Re: Dub with ldc on windows

2016-11-14 Thread MrSmith via Digitalmars-d

On Monday, 14 November 2016 at 21:16:23 UTC, Daniel Kozak wrote:
Is there any plan to support this? Right now I can use dub only 
with dmd on windows. On linux it works ok.


I've used this patch to fix dub with ldc on windows. Works fine.
https://github.com/dlang/dub/pull/963/files#diff-5ed4e1d15229759c3b844e746aa8c9ceR83


Re: Minor updates: gen-package-version v1.0.4 and sdlang-d v0.9.6

2016-08-26 Thread MrSmith via Digitalmars-d-announce

On Tuesday, 23 August 2016 at 16:19:12 UTC, Nick Sabalausky wrote:
I'm hoping to finally get around to taking care of some of the 
open enhancement requests for sdlang-d soon.


Can you, please, take care of this issue: 
https://github.com/Abscissa/libInputVisitor/issues/1 ?


Re: Entity Component Architecture

2016-08-26 Thread MrSmith via Digitalmars-d

On Wednesday, 24 August 2016 at 17:57:33 UTC, vladdeSV wrote:
I am searching for feedback. What do you think it's pros and 
cons are? Preformance, memory usage, scaleability, etc?


Your solution is basically OOP with composition used. It is 
enough for convenience, but not enough for speed. Also memory 
allocation for each component looks scary.
Systems simply iterate over a all entities that have given set of 
components.
Check my solution API 
https://gist.github.com/MrSmith33/e861a289d295ec4659a0
I have query maker that iterates over smallest collection and 
gets other components. Full code is here 
https://github.com/MrSmith33/voxelman/tree/master/source/datadriven. WIP.
Here is example of usage (single component used here though) 
https://github.com/MrSmith33/voxelman/blob/master/plugins/test/entitytest/plugin.d


Re: LZ4 decompression at CTFE

2016-04-26 Thread MrSmith via Digitalmars-d-announce

On Tuesday, 26 April 2016 at 22:05:39 UTC, Stefan Koch wrote:

Hello,

originally I want to wait with this announcement until DConf.
But since I working on another toy. I can release this info 
early.


So as per title. you can decompress .lz4 flies created by the 
standard lz4hc commnadline tool at compile time.


No github link yet as there is a little bit of cleanup todo :)

Please comment.


I would like to use this instead of c++ static lib. Thanks! (I 
hope it works at runtime too).


Re: DlangUI on Android

2016-04-23 Thread MrSmith via Digitalmars-d-announce

Works on Nexus 7, Android 6.0.1!


Re: trying to implement lock-free fixedsize queue

2016-03-31 Thread MrSmith via Digitalmars-d-learn

On Thursday, 31 March 2016 at 18:25:46 UTC, jacob wrote:
I try to implement chunk (something like lock-free fixedsize 
queue)

...


Check out this implementation 
https://github.com/MartinNowak/lock-free/blob/master/src/lock_free/rwqueue.d





Re: Damage Control: An homage to Rampart (Alpha)

2016-01-01 Thread MrSmith via Digitalmars-d-announce

On Thursday, 31 December 2015 at 16:43:53 UTC, rcorre wrote:
"Damage Control" is a game inspired by one of my old favorite 
SNES games, Rampart (ok, technically an arcade game, but I had 
it on SNES).


[...]


For me window is not shown. Windows 7 64bit. I see console and 
graphics windows in taskbar, but no actual window on the screen. 
Used release v0.2.


Re: Voting For std.experimental.ndslice

2015-12-29 Thread MrSmith via Digitalmars-d

On Tuesday, 29 December 2015 at 21:19:19 UTC, Jack Stouffer wrote:
On Tuesday, 29 December 2015 at 17:38:06 UTC, Ilya Yaroshenko 
wrote:
On Tuesday, 29 December 2015 at 17:17:05 UTC, Jack Stouffer 
wrote:

...
First draft: http://jackstouffer.com/hidden/nd_slice.html

Please critique.


Looks solid. Good work!


Re: Atrium - 3D game written in D

2015-11-06 Thread MrSmith via Digitalmars-d-announce

Would be nice to have demos avaliable on github



Re: Automatic method overriding in sub-classes

2015-10-27 Thread MrSmith via Digitalmars-d

On Monday, 26 October 2015 at 23:25:49 UTC, Tofu Ninja wrote:
I know this has basically no chance of ever actually being 
added because that is the way of all "I want feature X" 
threads, but I thought I would post this anyways because I seem 
to want it constantly.


Hey, that is what I needed yesterday!


Re: Yieldable function?

2015-08-13 Thread MrSmith via Digitalmars-d-learn

http://dlang.org/phobos/core_thread.html#.Fiber


Re: Voting for std.experimental.allocator

2015-07-08 Thread MrSmith via Digitalmars-d-announce

Yes


Re: Opening browser and url.

2015-06-25 Thread MrSmith via Digitalmars-d-learn

On Thursday, 25 June 2015 at 14:02:41 UTC, Bauss wrote:
In other programming languages you can open a website in the 
default browser by spawning a process using the url, but it 
does not seem to work with D using spawnProcess().


Do I have to do API calls to get the default browser and then 
call spawnProcess() with the url as an argument or is there a 
standard D way.


I tried it like the following
spawnProcess(http://www.x.x/;);


http://dlang.org/phobos/std_process.html#.browse


Re: quick-and-dirty minimalistic LISP engine

2015-02-22 Thread MrSmith via Digitalmars-d-announce

With master dmd I'm getting

milf.d(2): Error: ';' expected following module declaration 
instead of is

milf.d(2): Error: no identifier for declarator aliced
milf.d(99): Deprecation: typedef is removed
milf.d(223): Error: basic type expected, not ;
milf.d(223): Error: no identifier for declarator int
milf.d(352): Error: no identifier for declarator CellCons
milf.d(352): Error: declaration expected, not 'body'
milf.d(359): Error: found 'body' instead of statement
milf.d(374): Error: expression expected, not 'body'
milf.d(380): Error: expression expected, not 'body'
milf.d(760): Error: expression expected, not 'auto'
milf.d(760): Error: found 's' when expecting ')'
milf.d(760): Error: found '=' instead of statement
milf.d(795): Error: declaration expected, not 'if'
milf.d(796): Error: declaration expected, not 'if'
milf.d(799): Error: declaration expected, not 'for'
milf.d(799): Error: declaration expected, not ')'
milf.d(801): Error: declaration expected, not 'if'
milf.d(802): Error: no identifier for declarator stloc
milf.d(802): Error: declaration expected, not '='
milf.d(804): Error: function declaration without return type. 
(Note that constructors are always named 'this')


Also, there was no alias usize = size_t;
There is no typedef and body is reserved word.

Here is what I got: 
https://gist.github.com/MrSmith33/9bedde7b0721a6b40666


Re: Best practices for reading public interfaces

2015-02-22 Thread MrSmith via Digitalmars-d-learn

On Saturday, 21 February 2015 at 20:46:09 UTC, Kenny wrote:

I like D modules and it's a major point in the list of major
points why I like D (there is also the second not so nice
wft-list but it's for another post). I'm annoyed with C++
includes and I'm tired to create 2 files every time when I need
to add something new to the project...  But I must admit that 
one

thing I like in header files is that it is a convenient way to
read public interfaces.

In D we have interface specification and implementation in a
single file and also one approach with unit testing is to put
them immediately after functions which makes writing unit tests
even more easy task (and I like it very much) but again it makes
the gaps between declarations even wider.

So, what are the common approaches for reading public interfaces
in D programs? Especially it would be great to see the answers 
of

developers who work with more or less big codebases.

The few possible solution I'm thinking about at the moment:

a) Provide D interfaces for corresponding classes (but probably
it's only for more or less complex abstractions and also I won't
use it for Vector3D, also very often I use just regular
functions).

b) Write DDocs and read documentation. The problem here is that
I'm going to use D only for my own projects and in the last time
I tend to write less documentation, for example I do not write 
it

for the most methods of Vector3D.

c) Do nothing special, just write D modules and try to figure 
out

public interfaces reading its code. Maybe it works in practice.

Thanks,
Artem.


You can also fold all the function bodies in your editor, this 
helps me to read massive sources.


Re: Cannot use the same template arguments on function as the ones on struct

2015-02-12 Thread MrSmith via Digitalmars-d-learn

Thanks, everyone.


Re: Cannot use the same template arguments on function as the ones on struct

2015-02-12 Thread MrSmith via Digitalmars-d-learn

Thank you!


Re: std.allocator ready for some abuse

2015-02-11 Thread MrSmith via Digitalmars-d

On Wednesday, 11 February 2015 at 15:57:26 UTC, John Colvin wrote:

Should it be in std.experimental? Or at least on code.dlang.org?


Yeah, dub package would be really nice!


Cannot use the same template arguments on function as the ones on struct

2015-02-11 Thread MrSmith via Digitalmars-d-learn
Here I have templated struct that matches type with CborConfig 
tempate specialization


CborConfig will have more parameters in future and all of them 
will be accessed via alias members, so I've used variadic (T...) 
parameter whule matching.


---
template CborConfig(_nonSerializedAttribute)
{
struct CborConfig
{
alias nonSerializedAttribute = _nonSerializedAttribute;
}
}

/// Default non-serialized attribute type
struct NonSerialized{}

/// This CborConfig instantiation will be used by default.
alias defaultCborConfig = CborConfig!(NonSerialized, 
NonSerialized);


struct AccepterT(Config : CborConfig!(T) = defaultCborConfig, 
T...)

{
pragma(msg, T);
}

// template f379.accepter cannot deduce function from argument 
types !()()

void accepter(Config : CborConfig!(T) = defaultCborConfig, T...)()
{
pragma(msg, T);
}
---
^^^
http://dpaste.dzfl.pl/5f1d5d5d9e19

Instead I need to use template constraint which is less compact.
http://dpaste.dzfl.pl/571ae84d783e

Why such behavior happens?


Re: DDocs.org: auto-generated documentation for all DUB projects (WIP)

2015-02-10 Thread MrSmith via Digitalmars-d-announce

On Tuesday, 10 February 2015 at 22:40:18 UTC, Kiith-Sa wrote:
DDocs.org (http://ddocs.org) is a repository of documentation 
for DUB projects that automatically re-generates docs as new 
projects/releases/branch changes are added.


The idea is to make documenting D projects as simple as 
possible, to the point where you don't need to do any work to 
get documentation for your project other than adding it to the 
DUB registry. Also, users can now browse documentation for DUB 
projects even if the author was too lazy to generate it 
themselves (assuming thy did include some documentation 
comments).



Note that this is still in a very early stage, it was put 
together in a very quick-and-dirty style by a person with 
little webdev experience. Currently it just scans 
`code.dlang.org`, looking for changes (yes, I know, this will 
break as soon as code.dlang.org changes, I plan to raise 
issue/s (PRs?) to the dub registry project so it can have a 
full/stable API, but I wanted to get something to work *right 
now*.


Code is here:

* ddocs.org: https://github.com/kiith-sa/ddocs.org
* hmod-dub: https://github.com/kiith-sa/hmod-dub
* harbored-mod: https://github.com/kiith-sa/harbored-mod



Background:

When optimizing harbored-mod by testing it on big D projects 
(gtk-d, tango, vibe.d, etc.), I wrote a simple tool to 
fetch/generate docs for any DUB project; I got carried away and 
used that as base for a tool that checks for changes in the DUB 
registry and generates docs for all projects.


That is pretty cool! I will put a link to it in all my project 
readmes.


I've noticed that License: a$(WEB boost.org/LICENSE_1_0.txt, 
Boost License 1.0). gets rendered as a.

Am I doing it wrong?


Re: std.sevenzip - Do you need it?

2015-01-31 Thread MrSmith via Digitalmars-d

On Saturday, 31 January 2015 at 04:30:06 UTC, Daniel Murphy wrote:
Brad Anderson  wrote in message 
news:vqkaztokcfgdbykbi...@forum.dlang.org...


I'm mostly of the opinion that we should be relying less on 
Phobos and more on dub going forward. sevenzip would be a 
great addition to the dub registry.


Yes please.


+1


Re: Phobos colour module?

2015-01-09 Thread MrSmith via Digitalmars-d

You can take a look at what color formats does freeimage supports.


Re: DlangUI project update

2014-12-30 Thread MrSmith via Digitalmars-d-announce

On Friday, 26 December 2014 at 12:33:04 UTC, Vadim Lopatin wrote:

Hello!

DlangUI project is alive and under active development.

https://github.com/buggins/dlangui

Recent changes:
- new controls: ScrollWidget, TreeView, ComboBox, ...
- new dialogs: FileOpenDialog, MessageBox
- a lot of bugfixes
- performance improvements in software renderer
- killer app: new example - Tetris game :)

Try Demos:
# download sources
git clone https://github.com/buggins/dlangui.git
cd dlangui
# example 1 - demo for most of widgets
dub run dlangui:example1 --build=release
# tetris - demo for game development
dub run dlangui:tetris --build=release

DlangUI is cross-platform GUI library written in D.
Main features:
- cross platform: uses SDL for linux/macos, Win32 API or SDL 
for Windows
- hardware acceleration: uses OpenGL for drawing when built 
with version USE_OPENGL
- easy to extend: since it's native D library, you can add your 
own widgets and extend functionality

- Unicode and internationalization support
- easy to customize UI - look and feel can be changed using 
themes and styles

- API is a bit similar to Android - two phase layout, styles

Screenshots (a bit outdated): 
http://buggins.github.io/dlangui/screenshots.html


See project page for details.

I would like to get any feedback.
Will be glad to see advises, bug reports, feature requests.

Best regards,
 Vadim


Is it possible to use your GUI for opengl game? I need to inject 
a gui in an existing main loop.


Re: DlangUI project update

2014-12-30 Thread MrSmith via Digitalmars-d-announce
On Tuesday, 30 December 2014 at 18:32:04 UTC, ketmar via 
Digitalmars-d-announce wrote:

On Tue, 30 Dec 2014 18:18:38 +
MrSmith via Digitalmars-d-announce
digitalmars-d-announce@puremagic.com wrote:

Is it possible to use your GUI for opengl game? I need to 
inject a gui in an existing main loop.
as it seems to have OpenGL as one of the backends, i think that 
it
shouldn't be hard even if it is not supported directly right 
now.

please write about your progress here (if there will be any).


I've built library with 2.066.1 and master
Despite resources is not copied by dub it works fine.
Fixed C-style arrays and sent PR 
https://github.com/buggins/dlangui/pull/24


Re: Concise Binary Object Representation (CBOR) binary serialization library.

2014-12-20 Thread MrSmith via Digitalmars-d-announce

On Friday, 19 December 2014 at 22:25:57 UTC, Nordlöw wrote:

On Friday, 19 December 2014 at 18:26:26 UTC, MrSmith wrote:

Here is github link: https://github.com/MrSmith33/cbor-d
Destroy!


It would be nice to have a side-by-side comparison with 
http://msgpack.org/ which is in current use by a couple 
existing D projects, include D Completion Daemon (DCD) and a 
few of mine.


There is a comparison to msgpack here (and to other formats too): 
http://tools.ietf.org/html/rfc7049#appendix-E.2

which states:
   [MessagePack] is a concise, widely implemented counted binary 
serialization format, similar in many properties to CBOR, 
although somewhat less regular. While the data model can be used 
to represent JSON data, MessagePack has also been used in many 
remote procedure call (RPC) applications and for long-term 
storage of data.
   MessagePack has been essentially stable since it was first 
published around 2011; it has not yet had a transition. The 
evolution of MessagePack is impeded by an imperative to maintain 
complete backwards compatibility with existing stored data, while 
only few bytecodes are still available for extension.
   Repeated requests over the years from the MessagePack user 
community to separate out binary text strings in the encoding 
recently have led to an extension proposal that would leave 
MessagePack's raw data ambiguous between its usages for binary 
and text data. The extension mechanism for MessagePack remains 
unclear.


Re: Concise Binary Object Representation (CBOR) binary serialization library.

2014-12-20 Thread MrSmith via Digitalmars-d-announce

On Friday, 19 December 2014 at 22:33:57 UTC, BBaz wrote:

Do you know OGDL ?

http://ogdl.org/

It's currently the more 'appealing' thing to me for 
serialization.


That is interesting! Is there a D implementation?
Though, it looks like there is not much types of data there.


Re: Concise Binary Object Representation (CBOR) binary serialization library.

2014-12-20 Thread MrSmith via Digitalmars-d-announce

On Friday, 19 December 2014 at 22:46:14 UTC, ponce wrote:

On Friday, 19 December 2014 at 22:33:57 UTC, BBaz wrote:

On Friday, 19 December 2014 at 18:26:26 UTC, MrSmith wrote:
The Concise Binary Object Representation (CBOR) is a data 
format
whose design goals include the possibility of extremely small 
code
size, fairly small message size, and extensibility without 
the need
for version negotiation.  These design goals make it 
different from

earlier binary serializations such as ASN.1 and MessagePack.



When implementing CBOR serialization/parsing I got the 
impression that it was remarkably similar to MessagePack except 
late. Dis you spot anything different?


Not much in the sense of implementation, but it has text type, 
indefinite-length encoding, tags and can be easily extended if 
needed. I think of it as of better msgpack.


Concise Binary Object Representation (CBOR) binary serialization library.

2014-12-19 Thread MrSmith via Digitalmars-d-announce

The Concise Binary Object Representation (CBOR) is a data format
whose design goals include the possibility of extremely small code
size, fairly small message size, and extensibility without the 
need
for version negotiation.  These design goals make it different 
from

earlier binary serializations such as ASN.1 and MessagePack.

Here is more info about format: http://cbor.io/

You can easily encode and decode things like built-in types, 
arrays, hash-maps, structs, tuples, classes, strings and raw 
arrays (ubyte[]).


Here is some simple code:

import cbor;

struct Inner
{
int[] array;
string someText;
}

struct Test
{
ubyte b;
short s;
uint i;
long l;
float f;
double d;
ubyte[] arr;
string str;
Inner inner;

void fun(){} // not encoded
void* pointer; // not encoded
int* numPointer; // not encoded
}

ubyte[1024] buffer;
size_t encodedSize;

Test test = Test(42, -120, 11, -123456789, 0.1234, 
-0.987654,

cast(ubyte[])[1,2,3,4,5,6,7,8], It is a test string,
Inner([1,2,3,4,5], Test of inner struct));

encodedSize = encodeCborArray(buffer[], test);

// ubyte[] and string types are slices of input ubyte[].
Test result = decodeCborSingle!Test(buffer[0..encodedSize]);

// decodeCborSingleDup can be used to auto-dup those types.

assert(test == result);

Here is github link: https://github.com/MrSmith33/cbor-d
Destroy!


Re: dub dustmite

2014-12-14 Thread MrSmith via Digitalmars-d-learn

On Friday, 12 December 2014 at 04:25:01 UTC, Vlad Levenfeld wrote:
I'm trying to reduce a bug with dub dustmite feature and I must 
be doing it wrong somehow, my regular dub output looks like 
this:


  source/experimental.d(2403): Error: struct 
experimental.Product!(int[], int[]).Product no size yet for 
forward reference

ulong[2]
  source/experimental.d(2454): Error: template instance 
experimental.Product!(int[], int[]) error instantiating
  source/experimental.d(2462):instantiated from here: 
by!(int[], int[])
  FAIL 
.dub/build/application-debug-linux.posix-x86_64-dmd_2067-44246AA2375AB6C7D895600135F734E4/ 
engine_vx executable

  Error executing command run:
  dmd failed with exit code 1.

and then when I run this command

  dub dustmite ~/dubdust --compiler-regex=Product no size yet

I get

  Executing dustmite...
  None = No
  object.Exception@dustmite.d(243): Initial test fails

It seems like a pretty simple case, I'm not sure what's going 
on.


Try using --combined. This will test all packages at the same 
time if you have dependencies.


Re: How to share modules when using -shared?

2014-12-14 Thread MrSmith via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 00:44:41 UTC, Justin Whear 
wrote:
I'm trying to build components that I can dynamically link and 
keep
running into an issue with sharing modules between the host and 
the

pluggable components. Assuming a layout like this:

  host.d  -- loads components at runtime
  a.d -- a module that builds to `a.so`
  b.d -- a module that builds to `b.so`
  common.d

If a.d and b.d both import common.d, all is well.  If host.d 
imports

common.d as well, I get this at runtime:
Fatal Error while loading 'a.so':
The module 'common' is already defined in 'host'.

Test session with sources here: http://pastebin.com/LxsqHhJm

Some of this can be worked around by having host.d use its own 
extern
definitions, but how does this work with interfaces?  My tests 
thus far

have resulted in object invariant failures.


You can have common in separate .so file, or include it in host.


Re: Does RTTI and exceptions work in dlls on windows?

2014-12-02 Thread MrSmith via Digitalmars-d

On Tuesday, 2 December 2014 at 10:48:16 UTC, Kagamin wrote:

On Monday, 1 December 2014 at 18:35:28 UTC, MrSmith wrote:

Can i compile it in the same dll with its implementation?


Yes, you can have all implementations in the same dll, 
interface will only have to be directly accessible to all code 
seeing it.


Can i have interface compiled only in one dll, and others dlls 
that use this one will not have it compiled, only import it?


Re: regular expression engine and ranges

2014-12-02 Thread MrSmith via Digitalmars-d-learn
On Tuesday, 2 December 2014 at 19:17:43 UTC, ketmar via 
Digitalmars-d-learn wrote:

Hello.

is there any decent regular expression engine which works with 
input

ranges? under decent i mean good D code, [t]nfa and no
backtracking. support for captures and greedy/non-greedy modes 
are

must.

i found that some popular regex libraries and std.regex are 
sure that
the only data layout regex engine is supposed to work with is 
plain
text array. now, i'm writing a small text editor (yes, another 
one;
please, i know that there are alot of them already! ;-) and 
internal
text layout is anything but plain array. yet i want to use 
regular
expressions for alot of things -- not only for search that 
piece of
text, but for syntax highlighting (i know, i know; don't think 
about
it, everything is much more complicated there), navigation and 
so on.


i was thinking that it will not be that hard, but found that if 
you
want to use existing regexp engine, you *have* to either use 
plain
array and alot of shitcode around it for bookkeeping to please 
RE, or

build that plain array each time you want to use RE. this sux.

for now it seems that i have no choice except to write yet 
another one
regular expression engine. and this is the thing i don't want 
to do.
but maybe someone already did that and just don't think that it 
worth

publishing as we have std.regex and so?


IIRC, there was a request for ranged regex in phobos somewhere.
Is there anything simple that can be easily ported?

Btw, do you use ropes for text? What do you use for storing 
lines, wrapped lines and text style?


Re: Does RTTI and exceptions work in dlls on windows?

2014-12-01 Thread MrSmith via Digitalmars-d

On Saturday, 29 November 2014 at 13:52:11 UTC, Martin Nowak wrote:

On Thursday, 27 November 2014 at 21:52:27 UTC, MrSmith wrote:
Can you suggest a good way to design mod system? Where each 
mod can depend on others and use their real functionality. All 
mods should be in form of dlls.


No DLL per module, just releasing a complete Phobos.DLL. If you 
want to ship a smaller Phobos.dll , build one yourself.


I meant modifications, not modules here. Will it work if i have 
an interface and implementation of each modification in a 
separate shared library? How other modifications can depend on 
that interface? Should i simply add it to import path while 
compiling or i need to compile it too? This will cause a 
duplication of interface.


On Friday, 28 November 2014 at 12:56:10 UTC, Kagamin wrote:
On Thursday, 27 November 2014 at 11:21:23 UTC, Martin Nowak 
wrote:

No!
https://issues.dlang.org/show_bug.cgi?id=7020#c2


If you want interfaces to be unique, you'll have whole new dlls 
containing only interface definitions and probably nothing 
else, just for the sake of uniqueness (things like this happen 
in .net). And you still have to deal with templates.

Can i compile it in the same dll with its implementation?


Re: Does RTTI and exceptions work in dlls on windows?

2014-11-27 Thread MrSmith via Digitalmars-d

On Thursday, 27 November 2014 at 11:24:45 UTC, Martin Nowak wrote:

On 11/24/2014 07:20 PM, MrSmith wrote:

I've got little test here
https://gist.github.com/MrSmith33/8750dd43c0843d45ccf8#file-sharedmodule2-d-L17-L29.


I have one application and two dlls. Application loads both 
dlls, calls
their factory functions and then passes each IModule instance 
that it

got from factories to those modules.

Modules then try to cast those IModule refs back to their real
interfaces (ISharedModule1) but i am getting null there.

A have found a workaround for this by returning a void* 
pointer to real

interface and it back when needed.

Another, and more major issue is, that when exception is thrown
application fail immediately.

Is it broken on windows, or it is me doing it wrong?


On Windows we currently only support static linkage of phobos 
and druntime. DLLs do work as long as each one is isolated, 
once you start exchanging data across DLL boundaries you run in 
ODR issues.
We need to make phobos itself a DLL to solve this, but that's 
quite a lot of work.


Can you suggest a good way to design mod system? Where each mod 
can depend on others and use their real functionality. All mods 
should be in form of dlls.


Another question is: What dll features are currently supported on 
linux and what they should be idealy? How do i use them?


Re: Does RTTI and exceptions work in dlls on windows?

2014-11-26 Thread MrSmith via Digitalmars-d
On Wednesday, 26 November 2014 at 07:46:12 UTC, Benjamin Thaut 
wrote:

Am 25.11.2014 21:46, schrieb MrSmith:
Is there a bugzilla issue for this? And what is the status of 
windows dlls?


If you want a bit more dll support right now, I suggest that 
you take a look at these changes and merge them into your own 
version of druntime:


https://github.com/Ingrater/druntime/commit/7e54eac91dd34810913cfe740e709b18cbbc00d6

Kind Regards
Benjamin Thaut


Thank you very much!


Re: Does RTTI and exceptions work in dlls on windows?

2014-11-25 Thread MrSmith via Digitalmars-d

On Tuesday, 25 November 2014 at 10:02:00 UTC, Kagamin wrote:
On Monday, 24 November 2014 at 20:56:29 UTC, Rainer Schuetze 
wrote:
The different DLLs have different copies of the RTTI for the 
classes (you could not link them separately otherwise). 
Looking for base classes or derived classes only compares RTTI 
pointers, so it doesn't find the target class of a cast in the 
hierarchy inside another DLL.


Maybe we can have a function, which will search the typeinfo 
based on type name, like C++ does it?


I was sure that when dll is loaded, runtimes will merge (hook) 
and all type info is shared between dll and application.


Re: Does RTTI and exceptions work in dlls on windows?

2014-11-25 Thread MrSmith via Digitalmars-d
On Tuesday, 25 November 2014 at 18:39:56 UTC, Benjamin Thaut 
wrote:

Am 24.11.2014 19:20, schrieb MrSmith:

I've got little test here
https://gist.github.com/MrSmith33/8750dd43c0843d45ccf8#file-sharedmodule2-d-L17-L29.


I have one application and two dlls. Application loads both 
dlls, calls
their factory functions and then passes each IModule instance 
that it

got from factories to those modules.

Modules then try to cast those IModule refs back to their real
interfaces (ISharedModule1) but i am getting null there.

A have found a workaround for this by returning a void* 
pointer to real

interface and it back when needed.

Another, and more major issue is, that when exception is thrown
application fail immediately.

Is it broken on windows, or it is me doing it wrong?


Dlls are generally broken on windows. If you hack around in 
druntime (e.g. the casting routines) you can get it to work to 
some degree, but you are going to be happier if you just stay 
away from it.


Is there a bugzilla issue for this? And what is the status of 
windows dlls?


D is for Data Science - reddit discussion

2014-11-24 Thread MrSmith via Digitalmars-d-announce

D is for Data Science by Andrew Pascoe

http://www.reddit.com/r/programming/comments/2n9gfb/d_is_for_data_science/


Re: D is for Data Science - reddit discussion

2014-11-24 Thread MrSmith via Digitalmars-d-announce

Haven't noticed that it was already posted. Sorry about that.

The disscussion is here 
http://forum.dlang.org/thread/qeyftagcvkhjjeeba...@forum.dlang.org


Does RTTI and exceptions work in dlls on windows?

2014-11-24 Thread MrSmith via Digitalmars-d
I've got little test here 
https://gist.github.com/MrSmith33/8750dd43c0843d45ccf8#file-sharedmodule2-d-L17-L29.


I have one application and two dlls. Application loads both dlls, 
calls their factory functions and then passes each IModule 
instance that it got from factories to those modules.


Modules then try to cast those IModule refs back to their real 
interfaces (ISharedModule1) but i am getting null there.


A have found a workaround for this by returning a void* pointer 
to real interface and it back when needed.


Another, and more major issue is, that when exception is thrown 
application fail immediately.


Is it broken on windows, or it is me doing it wrong?


Re: Does RTTI and exceptions work in dlls on windows?

2014-11-24 Thread MrSmith via Digitalmars-d
On Monday, 24 November 2014 at 20:56:29 UTC, Rainer Schuetze 
wrote:


On 24.11.2014 19:20, MrSmith wrote:

I've got little test here
https://gist.github.com/MrSmith33/8750dd43c0843d45ccf8#file-sharedmodule2-d-L17-L29.


I have one application and two dlls. Application loads both 
dlls, calls
their factory functions and then passes each IModule instance 
that it

got from factories to those modules.

Modules then try to cast those IModule refs back to their real
interfaces (ISharedModule1) but i am getting null there.


The different DLLs have different copies of the RTTI for the 
classes (you could not link them separately otherwise). Looking 
for base classes or derived classes only compares RTTI 
pointers, so it doesn't find the target class of a cast in the 
hierarchy inside another DLL.




A have found a workaround for this by returning a void* 
pointer to real

interface and it back when needed.



Another workaround for a limited number of classes would be to 
add member functions 'ISharedModule1 toSharedModule1() { return 
null; }' in IModule and override these 'ISharedModule1 
toSharedModule1() { return this; }' in the appropriate class.



Another, and more major issue is, that when exception is thrown
application fail immediately.

Is it broken on windows, or it is me doing it wrong?


I haven't tried in a while but I think it should work on Win32, 
but probably does not on Win64.


I thought it will work at least for interfaces.
Any way, this is workaroundable, but exceptions must be there at 
least.


Re: help

2014-11-20 Thread MrSmith via Digitalmars-d-learn

On Thursday, 20 November 2014 at 16:48:29 UTC, MachineCode wrote:

On Thursday, 20 November 2014 at 07:25:45 UTC, Suliman wrote:
You need to check if remote file exist of server and only 
after it download шею


is this software name written in russian language?


шею means it. on russian keyboard layout


Re: print yyyy-mm-dd

2014-11-20 Thread MrSmith via Digitalmars-d-learn

On Thursday, 20 November 2014 at 13:50:49 UTC, Suliman wrote:
I can't understand how to get date in format -MM-dd from 
Clock.currTime

auto time = Clock.currTime;

And what next? Could anybody give any examples?


http://dpaste.dzfl.pl/73c0438f9d1e

currTime returns SysTime;
You can then cast is to Date.
And Date has toISOExtString which converts Date to a string with 
the format -MM-DD.


Re: Question about eponymous template trick

2014-11-03 Thread MrSmith via Digitalmars-d-learn

On Monday, 3 November 2014 at 14:07:55 UTC, Uranuz wrote:

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;

}

This code fails during compilation with message:

Compilation output:

/d228/f410.d(12): Error: no property 'Node' for type 
'Node!string' /d228/f410.d(12): Error: no property 'Node' for 
type 'Node!string' /d228/f410.d(13): Error: no property 'Name' 
for type 'Node!string' /d228/f410.d(13): Error: no property 
'Name' for type 'Node!string' /d228/f410.d(14): Error: no 
property 'Attr' for type 'Node!string' /d228/f410.d(14): Error: 
no property 'Attr' for type 'Node!string'


So question is: is this intended behaviour and I'm missing 
something about eponymous templates? Or is it a bug in compiler?


Looks like compiler looks for Node, Name and Attr in Node struct, 
because of eponymous thing.

This code works though:

template N(String)
{
struct Node {}
struct Name {}
struct Attr {}

}

void main()
{
alias MyNode = N!(string).Node;
alias MyName = N!(string).Name;
alias MyAttr = N!(string).Attr;

}


Re: accessing numeric template parameters

2014-11-03 Thread MrSmith via Digitalmars-d-learn
On Monday, 3 November 2014 at 14:27:47 UTC, Dominikus Dittes 
Scherkl wrote:
If I have a struct with numeric template parameter, how can I 
access it within member functions? Like normal member 
variables? And how about the constructor?


struct polynomial(uint base)
{
private:
   uint[] N;
public:
   this(uint x) { base = x; }
   ...
   void add(Polynomial!base P)
   {
  if(N.length  P.N.length) N.length = P.N.length;
  foreach(i; 0..P.N.length)
  {
 N[i] = (N[i]+P.N[i]) % base;
  }
   }
}

This doesn't work for me :-/


You cannot assign to it, because it is only avaliable during 
compilation. Think of it as an immediate value, not variable.


Re: HTML Parsing lib

2014-10-25 Thread MrSmith via Digitalmars-d-learn

On Saturday, 25 October 2014 at 19:46:01 UTC, MrSmith wrote:

On Saturday, 25 October 2014 at 19:44:25 UTC, Suliman wrote:

I found only https://github.com/Bystroushaak/DHTMLParser

But I can't get it work:
C:\Users\Dima\Downloads\DHTMLParser-master\DHTMLParser-masterdmd 
find_links.d

OPTLINK (R) for Win32  Release 8.00.15
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
find_links.obj(find_links)
Error 42: Symbol Undefined 
_D11dhtmlparser11parseStringFAyaZC11dhtmlparser11HTM

LElement
find_links.obj(find_links)
Error 42: Symbol Undefined _D11dhtmlparser12__ModuleInfoZ
--- errorlevel 2

Is there any other HTML parsing lib, or maybe someone do know 
how to get it's work. Look like it's not compatible with 
current version of DMD


You need to pass a library to compiler as well (all its files 
or .lib/.a file) if it is compiled as static library


You can try
dmd find_links.d dhtmlparser.d quote_escaper.d


Re: HTML Parsing lib

2014-10-25 Thread MrSmith via Digitalmars-d-learn

On Saturday, 25 October 2014 at 19:44:25 UTC, Suliman wrote:

I found only https://github.com/Bystroushaak/DHTMLParser

But I can't get it work:
C:\Users\Dima\Downloads\DHTMLParser-master\DHTMLParser-masterdmd 
find_links.d

OPTLINK (R) for Win32  Release 8.00.15
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
find_links.obj(find_links)
 Error 42: Symbol Undefined 
_D11dhtmlparser11parseStringFAyaZC11dhtmlparser11HTM

LElement
find_links.obj(find_links)
 Error 42: Symbol Undefined _D11dhtmlparser12__ModuleInfoZ
--- errorlevel 2

Is there any other HTML parsing lib, or maybe someone do know 
how to get it's work. Look like it's not compatible with 
current version of DMD


You need to pass a library to compiler as well (all its files or 
.lib/.a file) if it is compiled as static library


Re: HTML Parsing lib

2014-10-25 Thread MrSmith via Digitalmars-d-learn

On Saturday, 25 October 2014 at 19:55:10 UTC, Suliman wrote:

How I can build such App with DUB?


Unfortunately that library has no dub package.
But you can include it in your project.

See info here http://code.dlang.org/package-format


Re: Making plugin system with shared libraries. Upcast in shared lib

2014-10-21 Thread MrSmith via Digitalmars-d-learn

On Tuesday, 21 October 2014 at 13:57:23 UTC, Kagamin wrote:

On Monday, 20 October 2014 at 15:07:43 UTC, MrSmith wrote:

On Monday, 20 October 2014 at 14:05:29 UTC, Kagamin wrote:
Do it the COM way: publish IModule2 interface and declare 
GetInterface method, which will return a prepared pointer, 
which you would reinterpret cast to IModule2.


Will it work on linux with simple .so libs?
I want it to be as simple as possible.


Is it any different from what you already have?
Dynamic cast is not guaranteed to work across dll boundary. If 
it does, you're lucky. If it doesn't, use GetInterface - that 
will work independently from runtime, environment, language, 
os, hardware etc.


What is GetInterface?


Re: Making plugin system with shared libraries. Upcast in shared lib

2014-10-20 Thread MrSmith via Digitalmars-d-learn

On Monday, 20 October 2014 at 14:05:29 UTC, Kagamin wrote:
Do it the COM way: publish IModule2 interface and declare 
GetInterface method, which will return a prepared pointer, 
which you would reinterpret cast to IModule2.


Will it work on linux with simple .so libs?
I want it to be as simple as possible.


Re: Making plugin system with shared libraries. Upcast in shared lib

2014-10-20 Thread MrSmith via Digitalmars-d-learn

On Monday, 20 October 2014 at 15:30:28 UTC, Martin Nowak wrote:

On 10/20/2014 12:32 AM, MrSmith wrote:
Than any module can search for registered modules and try to 
cast them

to concrete type (upcast).


That can't work because the notion of types only exists during 
compilation. Therefor it's not possible to load new types at 
runtime and use them in code that was compiled without knowing 
those types.

You should simply use interfaces to achieve your goal.


In this case ether shared lib knows actual type.

But i've tried it with interfaces, (upcast also), or do you mean 
something else?


1) I want application to load IModule from .so/.dll
2) Any other module should be able to cast that IModule to actual 
type (upcast) and test if result is !null.
3) Can i do this using interfaces or without them? I.e. if in 
first example module2 is interface


Making plugin system with shared libraries. Upcast in shared lib

2014-10-19 Thread MrSmith via Digitalmars-d-learn

I'm using Windows.

I was making some sort of modular system where you can define 
modules that are loaded by host application.
Here is a simple example 
https://gist.github.com/MrSmith33/7692328455a19e820a7c
Now i want to separate these modules in separate shared libs 
and link them on the fly.
The issue i have is that some modules can define some useful 
functions and in order to use them you need to upcast to concrete 
type. This is easy in a single application, but i was unable to 
do this through dll boundary.


So basically all dll's have factory function that returns an 
instance of IModule.
Than any module can search for registered modules and try to cast 
them to concrete type (upcast).


in imodule.d

interface IModule
{
string name();
void init(ModuleManager modman);
}

in module1.d (dll)

class Module1 : IModule
{
override string name() {return Module1;}

override void init(ModuleManager modman)
{
IModule module2 = modman.findModule(Module2);
if (auto m = cast(Module2)module2)
{
m.someMethod2();
}
}
}

in module2.dll (dll)

class Module2 : IModule
{
override string name() {return Module2;}
override void init(ModuleManager modman){}
void someMethod2(){}
}

And what files should i compile with what packages?
application
IModule
main
other

module1 dll
IModule
Module1
Module2 - should i import it, compile of import .di file?

module2 dll
IModule
Module2

Is it possible at all? Or it is an issue with Windows shared lib 
support?


Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together

2014-09-25 Thread MrSmith via Digitalmars-d-learn

On Wednesday, 24 September 2014 at 13:59:41 UTC, csmith wrote:

On Wednesday, 24 September 2014 at 11:07:56 UTC, Mike Parker
wrote:
You're using deprecated OpenGL calls. The gl3 module only 
declares and loads modern OpenGL. If you really want to use 
the deprecated stuff, change the gl3 import to this:


import derelict.opengl3.gl;

And call load/reload on the DerelictGL instance rather than 
DerelictGL3. All of the modern stuff will still be available.


Thanks for this. Was using GLFW's example trying to troubleshoot
it. Wasn't really considering them using the outdated functions.
I guess I'll look for a different tutorial elsewhere.

Also, thanks for making it in the first place!


We have opengl tutorials in D 
https://github.com/d-gamedev-team/opengl-tutorials


Extracting string parameter from template instance received via alias parameter

2014-09-12 Thread MrSmith via Digitalmars-d

Given the following program:

-
import std.stdio;

template first(string s)
{
string first(string par)
{
if (par == s)
return true;
else
return false;
}
}

template second(alias firstInstance)
{
string second(string par)
{
// this line doesn't work
static if (is(firstInstance : F!(str), alias F, string str))
{
writeln(matched , str);
}

enum s = XXX; // get s from firstInstance
// without parsing strings and using mixins
// something like second(alias C : F!(str), alias F, string str)

import std.string : icmp;
if (icmp(par, s) == 0)
return true;
else
return false;
}
}

void main()
{
writeln(first!str(str));
	writeln(second!( first!str )(StR)); // should match string 
from first, but case insensetive

}

-

How do I extract s parameter of first passed to second via alias 
parameter. It seems like it is not possible. Or is it?


Re: Extracting string parameter from template instance received via alias parameter

2014-09-12 Thread MrSmith via Digitalmars-d

On Friday, 12 September 2014 at 20:37:44 UTC, Ali Çehreli wrote:

On 09/12/2014 12:44 PM, MrSmith wrote:

 Given the following program:

 -
 import std.stdio;

 template first(string s)
 {
  string first(string par)
  {
  if (par == s)
  return true;
  else
  return false;
  }
 }

 template second(alias firstInstance)
 {

TemplateArgsOf:

import std.traits;
foreach (i, arg; TemplateArgsOf!firstInstance) {
writefln(arg %s: %s, i, arg);
}

Prints:

arg 0: str

Ali

P.S. We want to see these topics over at the D.learn newsgroup. 
;)


Thank you, Ali. I will try to not mismatch open tabs next time =)


Re: Ropes (concatenation trees) for strings in D ?

2014-08-16 Thread MrSmith via Digitalmars-d-learn
On Saturday, 16 August 2014 at 02:26:29 UTC, ketmar via 
Digitalmars-d-learn wrote:

On Fri, 15 Aug 2014 19:04:10 -0700
Timothee Cour via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:

sounds like my C library based on this article:
http://e98cuenc.free.fr/wordprocessor/piecetable.html

i'm slowly converting my C code to D (nothing fancy yet, still 
C-style).


it's not a 'real' rope -- it's designed for text editing tasks, 
and it
allocates like crazy now, but it's pretty usable to writing 
rich text

editors and renderers in various GUI toolkits.

don't know when i'll finish first working version though, it's 
all
little tedious and i have alot other things to do. but i'll 
announce it

when it will be done. ;-)


I've done some progress on making piece table some time ago, but 
have no time atm.

Have a look https://github.com/MrSmith33/textedit-d
It supports inserting, removing, undo, redo and slicing. Provides 
forward range interface. Can you also share your progress?


Re: Using input ranges with std.regex?

2014-08-11 Thread MrSmith via Digitalmars-d-learn
On Wednesday, 25 April 2012 at 21:43:11 UTC, Dmitry Olshansky 
wrote:

On 25.04.2012 23:08, H. S. Teoh wrote:
Does std.regex support input ranges to match()? Or do I need 
to convert

to string first?



For now, yes you have to convert them. Any random access range 
of code units should do the trick but stringish template 
constraints might kill that.


I plan to extend this eventually. The problematic point is that 
match internally is delimited by integer offsets (indices). 
Forward ranges technically can work (the match then will return 
something like take(..., n);) with a bunch of extra .save 
calls. Input ranges can't be used at all.


Is there any progress on this thing?


Re: Voting: std.logger

2014-07-30 Thread MrSmith via Digitalmars-d

Yes for inclusion into std.experimental


Re: Review: std.logger

2014-07-14 Thread MrSmith via Digitalmars-d
While trying to use logger i've found that this doesn't work. The 
execution stalls and thread is not executed, while eith writeln 
it works fine.


import std.logger;
import std.parallelism;

void worker()
{
log(in worker);
}

void main()
{
auto pool = taskPool;
pool.put(task!worker);
}


Re: Review: std.logger

2014-07-14 Thread MrSmith via Digitalmars-d
On Monday, 14 July 2014 at 18:54:35 UTC, Robert burner Schadek 
wrote:

On Monday, 14 July 2014 at 18:12:44 UTC, MrSmith wrote:
While trying to use logger i've found that this doesn't work. 
The execution stalls and thread is not executed, while eith 
writeln it works fine.


import std.logger;
import std.parallelism;

void worker()
{
log(in worker);
}

void main()
{
auto pool = taskPool;
pool.put(task!worker);
}


can you make an issue out of it here 
https://github.com/burner/logger, so we

don't lose track


Here it is https://github.com/burner/logger/issues/10


Re: bgfx bindings

2014-07-02 Thread MrSmith via Digitalmars-d-announce

On Tuesday, 1 July 2014 at 20:43:27 UTC, ponce wrote:

Hi,

I'd like to announce DerelictBgfx, a dynamic bindings to the 
bgfx library.

https://github.com/derelictorg/derelictbgfx

bgfx is a library which abstract the accelerated graphics API 
through a common denominator. DX9, DX11, Desktop OpenGL and 
OpenGL ES can be used from the same abstraction. I believe it 
to be useful and risk-mitigating for games.


To allows this feat, a shader language and compiler is included 
in the original library there: https://github.com/bkaradzic/bgfx


Using the derelict-bgfx package, you would have to build bgfx 
as a dynamic library and the associated shader compiler.


bgfx is decoupled from the windowing library. It can be used 
through the likes of SDL and GLFW, provided a OS-dependent 
window handle is given.


That is awesome!


Re: Perlin noise benchmark speed

2014-06-20 Thread MrSmith via Digitalmars-d

On Friday, 20 June 2014 at 12:56:46 UTC, David Nadlinger wrote:

On Friday, 20 June 2014 at 12:34:55 UTC, Nick Treleaven wrote:

On 20/06/2014 13:32, Nick Treleaven wrote:
It apparently shows the 3 main D compilers producing slower 
code than

Go, Rust, gcc, clang, Nimrod:


Also, it does appear to be using the correct compiler flags 
(at least for dmd):

https://github.com/nsf/pnoise/blob/master/compile.bash


-release is missing, although that probably isn't playing a big 
role here.


Another minor issues is that Noise2DContext isn't final, making 
the calls to get virtual.


This should cause such a big difference though. Hopefully 
somebody can investigate this more closely.


David


struct can be used instead of class


Re: Icons for .d and .di files

2014-06-20 Thread MrSmith via Digitalmars-d

On Friday, 20 June 2014 at 16:52:55 UTC, Meta wrote:
On Friday, 20 June 2014 at 16:41:14 UTC, Jordi Sayol via 
Digitalmars-d wrote:

El 20/06/14 18:02, Jordi Sayol via Digitalmars-d ha escrit:

El 20/06/14 11:49, FreeSlave via Digitalmars-d ha escrit:
Thanks, but they are still logos, not icons for files. File 
icon should appear as document. Like this 
http://th04.deviantart.net/fs70/200H/f/2012/037/1/a/c___programming_language_dock_icon_by_timsmanter-d4ougsk.png



http://s28.postimg.org/d4hqy7hv1/dsrc1.png
http://s28.postimg.org/kyicjlpnx/dsrc2.png
http://s28.postimg.org/4os6gpezx/dsrc3.png



A bigger one

http://s7.postimg.org/cmwclyxh7/dsrc4.png


I think the third one is best in this case. You don't want a 
really detailed logo for a file icon.


+1


Re: delegate issue

2014-06-02 Thread MrSmith via Digitalmars-d-learn

On Monday, 2 June 2014 at 06:56:54 UTC, captaindet wrote:

hi,

i stumbled upon something weird - it looks like a bug to me but 
maybe it is a feature that is unclear to me.


so i know i can declare function and delegate pointers at 
module level.

for function pointers, i can initialize with a lambda.
BUT for delegates i get an error - see below

i found out that using module static this(){...} provides a 
workaround, but why is this necessary?


also, if there is a good reason after all then the error 
message should make more sense.


/det

ps: i know there is a shorthand syntax for this.


module demo;

int function(int) fn = function int(int){ return 42; };
// ok

int delegate(int) dg = delegate int(int){ return 666; };
// demo.d(6): Error: non-constant nested delegate literal 
expression __dgliteral6


void main(){}


You can't assign a delegate at compile time now.
But you can do this in static constructor like this:


int delegate(int) dg;
static this()
{
dg = delegate int(int){ return 666; };
}



  1   2   >