Re: Using core/sys/posix/mqueue.d on FreeBSD

2024-04-06 Thread Arjan via Digitalmars-d-learn

On Saturday, 6 April 2024 at 12:05:56 UTC, Jonathan M Davis wrote:
Actually, since I'm usually the one who does the FreeBSD ones 
anyway, here you go:


https://github.com/dlang/dmd/pull/16359

The declarations compile, and they should match the ones in C, 
since I copied them over and then tweaked them, but I haven't 
actually tested them.


All that being said, even if they're merged immediately, they 
won't be available as part of druntime until dmd 2.109.0 is 
released (and 2.108.0 was released less than a week ago), so 
you'll probably need to copy them into your own install or use 
the development version of dmd to get the updated bindings if 
you want to use them now.


- Jonathan M Davis


This is awesome, Jonathan! Thanks a lot for your elaboration on 
the issue, no wonder I got confused, and of course the PR! Really 
appreciated.

Thanks!



Re: Serial communication library

2022-09-24 Thread Arjan via Digitalmars-d-learn

On Saturday, 24 September 2022 at 08:52:42 UTC, Imperatorn wrote:
On Thursday, 22 September 2022 at 12:05:00 UTC, Imperatorn 
wrote:

Hi guys!

What's the best/preferred library to use for serial 
communication (RS)?


Thanks 


I will give onyx-serial a try


Also on code.dlang.org:

https://github.com/NCrashed/serial-port

Depending on you specific needs, using the platform/os api is 
also an option.




Re: What are (were) the most difficult parts of D?

2022-05-12 Thread Arjan via Digitalmars-d-learn

On Thursday, 12 May 2022 at 11:05:08 UTC, Basile B. wrote:

On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
What are you stuck at? What was the most difficult features to 
understand? etc.


To make it more meaningful, what is your experience with other 
languages?


Ali


Overhall I think that D was not hard to learn because well 
designed (i.e intuitive).


 I concur..


A few specific points however that I remember

- Certain variant forms of the `is` Expression are not obvious 
(not intuitive), I'm pretty sure I still cant use them without 
a quick look to the specs.


Yes indeed, had to read through the then excellent 
pdf()https://github.com/PhilippeSigaud/D-templates-tutorial by 
Philippe Sigaud (of PEG) to grasp the whole idea first, and still 
have to look it up when the need to use it arises...




- Operator overloading in certain cases was confusing, I 
remember that for one particular form once I had to use your 
book instead of the official specs (when opSlice and opIndex 
are combined)


Indeed same experience. Also opCmp and opEquals caused some 
confusion.


D's [][] !== C's [][],

Range peculiarities w.r.t some algo's (algo want's fwdRange but 
got inputRange but did not have the constraint ea)


lazy vs eager algorithms (the need to call .array)


The main difficulty I had is actually not specific to D. It was 
to accept that a GC is OK.


Nice one.

I recon I have to think much harder sometimes to know where the 
data is and 'who' has access: stack heap tls mutexed or not 
whatever, but find myself almost never asking this question 
anymore in D, which I use(d) to do almost all the time in c++ 
land. The need for it is almost removed by D.





Re: error connecting to mongodb atlas with vibe.d

2022-05-01 Thread Arjan via Digitalmars-d-learn

On Saturday, 30 April 2022 at 14:29:56 UTC, notsteve wrote:

Hi,

I am trying to setup a simple webserver in D using vibe.d 
(0.9.4) and want to use mongoDB as a database. To achieve this, 
I've set up a mongoDB atlas instance with the following command 
inside the standard app.d file created by vibe.d


```
 string MongoURL = 
"mongodb://username:@cluster0-shard-00-01.gaetq.mongodb.net:27017";


auto client = connectMongoDB(MongoURL);

```

but am getting error [1] below.

Alternatively if I use the following path to the instance

```
string MongoURL =   
"mongodb://username:passw...@cluster0-shard-00-01.gaetq.mongodb.net:27017/myFirstDatabase?ssl=true=false";


```

I get error [2].

I have tried accessing this instance using other programming 
languages and am not having any issues so am sure it is not an 
issue with the database instance. Does anyone have experience 
with this?




Error 1:
```
object.Exception@../../../.dub/packages/vibe-core-1.22.3/vibe-core/source/vibe/core/net.d(777):
 Reached end of stream while reading data.

```


https://github.com/vibe-d/vibe-core/blob/v1.22.3/source/vibe/core/net.d#L777

Apparently, no data is received anymore within the remaining time 
duration.






Error 2:
```
object.Exception@../../../.dub/packages/vibe-d-0.9.4/vibe-d/data/vibe/data/bson.d(813):
 BSON value is type 'int_', expected to be one of [double_]
```


https://github.com/vibe-d/vibe.d/blob/v0.9.4/data/vibe/data/bson.d#L813

There is clearly something wrong with the type expected and 
provided. Check the schemes/layouts.




Re: stripping binaries from LDC2

2022-02-07 Thread Arjan via Digitalmars-d-learn

On Monday, 7 February 2022 at 13:14:19 UTC, max haughton wrote:

On Monday, 7 February 2022 at 12:16:53 UTC, Arjan wrote:
In c++ our release builds are build `-O2 -g` and the resulting 
binaries are stripped with GNU/strip.

Is this also possible with LDC2 generated binaries for D code?
So build D code with `-O2 -g` and then strip the resulting 
binary?


Why build with debug info if you're going to strip it anyway?


The stripped release binaries are going to the client, when a 
problem occurs get a core dump, using the core dump + the 
original binary / symbol gives full debug info off site.


It is common practice.


stripping binaries from LDC2

2022-02-07 Thread Arjan via Digitalmars-d-learn
In c++ our release builds are build `-O2 -g` and the resulting 
binaries are stripped with GNU/strip.

Is this also possible with LDC2 generated binaries for D code?
So build D code with `-O2 -g` and then strip the resulting binary?




Re: How to loop through characters of a string in D language?

2021-12-10 Thread Arjan via Digitalmars-d-learn

On Friday, 10 December 2021 at 06:24:27 UTC, Rumbu wrote:

On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:

Let's say I want to skip characters and build a new string.
The character I want to skip: `;`

Expected result:
```
abcdefab
```


Since it seems there is a contest here:

```d
"abc;def;ghi".split(';').join();
```

:)

```d
"abc;def;ghi".tr(";", "", "d" );
```



Re: KQueue and Fibers

2021-04-09 Thread Arjan via Digitalmars-d-learn

On Friday, 9 April 2021 at 09:00:17 UTC, rashir wrote:

Goodmorning everyone,
I'm trying to understand both Kqueue and Fiber's operation on 
Mac. Why don't I get the correct data as long as I read from 
the socket?
It seems to be reading too early, but Kquue tells me that the 
socket is readable.


...


yield for readibility
kqueue waiting for readibilty
resuming fiber as it's readable 131858
read bytesRead: -1readableAmount:131858 errno:35


35 == EAGAIN This informs the operation (recv) could not complete 
without blocking and should be retried. This does not mean the 
socket is not readable, but the operation would block (for 
whatever reason).


Re: Vibe.d diet template help

2021-02-07 Thread Arjan via Digitalmars-d-learn

On Sunday, 7 February 2021 at 00:05:51 UTC, Tim wrote:

Hi all,

I'm trying to render a diet template out to a WebSocket as a 
string to be inserted into a specific portion of the currently 
served page. Does anyone know how to go about this?


Is the websocket really needed? Otherwise a plain XHR would be 
advised which would Just implie another handler.






Re: Using a betterC dub package in ordinary D

2021-01-08 Thread Arjan via Digitalmars-d-learn

On Friday, 8 January 2021 at 20:19:59 UTC, Bastiaan Veelo wrote:


Off topick, the original js implementation is documented to not 
generate results that are guaranteed to be correct. I could not 
find information on what the conditions are that cause 
deviations, and how large these then can be. Do you have an 
idea about this or experience with accuracy of the algorithm? I 
am looking into whether earcutd can replace GLU tesselation. We 
use the result for engineering purposes (not only 
visualisation) and correctness is important to us.


I've used documentation and implementations from David Eberly at 
https://www.geometrictools.com/ and also on github nowadays to 
get 'correct' or at least 'predictable' behavior for various 
geometric challenges.


Using this library solved various issues for us. The 
documentation is great!


Re: Nasty supprise when using c 'anonymous struct and union' in D with 'static struct'

2020-12-29 Thread Arjan via Digitalmars-d-learn
On Tuesday, 29 December 2020 at 17:49:20 UTC, Steven 
Schveighoffer wrote:

On 12/29/20 12:13 PM, Arjan wrote:
On Tuesday, 29 December 2020 at 14:42:07 UTC, Steven 
Schveighoffer wrote:

On 12/29/20 7:38 AM, Arjan wrote:

see https://en.cppreference.com/w/c/language/struct


structs only add context pointers if nested in functions (and 
even then, only if it's not POD). If nested in structs, 
classes, or unions (or anything else), then no context pointer 
is added.


So the answer is, don't use static.


That is what I discovered indeed. Thanks both for answering and 
the additional information. This could however be made more 
explicit and clear in the documentation.




Re: Nasty supprise when using c 'anonymous struct and union' in D with 'static struct'

2020-12-29 Thread Arjan via Digitalmars-d-learn
On Tuesday, 29 December 2020 at 14:42:07 UTC, Steven 
Schveighoffer wrote:

On 12/29/20 7:38 AM, Arjan wrote:

see https://en.cppreference.com/w/c/language/struct


I added in some printouts of the addresses of the variables.

It appears that if you add static to the struct, it now becomes 
a static member of the union, which means it's not an instance 
variable, and is now a thread-local variable. Its address 
doesn't even coincide remotely with the address of v1.


What is the equivalent behavior for C that you are expecting? 
The usage of "static struct" doesn't appear in that page you 
linked to.


On the C/C++ side there is no static. I added those on the D side 
to to make sure there is no context pointer being added, since 
that will change the layout and size of struct. (in the c/c++ 
code those unions and structs are nested several levels deep)


Based on this: https://dlang.org/spec/struct.html#nested
I expected to have the equivalent of C behavior in D by using the 
static keyword, which in this case just caused havoc. So the 
other way around.




Nasty supprise when using c 'anonymous struct and union' in D with 'static struct'

2020-12-29 Thread Arjan via Digitalmars-d-learn

see https://en.cppreference.com/w/c/language/struct

It seems the 'static' must NOT be used here to get the equivalent 
behavior of c, when left in the assertions will fail.


Is this expected?

```
unittest
{

struct W
{
align(1):
long k;
long l;
}

struct V
{
align(1):
union // anonymous union
{
/*static*/ struct // anonymous structure
{
long i;
long j;
}
W w;
   }
   int m;
}

V v1;

v1.i = 2;
assert( 2 == v1.w.k );
v1.w.l = 5;
assert( 5 == v1.j );
}
```






name enum vs static named enum

2020-11-07 Thread Arjan via Digitalmars-d-learn

What is the usage of `static` in this? :
```
static enum Status
{
NONE,
BUSY,
...
}
```



Dub cmdline overrides?

2020-11-07 Thread Arjan via Digitalmars-d-learn
Is there a cmdline switch to DUB to override certain dub.sdl 
settings for a dependency? Like the addition or override to lib 
dirs or link-libs?


For example once and a while I run into linking issues with 
symbols not found due to the `soname` being different on my 
system than specified in some dependency dub.sdl. Or the lib path 
to the shared lib is different.




Re: How to use bootstrap with vibe.d.

2020-11-07 Thread Arjan via Digitalmars-d-learn

On Thursday, 5 November 2020 at 16:22:11 UTC, Alaindevos wrote:
This is from the bootstrap documentation. I think you must 
adapt this to .dt files.


dt files are basically pugjs https://pugjs.org/ files.

When you use vscode with this extension: 
https://marketplace.visualstudio.com/items?itemName=ditto.convert-html-to-pug


It becomes easy to convert from html to pug/dt.


Re: How to use bootstrap with vibe.d.

2020-11-07 Thread Arjan via Digitalmars-d-learn

On Thursday, 5 November 2020 at 16:22:11 UTC, Alaindevos wrote:
This is from the bootstrap documentation. I think you must 
adapt this to .dt files.

```
...
...
html( lang='nl' )
  head
title #{pageTitle}
meta( charset="utf-8")
meta( name="viewport"
  content="width=device-width, initial-scale=1, 
shrink-to-fit=no" )
link( rel="stylesheet" 
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css;
  
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous")

//- fontawesome icons from localhost
link( rel="stylesheet" href="/css/fontawesome.css" )
link( rel="stylesheet" href="/css/brands.css" )
link( rel="stylesheet" href="/css/solid.css" )

  body
//- main page0
div.d-flex.flex-column.h-100
  //- nav bar
  nav.navbar.navbar-expand-sm.sticky-top
...
```

Like this.


Re: D binary io functions

2020-08-30 Thread Arjan via Digitalmars-d-learn

On Sunday, 30 August 2020 at 06:00:20 UTC, Andy Balba wrote:
going nuts trying to figure out which D functions will 
read/write binary files


see this blog:
http://nomad.uk.net/articles/working-with-files-in-the-d-programming-language.html


Re: scope guard question

2020-06-30 Thread Arjan via Digitalmars-d-learn
On Tuesday, 30 June 2020 at 12:18:14 UTC, Steven Schveighoffer 
wrote:

On 6/30/20 2:56 AM, Arjan wrote:
On Monday, 29 June 2020 at 22:47:16 UTC, Steven Schveighoffer 
wrote:

[...]


Thanks for the assurance. The spec does state it like this:
```
The ScopeGuardStatement executes NonEmptyOrScopeBlockStatement 
at the close of the current scope, rather than at the point 
where the ScopeGuardStatement appears.

```
Which is correct, but there is no single example with a return 
where the ScopeBlockStatement interferes with the return.


I started wondering about this since I hit a bug in a piece of 
code.


I can see where it would be confusing, and it could probably 
contain an example and clarification.


-steve


That would certainly be helpfull.


Re: scope guard question

2020-06-30 Thread Arjan via Digitalmars-d-learn
On Monday, 29 June 2020 at 22:47:16 UTC, Steven Schveighoffer 
wrote:
Yes. The return statement is inside the scope of the function, 
so it runs before the scope is exited. Are you saying the spec 
doesn't say that?


Thanks for the assurance. The spec does state it like this:
```
The ScopeGuardStatement executes NonEmptyOrScopeBlockStatement at 
the close of the current scope, rather than at the point where 
the ScopeGuardStatement appears.

```
Which is correct, but there is no single example with a return 
where the ScopeBlockStatement interferes with the return.


I started wondering about this since I hit a bug in a piece of 
code.


scope guard question

2020-06-29 Thread Arjan via Digitalmars-d-learn

```
void main()
{
  import std.stdio;
  auto f = (){
string[] t;
{ // inner scope
  t ~= "hello";
  scope( exit ) t ~= "world";
} // inner scope exit
return t;
  };

  f().writeln; // ["hello", "world"]
}
```
removing the inner scope in f() gives ["hello"]

So when no inner scope is present, the scope exit 'runs' after 
the return? Is that indeed expected behavior according to the 
specification?


Vibed unix socket

2020-05-20 Thread Arjan via Digitalmars-d-learn
I noticed vibe has gained support for unix sockets. What is 
unclear (at least from API docs) how to create a raw unix stream 
socket.

should `listenTCP` and `connectTCP` be used?
Seems weird because those require a 'port'..



Re: Program exited with code -11

2019-09-18 Thread Arjan via Digitalmars-d-learn
On Wednesday, 18 September 2019 at 13:22:03 UTC, Danny Arends 
wrote:

Hey all,

"Program exited with code -11"


Not signal 11? On unix/linux I assume?




Re: Recommendations for best JSON lib?

2019-04-21 Thread Arjan via Digitalmars-d-learn

On Sunday, 21 April 2019 at 02:09:29 UTC, evilrat wrote:
On Saturday, 20 April 2019 at 20:44:22 UTC, Guillaume Piolat 
wrote:

On Saturday, 20 April 2019 at 18:49:07 UTC, Nick Sabalausky


I also tried experimental std json, asdf and vibe.d.
The only one that worked for me is vibe.d JSON subpackage, and


What was the problem with asdf? I've succesfully used it in the 
past.




dub default settings

2018-03-19 Thread Arjan via Digitalmars-d-learn
I find myself typing over and over again the same things like '-a 
x86_64'. Is it somehow possible to set those defaults?


Re: howto run unittest of a single module in dub driven project?

2018-03-05 Thread Arjan via Digitalmars-d-learn

On Monday, 5 March 2018 at 11:26:37 UTC, Atila Neves wrote:

On Sunday, 4 March 2018 at 10:43:06 UTC, Arjan wrote:
Is it somehow possible to only run the unittests of a single d 
file within a dub project? Of course without resorting to 
typing the complete commandline with all versions includes 
switches etc.


You could use unit-threaded:

http://code.dlang.org/packages/unit-threaded

You'd still need to build everything, but `dub test` would take 
care of that. I started working on, and need to get back to, a 
way of only building one module and needed dependencies.


Atila


Thanx will take a look at it and yes that would be exactly what I 
was after!


Re: howto run unittest of a single module in dub driven project?

2018-03-05 Thread Arjan via Digitalmars-d-learn

On Sunday, 4 March 2018 at 16:51:06 UTC, Basile B. wrote:
[1] 
https://github.com/BBasile/Coedit/commit/f8c5e686c8c6aaa7dc2c770121767e3e59806a0e


Thanks for givin me the idea original poster.


Guess I will have to give coedit another try then.. ;-)

So you do use dub behind the scenes so it seems? Care to 
elaborate a little on how you achieved this?


howto run unittest of a single module in dub driven project?

2018-03-04 Thread Arjan via Digitalmars-d-learn
Is it somehow possible to only run the unittests of a single d 
file within a dub project? Of course without resorting to typing 
the complete commandline with all versions includes switches etc.


Re: Debugging bad requests with vibe

2018-02-09 Thread Arjan via Digitalmars-d-learn

On Friday, 9 February 2018 at 11:46:31 UTC, Nicholas Wilson wrote:

On Friday, 9 February 2018 at 08:06:53 UTC, Seb wrote:
On Thursday, 8 February 2018 at 17:09:44 UTC, Nicholas Wilson 
wrote:
Is there a way I can see/log what requests are being made? I 
can change both the client and server.


-v and -vv


All that gives me is a bunch of
[FAC3BFF6:FAC451F6 dia] Actively closing TCP connection

is there a way to get the JSON being sent?


Wireshark?


Re: Vibe.d rest & web service?

2018-02-08 Thread Arjan via Digitalmars-d-learn
On Wednesday, 7 February 2018 at 20:23:10 UTC, Nicholas Wilson 
wrote:
On Wednesday, 7 February 2018 at 19:50:31 UTC, Jacob Carlborg 
wrote:

Have you tried this?


No. But apart from the fact that I forgot to make the class 
inherit from an interface to that the rest interface would 
actually compile, the web interface is routed before the rest 
interface and so the rest interface would never be reached 
since the methods are all the same and the REST's are shadowed 
by the web's .


Makes me wonder whether or not vibe does honor the http request 
Accept headers?

e.g.: application/json or application/javascript or text/html etc.



Re: R.filter!(..).sort!(..)

2017-11-28 Thread Arjan via Digitalmars-d-learn
On Tuesday, 28 November 2017 at 13:24:09 UTC, Steven 
Schveighoffer wrote:

On 11/28/17 8:10 AM, Arjan wrote:

[...]


The library is correctly telling you that your filtered range 
is not random access. It can't be, because it lazily applies 
the filter (that is, it filters on each element as you popFront 
them). So how can it know what the e.g. 3rd element is, if you 
haven't run any filters yet?


The array version works because you are applying the filter 
completely and storing the results elsewhere in one step.


-Steve


Well I would have liked an error msg something like: 
isRandomAccessRange!Range for Range=.. failed! Or unable to 
sort!() a lazy Range.


R.filter!(..).sort!(..)

2017-11-28 Thread Arjan via Digitalmars-d-learn
When applying a sort!() on a filtered range I get this compiler 
error:


Error: template std.algorithm.sorting.sort cannot deduce function 
from argument types !((a, b) => a.name < 
b.name)(FilterResult!(__lambda3, RangeT!(Array!(IssueType, 
candidates are:

C:\D\dmd2\windows\bin\..\..\src\phobos\std\algorithm\sorting.d(1851,1):std.algorithm.sorting.sort(alias less = "a < 
b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r) if ((ss == SwapStrategy.unstable && 
(hasSwappableElements!Range || hasAssignableElements!Range) || ss != SwapStrategy.unstable && hasAssignableElements!Range) 
&& isRandomAccessRange!Range && hasSlicing!Range && hasLength!Range)

But it seems the problem is with the filter!() result not being a 
isRandomAccessRange!Range because:
R.filter!(..).array.sort!(..) just works (by copying the filter 
results in a array).


Iaw is the compiler error msg wrong? Or i'm I wrong?





Re: debugging in vs code on Windows

2017-10-17 Thread Arjan via Digitalmars-d-learn

On Tuesday, 17 October 2017 at 03:10:52 UTC, Dmitry wrote:

On Tuesday, 17 October 2017 at 02:32:49 UTC, Domain wrote:

Can you share your tasks.json and launch.json?


tasks.json - I don't have this file.
launch.json:
{
"version": "0.2.0",
"configurations": [

{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "${workspaceRoot}\\parser.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}",
"environment": [],
"externalConsole": true
}
]
}

Also I have changed preferences:
"debug.allowBreakpointsEverywhere": true,

Status bar:
x86_64 debug dmd


Before this will work, one must install the Microsoft C/C++ Addin 
i.e. ms-vscode.cpptools.

Start debugging and select the C++ debugger.


Re: best way to interface D code to Excel

2015-06-18 Thread Arjan via Digitalmars-d-learn

On Wednesday, 17 June 2015 at 18:35:36 UTC, Laeeth Isharc wrote:

Hi.

Any thoughts on the best way to write D functions that I can 
call from Excel?  I am completely unfamiliar with Windows 
programming and COM (last time I wrote this kind of thing was 
in the mid-90s I think using xloper and C).


The easiest way for now seems to be via pyxll and pyd.  Wrap 
the D function using pyd and then call it from an annotated 
pyxll python function.  That's probably good enough for a 
start, but it requires python to be installed on each user 
machine which I would rather not have as the end game - just a 
single xll would be perfect.


I know D has support for COM - not sure of its status.  And 
there was a Microsoft chap who posted here a couple of years 
back - wonderful templated code that made it easy to write this 
kind of thing.  Unfortunately he wasn't able to share it 
publicly.


So I would like to write:
1. worksheet function that will function picker and have help 
text in the picker.  In general will take some combination of 
strings, doubles and arrays of doubles as arguments and return 
either string, double, or range/matrix of doubles.
2. vba function with similar kinds of arguments and return 
values.


I know it's easy to do this with double** and the like - at 
least on the VBA side.  I got a bit stuck navigating the 
headers when it comes to Excel strings.


If anyone has some source they could point me to, and some 
reading material then I would very much appreciate it.  This 
might help facilitate adoption of D within a large financial 
institution, but it is early days yet.  And I would guess this 
is a common sort of use for people operating in a financial 
environment, since people are still attached to spreadsheets.


Thanks.


Laeeth.


You actually want to create ActiveX/COM components in D?
See the 'COM in plain C' articles by Jeff Glatt which demonstrate 
how to do it using C. This might give you the information needed 
to do it using D.

http://www.codeproject.com/Articles/Jeff-Glatt#articles.

An idea to accelerate a little might be to use Visual Studio with 
C++ to create ActiveX/COM interfaces, wrappers, etc of the 
components and do the actual implementation of the interfaces in 
D.


Books (old): Inside COM and Essential COM might be handy to 
get hold of.


HTH.
Arjan


Re: dub.json dependencies per configuration?

2015-02-10 Thread Arjan via Digitalmars-d-learn

On Wednesday, 11 February 2015 at 01:06:02 UTC, Mike Parker wrote:

On 2/11/2015 8:38 AM, Arjan wrote:
Snippet from: 
https://github.com/buggins/ddbc/blob/master/dub.json#L7


ddbc has a dependencies on mysql-native: =0.0.12. But 
this is

only true for configurations: MySQL.
Is it allowed to put the dependency within the configuration 
section for

MySQL?.


Yes.


I moved the dependencies into the configuration of MySQL, but 
no dice.
It is accepted by dub but does not make a difference when 
selecting an other configuration. e.g.
dub build -f -c SQLite -a x86 still fetches and builds the 
mysql-native.


Is this behavior of dub expected or a bug?



dub.json dependencies per configuration?

2015-02-10 Thread Arjan via Digitalmars-d-learn
Snippet from: 
https://github.com/buggins/ddbc/blob/master/dub.json#L7


ddbc has a dependencies on mysql-native: =0.0.12. But this 
is only true for configurations: MySQL.
Is it allowed to put the dependency within the configuration 
section for MySQL?.


dependencies: {
mysql-native: =0.0.12
},
targetPath: lib,
targetType: staticLibrary,
configurations: [
{
name: full,
versions: [USE_MYSQL, USE_SQLITE, USE_PGSQL],
libs-posix: [sqlite3, pq],
libs-windows: [sqlite3, libpq],
copyFiles-windows-x86: [ libs/win32/sqlite3.dll, 
libs/win32/libpq.dll, libs/win32/intl.dll ],
sourceFiles-windows-x86 : [ 
libs/win32/sqlite3.lib, libs/win32/libpq.lib ]

},
{
name: MySQL,
versions: [USE_MYSQL]
},
{
name: SQLite,
versions: [USE_SQLITE],
libs-posix: [sqlite3],
libs-windows: [sqlite3],
copyFiles-windows-x86: [ libs/win32/sqlite3.dll ],
sourceFiles-windows-x86 : [ 
libs/win32/sqlite3.lib ]

},
{
name: PGSQL,
versions: [USE_PGSQL],
libs-posix: [pq],
libs-windows: [libpq],
copyFiles-windows-x86: [ libs/win32/libpq.dll, 
libs/win32/intl.dll ],

sourceFiles-windows-x86 : [ libs/win32/libpq.lib ]
}
]


Re: Learning to XML with D

2015-02-07 Thread Arjan via Digitalmars-d-learn

On Friday, 6 February 2015 at 09:15:54 UTC, Derix wrote:
So, I set sails to transform a bunch of HTML files with D. 
This, of course, will happen with the std.xml library.


There is this nice example :
http://dlang.org/phobos/std_xml.html#.DocumentParser
that I put to some use already, however some of the basics seem 
to escape me, specially in lines like


xml.onEndTag[author]   = (in Element e) { book.author
   = e.text(); };

OK, we're doing some event-base parsing, reacting with a lambda 
function on encountering so-and-do tag, à la SAX. (are we ?)


What I don't quite grab is the construct (in Element e) , 
especially the *in* part.


Is it *in* as in http://dlang.org/expression.html#InExpression 
? In which case I fail to see what associative array we're 
considering.


It's probably more a way to further qualify the argument e were 
passing to the  λ-function : could someone elaborate on that ?


Of course, it is entirely possible that I completely miss the 
point and that I'm overlooking some fundamentals, if so have 
mercy and help me find my way back to teh righteous path ;-)



Thxxx


Maybe, when you're on windows, you could use msxml6 through COM.
You have DOM, SAX, Xpath 1.0 and XSLT at your disposal.



Re: Why hibernated does not create tables automatically?

2015-02-06 Thread Arjan via Digitalmars-d-learn

On Friday, 6 February 2015 at 09:42:09 UTC, zhmt wrote:

class Card
{
import hibernated.core;

@Id
@Generated
long id;
@UniqueKey
string pwd;
}

MySQLDriver driver = new MySQLDriver();
	string url = MySQLDriver.generateUrl(10.211.55.10, 3306, 
test);
	string[string] params = MySQLDriver.setUserAndPassword(root, 
xxx);
	auto ds = new ConnectionPoolDataSourceImpl(driver, url, 
params);


EntityMetaData schema = new SchemaInfoImpl!(Card);
Dialect dialect = new MySQLDialect();
auto factory = new SessionFactoryImpl(schema, dialect, ds);


Card c = new Card;
auto s = factory.openSession();
scope(exit) s.close();
s.save(c);


Here is the simplest example, but it complains the same error.

OK,
Before the call
auto s = factory.openSession();
Does de mysql db has a db called 'test' and a table called 'card' 
with columns named 'id' and 'pwd'? If not call:

factory.getDBMetaData().updateDBSchema( conn, true, true );
verify the table is created in mysql.
After create call:
factory.openSession();
...
If things are still failing take a look here:
https://github.com/buggins/hibernated/blob/master/hdtest/source/htestmain.d
This is a simple program testing some basic functions of 
hibernated. Try it with sqlite first after that add a mysql 
section and try again.


Re: Why hibernated does not create tables automatically?

2015-02-06 Thread Arjan via Digitalmars-d-learn

On Friday, 6 February 2015 at 08:53:12 UTC, zhmt wrote:
The app compiles fine, but It throw an exception when I try to 
save data to mysql :


hibernated.type.MappingException@../../../zhmt/.dub/packages/hibernated-0.2.19/source/hibernated/metadata.d(3332): 
Cannot find entity by class ezsockacount.Dao.Customer


My initialization code is something like:

MySQLDriver driver = new MySQLDriver();
		string url = MySQLDriver.generateUrl(10.211.55.10, 3306, 
test);
		string[string] params = 
MySQLDriver.setUserAndPassword(root, xxx);

ds = new ConnectionPoolDataSourceImpl(driver, url, params);

		EntityMetaData schema = new 
SchemaInfoImpl!(Customer,Card,Agent);

Dialect dialect = new MySQLDialect();
factory = new SessionFactoryImpl(schema, dialect, ds);

Connection conn = ds.getConnection();
scope(exit) conn.close();

DBInfo db = factory.getDBMetaData();
db.updateDBSchema(conn, false, true);



I checked the static EntityInfo [] entities; in 
SchemaInfoImpl,

the length of entites is 0.

And tables in mysql is not created automatically either.

I found the point of this question, but dont know how to 
resolve it?


Will anybody help me?

Thx ahead!!


IFAIK partial creation does not work. (bug?)
Use db.updateDBSchema( conn, true, true) make sure none of the 
entities exist in the database. Otherwise it will fail.


hth.


Re: Problem interfacing with GSL

2014-12-01 Thread Arjan via Digitalmars-d-learn
On Sunday, 30 November 2014 at 16:26:53 UTC, Joseph Rushton 
Wakeling via Digitalmars-d-learn wrote:

On 30/11/14 13:21, Arjan via Digitalmars-d-learn wrote:

Hi!
D noob here.
I'm trying to call this function from the GSL lib:


Out of curiosity (since your question has already been 
answered), what functionality is it that is making you want to 
use GSL?  I ask because I want to be sure we're not missing 
something we ought to have in Phobos.


I'm taking a course in statistical inference and uncertainty, 
since I'm learning D, i thought I'd do some numerical computing 
in it.

Does there exist a library so I can stick in D only?


Problem interfacing with GSL

2014-11-30 Thread Arjan via Digitalmars-d-learn

Hi!
D noob here.
I'm trying to call this function from the GSL lib:

double gsl_stats_long_double_mean (const long double [], const 
size_t, const size_t);


linking with: -L-lgsl -L-lgslcblas -L-lm

I have tried different configurations, refering to
http://dlang.org/interfaceToC.html and the forums, but it always 
gives me probems like,

calling it the wrong way or segmentation falt.
Can anyone help?

Arjan


Re: Problem interfacing with GSL

2014-11-30 Thread Arjan via Digitalmars-d-learn

On Sunday, 30 November 2014 at 13:09:15 UTC, John Colvin wrote:

On Sunday, 30 November 2014 at 12:21:51 UTC, Arjan wrote:

Hi!
D noob here.
I'm trying to call this function from the GSL lib:

double gsl_stats_long_double_mean (const long double [], const 
size_t, const size_t);


linking with: -L-lgsl -L-lgslcblas -L-lm

I have tried different configurations, refering to
http://dlang.org/interfaceToC.html and the forums, but it 
always gives me probems like,

calling it the wrong way or segmentation falt.
Can anyone help?

Arjan


the correct signature in D for that would be:

import core.std.config;

double gsl_stats_long_double_mean(const(c_long_double)*, const 
size_t, const size_t);


I admit i was far from getting it right :), and was unaware of 
core.std.config functionalities.

Thanks!
Arjan.


Re: SQLite3

2014-05-08 Thread Arjan via Digitalmars-d-learn

On Thursday, 8 May 2014 at 10:29:16 UTC, Jack wrote:

On Wednesday, 7 May 2014 at 19:03:34 UTC, Arjan wrote:

On Wednesday, 7 May 2014 at 06:21:10 UTC, Jack wrote:

First off a Disclaimer: I'm a noob and still learning. Please
don't bash me like some forums.

Now to the questions: I'm searching for a quick and easy way 
to

integrate SQLite3 in my application.


maybe:
https://github.com/buggins/ddbc/wiki ?


I seem to have a problem with that library. Even if the modules 
have been imported and the libraries linked and yada yada, it 
spews error upon error. Sample code is this:


import std.stdio;
import ddbc.drivers.sqliteddbc;

void main(){

SQLITEDriver driver = new SQLITEDriver();
writeln(SUCCESS);
}


Error spewed out is this:
hello.d|7|Error: undefined identifier SQLITEDriver|

I think Code::Blocks is importing the modules but not detecting 
the modules. Been at it for a few hours now. Any help?


Did you specify the configuration to use to dub?
dub -c SQLite


Re: SQLite3

2014-05-08 Thread Arjan via Digitalmars-d-learn

On Thursday, 8 May 2014 at 11:48:14 UTC, Jack wrote:

On Thursday, 8 May 2014 at 11:07:06 UTC, Arjan wrote:

On Thursday, 8 May 2014 at 10:29:16 UTC, Jack wrote:

On Wednesday, 7 May 2014 at 19:03:34 UTC, Arjan wrote:

On Wednesday, 7 May 2014 at 06:21:10 UTC, Jack wrote:
First off a Disclaimer: I'm a noob and still learning. 
Please

don't bash me like some forums.

Now to the questions: I'm searching for a quick and easy 
way to

integrate SQLite3 in my application.


maybe:
https://github.com/buggins/ddbc/wiki ?


I seem to have a problem with that library. Even if the 
modules have been imported and the libraries linked and yada 
yada, it spews error upon error. Sample code is this:


import std.stdio;
import ddbc.drivers.sqliteddbc;

void main(){

SQLITEDriver driver = new SQLITEDriver();
writeln(SUCCESS);
}


Error spewed out is this:
hello.d|7|Error: undefined identifier SQLITEDriver|

I think Code::Blocks is importing the modules but not 
detecting the modules. Been at it for a few hours now. Any 
help?


Did you specify the configuration to use to dub?
dub -c SQLite


Yes. I've also linked the library to it.
Dub:
http://puu.sh/8DYrR.png
Code::Blocks Configuration:
http://puu.sh/8DYug.png


Ah ok. CodeBlocks does not integrate with dub.
Take a look in the dub.json file of ddbc and collect the 
'versions' for the SQLite configuration (USE_SQLITE)

Add those 'versions' to the DMD commandline n codeblocks:
dmd.exe  -version=USE_SQLITE -version=...


Re: DOSNEWSIZE Error

2014-05-08 Thread Arjan via Digitalmars-d-learn

On Thursday, 8 May 2014 at 14:49:09 UTC, Jack wrote:
I had a compiler error with just a DOSNEWSIZE Error with no 
more information.


Code: http://pastebin.com/UDAgmjtx

I was trying to learn to implement SQLite connections to a 
local file with only the path to the file and no port or 
localhost nonesense from this :


https://github.com/buggins/ddbc/wiki

I tried a google search about the error but so far it landed me 
into a post with no replies, and various other non-D related 
posts.


Optlink error.
Are you builing a x86_32 exe or x86_64 exe?
when 32 bits use the dmd -m32 and make sure to use omf libs.
when 64 bits don not use optlink but MS VS link.exe and use coff 
libs.






Re: SQLite3

2014-05-07 Thread Arjan via Digitalmars-d-learn

On Wednesday, 7 May 2014 at 06:21:10 UTC, Jack wrote:

First off a Disclaimer: I'm a noob and still learning. Please
don't bash me like some forums.

Now to the questions: I'm searching for a quick and easy way to
integrate SQLite3 in my application.


maybe:
https://github.com/buggins/ddbc/wiki ?