beginner's pyd question - exporting structs to python

2014-08-18 Thread Laeeth Isharc via Digitalmars-d-learn
Hi there. Brief introduction, and a beginner's question. I just started playing with D a couple of weeks ago. I have been programming in C on and off since the late 80s, but I do finance for a living and my programming skills grew rusty. I have a bit more time now to catch up with

Re: beginner's pyd question - exporting structs to python

2014-08-18 Thread Laeeth Isharc via Digitalmars-d-learn
Thank to jwhear on irc who solved it for me despite claiming not to be a pyd guru. In case it's of benefit, here is what works: module hellostruct; import pyd.pyd; import std.stdio; import std.conv; struct t_mystruct { int i; string s; }; t_mystruct hellostruct(int[] inp) { int i;

Re: beginner's pyd question - exporting structs to python

2014-08-18 Thread Laeeth Isharc via Digitalmars-d-learn
All the cool folk doing data analysis and visualization using Python no longer bother with hand written C (*) for when pure Python won't cut the mustard. If Numba can't do the job, then Cython gets used. I have all my computational pure Python source codes running as fast as C these days

Re: beginner's pyd question - exporting structs to python

2014-08-18 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 18 August 2014 at 18:08:59 UTC, Russel Winder via Digitalmars-d-learn wrote: […] distutils.util.get_platform(), […] Does os.uname() not provide sufficient information? This was boilerplate generated by pyd.

Re: beginner's pyd question - exporting structs to python

2014-08-18 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 18 August 2014 at 19:28:55 UTC, Russel Winder via Digitalmars-d-learn wrote: On Mon, 2014-08-18 at 19:00 +, Laeeth Isharc via Digitalmars-d-learn wrote: On Monday, 18 August 2014 at 18:08:59 UTC, Russel Winder via Digitalmars-d-learn wrote

Re: beginner's pyd question - exporting structs to python

2014-08-18 Thread Laeeth Isharc via Digitalmars-d-learn
Whilst the hardcore Pythonistas remain Pythonistas, some of the periphery has jumped ship to Go. Sadly D did not capture these folk, it perhaps should have done. It would be easy to blame fadism, but I think the actual reasons are far less superficial. So I gather that you agree that what

Re: beginner's pyd question - exporting structs to python

2014-08-18 Thread Laeeth Isharc via Digitalmars-d-learn
Dr Russel Winder 41 Buckmaster Road London SW11 1EN, UK Are there any D users groups/meetups in London? I see you are not far away (I am in Barnes). Laeeth

building shared library from D code to import into cython

2014-10-07 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. I am trying to create a shared library in D linked against phobos so that I may use this in a cython extension module for Python. Ultimately I would like to be able to use a D class or struct (via the C++ interface) and call it from within cython, since cython classes cannot be

Re: building shared library from D code to import into cython

2014-10-07 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. Thanks for the quick response. The -defaultlib was left around from trying all kinds of combinations of dmd and gcc. I am not used to gcc, and it will take me some time to become properly acquainted with all the options. I simply could not get it to recognize libphobos no matter what

Re: building shared library from D code to import into cython

2014-10-12 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks for this. I am aware of pyd and will take a look at source/build process. Any thoughts on speed in 2014 of pyd vs using cython to talk to D directly via C/C++ interface? I saw this old coment here: prabhuramachandran.blogspot.co.uk/2008/09/python-vs-cython-vs-d-pyd-vs-c-swig

Returning multiple arrays from function - struct or byref the only option?

2014-10-15 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. I have to write a bunch of functions that operate on input arrays to return multiple output arrays. In case helpful the inputs are price bars or economic data points (datetime, ohlc) and the outputs are nx1 arrays (I won't say vectors) of doubles or structs. What is the best way to

Re: Returning multiple arrays from function - struct or byref the only option?

2014-10-15 Thread Laeeth Isharc via Digitalmars-d-learn
Here is byref: import std.typecons; import std.stdio; void myfunction(double x, ref double[] a, ref double[] b) { a~=x+1.0; a~=x+9.0; b~=x+2.0; b~=x+11.0; return; } void main() { double[] a; double[] b; myfunction(99.0,a,b);

Re: Returning multiple arrays from function - struct or byref the only option?

2014-10-18 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks for the thoughts Meta and Ali. Laeeth. On Wednesday, 15 October 2014 at 17:56:06 UTC, Ali Çehreli wrote: On 10/15/2014 09:48 AM, Laeeth Isharc wrote: struct RetStruct { double[] a; double[] b; } RetStruct myfunction(double x) That's my preference. Tuples would work

Re: Issue with WIKI example Win32_DLLs_in_D

2014-10-21 Thread Laeeth Isharc via Digitalmars-d-learn
Funnily enough I was just playing with this last night trying to get Excel to talk to dlang DLL. I borrowed a C example elsewhere on web and used a different .def file. Something like this: LIBRARY dprop DESCRIPTION 'My DLL written in D' EXETYPE NT CODE

Dart bindings for D?

2014-10-29 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. I have had a look around for these, but was not able to see them. It looks perhaps like dart_api.h is the main file to convert - I will have a crack at starting this unless anyone knows of any already in existence. Rationale for using Dart in combination with D is that I am not

Re: Dart bindings for D?

2014-10-30 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. Thanks for all the thoughts, and sorry it has taken me a little while to reply. Adam - I liked your book very much: it really complemented the other resources out there, especially in communicating a refreshing spirit of enthusiasm and fearless exploration. ketmar - I took a look at

alias and extern(C)

2014-10-30 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. I am trying to translate the following from the Dart header: typedef void (*Dart_MessageNotifyCallback)(Dart_Isolate dest_isolate); So I made a little simple test to understand callbacks in D. The code below works fine if you remove the extern(C). But I get the error

Re: alias and extern(C)

2014-10-30 Thread Laeeth Isharc via Digitalmars-d-learn
The code below works fine if you remove the extern(C). But I get the error functionpointertest.d(6): Error: basic type expected, not extern with the code as it is. How do I use alias with extern ? [...] alias Callback= extern(C) void function(int); Compiles as is with dmd 2.066. For

Re: Dart bindings for D?

2014-10-30 Thread Laeeth Isharc via Digitalmars-d-learn
Ah - makes sense. It is satisfyingly fast... On Thursday, 30 October 2014 at 21:33:59 UTC, ketmar via Digitalmars-d-learn wrote: On Thu, 30 Oct 2014 17:39:13 + Laeeth Isharc via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: BTW what was the story behind dscript? It seems

simd and dmd compiler v 2.066 and 2.067.0-b1

2014-11-03 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. Not sure if my code is correct - I wanted to build the simplest working example of simd use. The following compiles and works under ldc (I have not disassessembled the result to see if it is using simd instructions), but generates a compiler error under dmd (2.066 and 2.067.0-b1 running

Re: simd and dmd compiler v 2.066 and 2.067.0-b1

2014-11-03 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 3 November 2014 at 21:23:50 UTC, Marc Schütz wrote: Reduced testcase: import core.simd; void main() { short8 vec; vec=vec*3; } I've filed a bug report: https://issues.dlang.org/show_bug.cgi?id=13674 Thanks - appreciate it. Laeeth.

rndtonl

2014-11-04 Thread Laeeth Isharc via Digitalmars-d-learn
what am I doing wrong here? import std.math; import std.stdio; void main() { real fac; fac=1.2; fac=rndtonl(fac); } [root@fedorabox util]# dmd bug.d bug.o: In function `_Dmain': bug.d:(.text._Dmain+0x3b): undefined reference to `rndtonl' collect2: error: ld returned 1

Re: rndtonl

2014-11-05 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks, Adam. Should we perhaps make a pull to suggest updating the docs/wiki? As the point below is not what one would infer from the dlang.org library reference page. (If I say we, it's because I don't know what the protocol is, or whether my perception is right). On Tuesday, 4

status of D optimizers benefiting from contracts ?

2014-11-09 Thread Laeeth Isharc via Digitalmars-d-learn
https://www.youtube.com/watch?v=e2F2pqeMLuwlist=PL4EvMyUrlAJmEfs8l6oW2BlnALiDu7kGy 31 minutes in, Walter Bright suggests that a supplementary benefit of using contrats is helping the compiler make optimisations. He uses the example of being able to do faster 32 bit arithmetic when the

Re: status of D optimizers benefiting from contracts ?

2014-11-09 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks. Laeeth.

PyD-like wrapping for Excel/VBA and Julia?

2014-12-18 Thread Laeeth Isharc via Digitalmars-d-learn
I have a bunch of D functions I would like to make available to Excel (and possibly Julia) without having to write wrappers for each function individually. For Excel, I think one needs two levels of wrapper - one is to create a C style interface [using extern(Windows) calling convention, and

Re: PyD-like wrapping for Excel/VBA and Julia?

2014-12-19 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 19 December 2014 at 01:59:05 UTC, Ellery Newcomer wrote: On 12/18/2014 12:41 PM, Laeeth Isharc wrote: I have a bunch of D functions I would like to make available to Excel (and possibly Julia) without having to write wrappers for each function individually. I've thought about

optimization / benchmark tips a good topic for wiki ?

2014-12-22 Thread Laeeth Isharc via Digitalmars-d-learn
Replacing import core.stdc.math with import std.math in the D example increases the avg runtime from 19.64 to 23.87 seconds (~20% slower) which is consistent with OP's statement. + GDC/LDC vs DMD + nobounds, release Do you think we should start a topic on D wiki front page for

Data frames in D?

2014-12-26 Thread Laeeth Isharc via Digitalmars-d-learn
I thought about it once but quickly abandoned the idea. The primary reason was that D doesn't have REPL and is thus not suitable for interactive data exploration. The quick compile times could allow interactive data exploration I agree with other posters that a D REPL and

Re: Data frames in D?

2014-12-26 Thread Laeeth Isharc via Digitalmars-d-learn
REPLs are over-hyped and have become a fashion touchstone that few dare argue against for fear of being denounced as un-hip. REPLs have their place, but in the main are nowhere near as useful as people claim. IPython Notebooks on the other hand are a balance between editor/execution

Data Frames in D - let's not wait for linear algebra; useful today in finance and Internet of Things

2014-12-26 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 26 December 2014 at 21:31:00 UTC, aldanor wrote: On Wednesday, 25 September 2013 at 03:41:36 UTC, Jay Norwood wrote: I've been playing with the python pandas app enables interactive manipulation of tables of data in their dataframe structure, which they say is similar to the

Re: Data Frames in D - let's not wait for linear algebra; useful today in finance and Internet of Things

2014-12-27 Thread Laeeth Isharc via Digitalmars-d-learn
Russell: I think we are agreeing. Very lightweight editor and executor of code fragments is as good, if not better, that the one line REPL. Yes - the key for me is that the absence of a shell is by no means a reason to say that D is not suited to this task. One may wish to refine what

Re: Data Frames in D - let's not wait for linear algebra; useful today in finance and Internet of Things

2014-12-27 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 27 December 2014 at 16:41:04 UTC, Russel Winder via Digitalmars-d-learn wrote: On Sat, 2014-12-27 at 15:33 +, Laeeth Isharc via Digitalmars-d-learn wrote: […lots of agreed uncontentious stuff :-) …] You write as if Christensen's book The Innovator's Dilemma had never been

Re: Data Frames in D - let's not wait for linear algebra; useful today in finance and Internet of Things

2014-12-29 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 29 December 2014 at 04:08:58 UTC, Vlad Levenfeld wrote: Laeeth - I am not sure exactly what your needs are but I have a fairly complete solution for generic multidimensional interfaces (template-based, bounds checked, RAII-ready, non-integer indices, the whole shebang) that I have

Re: Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Argh - no way to edit. What's best practice here? D strings are not null-terminated. === cpling.c char* cpling(char *s) { s[0]='!'; return s; } === dcaller.d extern(C) char* cpling(char* s); void callC() { writefln(%s,fromStringz(cpling(hello\0))); } or void callC() {

Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
What's best practice here? D strings are not null-terminated. char* cpling(char *s) { So toString(This i

Checking C return results against NULL

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Am I missing a more agreeable way to check the return value of a C function against NULL. It's fine if it's a char*, but if it returns a pointer to some kind of struct, one has to go through and convert each instance of NULL to a cast of the appropriate return type. Eg cast(funnystruct*)0

Re: Passing string literals to C

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks for the help. Laeeth

Re: Checking C return results against NULL

2014-12-31 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks for the help. Laeeth

Re: Can the order in associative array change when keys are not midified?

2015-01-01 Thread Laeeth Isharc via Digitalmars-d-learn
On Thursday, 1 January 2015 at 18:58:04 UTC, Andrej Mitrovic via Digitalmars-d-learn wrote: On 1/1/15, Tobias Pankrath via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: You could implement an OrderedMap!(Key, Value) via RedBlackTree!(Tuple!(Key, Value), (a,b) = a[0] b[0]). We

Re: simple question about using dub to import CyberShadow's aeutils

2015-01-03 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 3 January 2015 at 12:08:16 UTC, Vladimir Panteleev wrote: On Saturday, 3 January 2015 at 11:58:48 UTC, Laeeth Isharc wrote: import ae.utils; ae.utils is a package, perhaps you meant to import ae.utils.xml? aha. schoolboy error on my part. thank you for your help, and

simple question about using dub to import CyberShadow's aeutils

2015-01-03 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. I would like to use the XML parser from CyberShadow's ae.utils - I am building a tool to index RSS feeds in elasticsearch (something like rssriver but with more complete functionality). I am using dub to build the code. So far I just have an empty boilerplate app.d with the line import

Other libraries - web site link, and other thoughts

2015-01-26 Thread Laeeth Isharc via Digitalmars-d-learn
At the moment it goes straight go code.dlang.org, which may be a bit overwhelming if you have just arrived at dlang.org and want to see what it can do. Is it worth changing to the library wiki write up page on libraries? And making sure link to code.dlang.org is prominent, saying

Re: D Beginner Trying Manual Memory Management

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
I don't think you've read h5py source in enough detail :) You're right - I haven't done more than browsed it. It's based HEAVILY on duck typing. There is a question here about what to do in D. On the one hand, the flexibility of being able to open a foreign HDF5 file where you don't know

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
On Tuesday, 13 January 2015 at 17:41:53 UTC, Tobias Pankrath wrote: On Tuesday, 13 January 2015 at 17:19:42 UTC, Laeeth Isharc wrote: The GC is allowed to move structs around, as I undestand it. Under what circumstances do I get into trouble having a pointer to them? None, a GC that moves

Re: vibe.d Subdirectory?

2015-01-15 Thread Laeeth Isharc via Digitalmars-d-learn
On Thursday, 15 January 2015 at 14:38:16 UTC, Steven Schveighoffer wrote: On 1/14/15 11:31 AM, Laeeth Isharc wrote: To be very clear: in the simple case when you compile your vibe application from multiple source files and diet templates etc, and you will end up with an executable. This can

Re: Getting a safe path for a temporary file

2015-01-17 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 17 January 2015 at 13:47:39 UTC, Marc Schütz wrote: Is it currently possible to get the path to a safe temporary file, i.e. one that is guaranteed to be freshly created and will not override another existing file? There's `std.file.tempDir`, which doesn't create a unique file.

Re: Getting a safe path for a temporary file

2015-01-17 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 17 January 2015 at 16:55:42 UTC, Marc Schütz wrote: On Saturday, 17 January 2015 at 14:37:00 UTC, Laeeth Isharc wrote: On Saturday, 17 January 2015 at 13:47:39 UTC, Marc Schütz wrote: Is it currently possible to get the path to a safe temporary file, i.e. one that is guaranteed to

Re: casting SysTime to ubyte[]

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
I really wouldn't advise doing that. SysTime contains a long which represents the time in hnsecs since midnight, January 1st, 1 A.D., and that could be written to a file quite easily. But it also contains a reference to a TimeZone object, so what you're doing would just be writing its

Re: vibe.d Subdirectory?

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
Actually I want to serve some JSON packed weather data (heck I also wrote my Global Climate Model partially in D and in C) - so I guess, I can use vibe.d to build a cgi. Cool. Do you incorporate the influence of solar activity via galactic rays / cloud formation and via volcanic activity?

Re: D Beginner Trying Manual Memory Management

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
In the hierarchy example above (c++ hdf hierarchy link), by using UFCS to implement the shared methods (which are achieved by multiple inheritance in the c++ counterpart) did you mean something like this? // id.d struct ID { int id; ... } // location.d struct Location { ID _id; alias _id

Re: D Beginner Trying Manual Memory Management

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
struct File { Location _location; alias _location this; ... } // group.d public import commonfg; struct File { Location _location; alias _location this; ... } // commonfg.d { ... } enum isContainer(T) = is(T: File) || is(T : Group); auto method1(T)(T obj, args) if (isContainer!T) { ... } auto

Re: vibe.d Subdirectory?

2015-01-14 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 14 January 2015 at 11:40:26 UTC, seany wrote: I am new to vibe.d and plying a bit with it. I notice, that in case of Apache, there is a root directory, often by default under /var/www or /srv/http (resp. ftp) if you are using linux, and then every time the client sends a

Re: Explicit Slicing of std.container.Array

2015-01-24 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 24 January 2015 at 13:11:33 UTC, Nordlöw wrote: Is there a reason why std.container.Array have to be explicitly sliced before being processed by range algorithms such as filter typically as import std.container: Array; Array!int a; foreach (e; a[].filter!true) {} ?

Re: Turning Executable into Application?

2015-01-25 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 26 January 2015 at 03:36:32 UTC, Gan wrote: With Xamarin Studio I create a D project and run it. It runs an Executable Unix file through the terminal. How can I turn that into an Application that doesn't open the Terminal? Thanks. Have you tried running your executable from the

Re: BitArray - incomplete implementation?

2015-01-23 Thread Laeeth Isharc via Digitalmars-d-learn
To avoid confusion, the below is the code that fits the error message: import std.bitmanip; import std.stdio; import std.array; import std.range:chain; void test() { int[] a=[1,2,3,4,5]; int[] b=[5,4,3,2,1]; int[] c = chain(a,b).array; // chain two arrays of int

BitArray - incomplete implementation?

2015-01-23 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. Should the following code work? import std.bitmanip; import std.stdio; import std.array; import std.range:chain; void test() { int[] a=[1,2,3,4,5]; int[] b=[5,4,3,2,1]; int[] c = chain(a,b).array; // chain two arrays of int writefln(%s,c); } void test2() {

Re: BitArray - incomplete implementation?

2015-01-23 Thread Laeeth Isharc via Digitalmars-d-learn
Yes, that error is caused by a bug of BitArray(https://issues.dlang.org/show_bug.cgi?id=13806). Having init function broke template constraints of chain(and must break dozen of other templates). pragma(msg, ElementType!(BitArray[])) // prints 'pure nothrow void(bool[] ba)' - ElementType uses

Re: foreach - premature optimization vs cultivating good habits

2015-02-01 Thread Laeeth Isharc via Digitalmars-d-learn
Thank you Adam, Bbaz and Ola for the helpful thoughts. I dumped them in a wiki page off the sandbox but needs editing and refining.

Re: foreach - premature optimization vs cultivating good habits

2015-01-30 Thread Laeeth Isharc via Digitalmars-d-learn
On Friday, 30 January 2015 at 12:55:20 UTC, Adam D. Ruppe wrote: On Friday, 30 January 2015 at 11:55:16 UTC, Laeeth Isharc wrote: As I understand it, foreach allocates when a simple C-style for using an array index would not. foreach is just syntax sugar over a for loop. If there's any

Re: simple dub question - avoiding creating a vibed project

2015-01-05 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 5 January 2015 at 10:46:17 UTC, Rikki Cattermole wrote: On 5/01/2015 11:42 p.m., Laeeth Isharc wrote: Figured out a fix: versions: [VibeCustomMain], It is still mysterious as to why it is pulling in vibed though (I don't import it, and I didn't think ddbc did).

simple dub question - avoiding creating a vibed project

2015-01-05 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. I am building an example for hibernated (I put a main around the sample code extract from the website). How do I stop dub trying to build a vibed project? Here is my dub.json { name: ddbc example, description: example for DB Connector for D language, similar to JDBC,

Re: simple dub question - avoiding creating a vibed project

2015-01-05 Thread Laeeth Isharc via Digitalmars-d-learn
Figured out a fix: versions: [VibeCustomMain], It is still mysterious as to why it is pulling in vibed though (I don't import it, and I didn't think ddbc did).

Re: simple dub question - avoiding creating a vibed project

2015-01-05 Thread Laeeth Isharc via Digitalmars-d-learn
I opened an issue about this last year: https://github.com/mysql-d/mysql-native/issues/44 Thanks. Laeeth.

Any chance of a linux dtoh?

2015-01-06 Thread Laeeth Isharc via Digitalmars-d-learn
I realize Walter has far better things to work on, but value of having a translation tool is considerable, since it opens up easy access to an enormous range of libraries. It is not much work to do the translation oneself, but in the world as it is small frictions cumulatively have large

Re: Any chance of a linux dtoh?

2015-01-06 Thread Laeeth Isharc via Digitalmars-d-learn
On Tuesday, 6 January 2015 at 14:11:19 UTC, Dicebot wrote: dstep is your only realistic chance currently. htod is completely unmaintained, even on Windows. Please report any issues found with it in relevant issue tracker. I got it the wrong way around - yes, I meant htod. I have reported the

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-10 Thread Laeeth Isharc via Digitalmars-d-learn
Small recommendation (apart from the reserved word issue which you fixed): it's generally considered good D style to give structs and classes names that start with capital letters, JustLikeThis. So, I suggest Node rather than node. Very minor point, and of course, your code is yours to style

Re: Wrapping a C library with its own GC + classes vs refcounted structs

2015-01-10 Thread Laeeth Isharc via Digitalmars-d-learn
Hi Aldanor. I wrote a slightly longer reply, but mislaid the file somewhere. I guess your question might relate to wrapping the HDF5 library - something that I have already done in a basic way, although I welcome your project, as no doubt we will get to a higher quality eventual solution

endsWith - for a string vs an array of strings

2015-01-10 Thread Laeeth Isharc via Digitalmars-d-learn
I understand from previous discussion there is some difficulty over immutability. I did not quite figure out what the solution was in this case: import std.array; import std.string; import std.stdio; void main(string[] args) { string[] test=[1,two,three!]; auto

casting SysTime to ubyte[]

2015-01-12 Thread Laeeth Isharc via Digitalmars-d-learn
import std.datetime; import std.stdio; import std.conv; void main(string[] arg) { auto a=Clock.currTime(); auto b=cast(ubyte[])a; writefln(%s,b); } how do i get the time as a binary representation I can write to a file? Thanks.

Re: endsWith - for a string vs an array of strings

2015-01-12 Thread Laeeth Isharc via Digitalmars-d-learn
Thanks for the help to everyone. It seems a common thing to want to check an array as one may not know the variables at compile time. Not that it's more than a few lines to do in D. But in terms of language adoption, small frictions can have large consequences over time. (Modern people

Re: Wrapping a C library with its own GC + classes vs refcounted structs

2015-01-12 Thread Laeeth Isharc via Digitalmars-d-learn
Laeeth. Thanks for the reply. Yes, this concerns my HDF5 wrapper project; the main concern is not that the memory consumption of course, but rather explicitly controlling lifetimes of the objects (especially objects like files -- so you are can be sure there are no zombie handles floating

Re: How to prevent sensitive information is displayed when the extension 'exe' is modified to 'txt' on windows?

2015-01-07 Thread Laeeth Isharc via Digitalmars-d-learn
What you want is some kind of code obfuscation. The easiest thing for you is to use exe compression. It is not going to stop a dedicated attacker, but ordinary people will not be able to extract any information from it. And I guess as an alternative to the utility you linked to, you

Re: D Beginner Trying Manual Memory Management

2015-01-13 Thread Laeeth Isharc via Digitalmars-d-learn
I see, thanks! :) I've started liking structs more and more recently as well and been pondering on how to convert a class-based code that looks like this (only the base class has any data): it's hard to tell by brief description. but having multiple inheritance immediately rings an

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-13 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 7 January 2015 at 14:59:58 UTC, H. S. Teoh via Digitalmars-d-learn wrote: On Wed, Jan 07, 2015 at 02:52:51PM +, Laeeth Isharc via Digitalmars-d-learn wrote: Another schoolboy question. Suppose I am constructing a tree (in this case it is an AST). In C I would have a pointer

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-08 Thread Laeeth Isharc via Digitalmars-d-learn
this conversation is so funny: well what's wrong with this . It's a keyword... Aa Ha ha ha ha , rol. Seriously, is it so complicated to use a D editor ? I mean with syntax color... Man afraid to ask stoopid questions stays stoopid. And compiler error message far from informative. Not

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-07 Thread Laeeth Isharc via Digitalmars-d-learn
ref is a reserved keyword. doh! Thanks.

idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-07 Thread Laeeth Isharc via Digitalmars-d-learn
Another schoolboy question. Suppose I am constructing a tree (in this case it is an AST). In C I would have a pointer for the child to find the parent, and an array or linked list of pointers to find the children from the parent. Obviously, I could still use pointers, but that would not be

tango linking problem

2015-01-06 Thread Laeeth Isharc via Digitalmars-d-learn
when trying to build dstep. any thoughts? (since I thought it may be a problem on my machine rather than something dstep specific). Fedora 21 64 bit, release dmd. Target tango 1.0.0+2.066 is up to date. Use --force to rebuild. Target mambo 0.0.3 is up to date. Use --force to rebuild. Target

Re: Any chance of a linux dtoh?

2015-01-06 Thread Laeeth Isharc via Digitalmars-d-learn
On Tuesday, 6 January 2015 at 14:25:19 UTC, Dicebot wrote: On Tuesday, 6 January 2015 at 14:14:28 UTC, Laeeth Isharc wrote: On Tuesday, 6 January 2015 at 14:11:19 UTC, Dicebot wrote: dstep is your only realistic chance currently. htod is completely unmaintained, even on Windows. Please report

Re: idiomatic D: what to use instead of pointers in constructing a tree data structure?

2015-01-07 Thread Laeeth Isharc via Digitalmars-d-learn
Not true. If you're using a tree structure, you *should* use pointers. Unless you're using classes, which are by-reference, in which case you can just use the class as-is. :-) Thanks v much. I just came to that realization also when I stepped away. class node { string name;

Re: calling C variadic arguments with no 'argc' and only variadic arguments

2015-03-18 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 05:38:40 UTC, Ali Çehreli wrote: On 03/17/2015 06:13 PM, Laeeth Isharc wrote: DMD gave me an error message for the following declarations: double mgl_rnd (...); double mgl_rnd_ (...); Are you sure those are the right signatures? I don't think those functions

calling C variadic arguments with no 'argc' and only variadic arguments

2015-03-17 Thread Laeeth Isharc via Digitalmars-d-learn
So I ported the C API for MathGL to D, and it is up at code.dlang.org (under dmathgl). MathGL is a nice plotting library. http://mathgl.sourceforge.net/doc_en/Pictures.html#Pictures Later I will work on porting the C++ interface, but so far it at least works for the simplest sample. (Not

Re: pyd and converting arrays of strings

2015-03-18 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 18 March 2015 at 20:58:56 UTC, John Colvin wrote: On Wednesday, 18 March 2015 at 17:09:27 UTC, Laeeth Isharc wrote: Hi I am using PyD with latest stable LDC on Arch Linux 64 bit. I have various structures I am trying to wrap to pass to python. For example: struct PlotLines {

pyd and converting arrays of strings

2015-03-18 Thread Laeeth Isharc via Digitalmars-d-learn
Hi I am using PyD with latest stable LDC on Arch Linux 64 bit. I have various structures I am trying to wrap to pass to python. For example: struct PlotLines { KPDateTime[] start_dates; KPDateTime[] end_dates; double[] y; string[] colors; long[]

Re: Windows - std.process - Setting env variables from D

2015-03-30 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 30 March 2015 at 12:28:19 UTC, wobbles wrote: I'm trying to set environment variables that will be visible when my D program exits. It is possible in a windows batch file using the set command (like set VAR=VALUE ) However, running this in D using: import std.process; import

Re: Windows - std.process - Setting env variables from D

2015-03-30 Thread Laeeth Isharc via Digitalmars-d-learn
On Monday, 30 March 2015 at 13:29:06 UTC, wobbles wrote: On Monday, 30 March 2015 at 12:54:28 UTC, Adam D. Ruppe wrote: On Monday, 30 March 2015 at 12:28:19 UTC, wobbles wrote: Any solutions that people know of? You can't from an exe, it is a limitation of the operating system (same on

Re: Windows - std.process - Setting env variables from D

2015-03-30 Thread Laeeth Isharc via Digitalmars-d-learn
You tried setx, and it didn't work ? Or you don't want to set permanent environmental variables Yep, correct. Don't want them to be permanent. The systems have to be clean for other tests at all times, so they need to be on a shell by shell basis sadly. Thanks - was curious to know.

Maxime's micro allocation benchmark much faster ?

2015-03-31 Thread Laeeth Isharc via Digitalmars-d-learn
I was curious to see if new DMD had changed speed on Maxime Chevalier-Boisvert's allocation benchmark here: http://pointersgonewild.com/2014/10/26/circumventing-the-d-garbage-collector/ I haven't had time to look at the Phobos test suite to know if this was one of those that were included,

Re: Maxime's micro allocation benchmark much faster ?

2015-03-31 Thread Laeeth Isharc via Digitalmars-d-learn
oops - scratch that. may have made a mistake with versions and be comparing 2.067 with some unstable dev version. On Tuesday, 31 March 2015 at 11:46:41 UTC, Laeeth Isharc wrote: I was curious to see if new DMD had changed speed on Maxime Chevalier-Boisvert's allocation benchmark here:

Re: Maxime's micro allocation benchmark much faster ?

2015-04-01 Thread Laeeth Isharc via Digitalmars-d-learn
On Wednesday, 1 April 2015 at 10:35:05 UTC, John Colvin wrote: On Wednesday, 1 April 2015 at 10:09:12 UTC, FG wrote: On 2015-03-31 at 22:56, Laeeth Isharc wrote: 1mm allocations 2.066: 0.844s 2.067: 0.19s That is great news, thanks! OT: it's a nasty financier's habit to write 1M and 1MM

OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-27 Thread Laeeth Isharc via Digitalmars-d-learn
An old essay that may yet be relevant today at a time when intellectual fashion has continued in the direction he was moved to address in his speech. there is a way to make a big improvement: it is still a pleasure to do routine jobs if we have beautiful things to work with. For example, a

Re: Maxime's micro allocation benchmark much faster ?

2015-03-31 Thread Laeeth Isharc via Digitalmars-d-learn
Trying on a different beefier machine with 2.066 and 2.067 release versions installed: 1mm allocations: 2.066: 0.844s 2.067: 0.19s 10mm allocations 2.066: 1m 17.2 s 2.067: 0m 1.15s So numbers were ballpark right before, and allocation on this micro-benchmark much faster.

Re: Maxime's micro allocation benchmark much faster ?

2015-03-31 Thread Laeeth Isharc via Digitalmars-d-learn
On Tuesday, 31 March 2015 at 22:00:39 UTC, weaselcat wrote: On Tuesday, 31 March 2015 at 20:56:09 UTC, Laeeth Isharc wrote: Trying on a different beefier machine with 2.066 and 2.067 release versions installed: 1mm allocations: 2.066: 0.844s 2.067: 0.19s 10mm allocations 2.066: 1m 17.2 s

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Laeeth Isharc via Digitalmars-d-learn
The whole art/science vein of these Knuth quotes seems like a lot of BS, trying to situate computer programming in the long-standing and overblown science/humanities divide. I should like to see an argument rather than mere assertion. Steve Jobs is not an authority on this subject, but I

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Laeeth Isharc via Digitalmars-d-learn
On Saturday, 28 March 2015 at 09:04:51 UTC, Messenger wrote: On Saturday, 28 March 2015 at 01:09:44 UTC, Laeeth Isharc wrote: On Friday, 27 March 2015 at 11:33:39 UTC, Kagamin wrote: Hmm... science exists only as long as we don't understand something, then it disappears and only knowledge

Re: OT; Donald Knuth on beauty, efficiency, and the programmer as artist

2015-03-29 Thread Laeeth Isharc via Digitalmars-d-learn
On Sunday, 29 March 2015 at 18:51:19 UTC, Joakim wrote: On Sunday, 29 March 2015 at 18:05:28 UTC, Laeeth Isharc wrote: I appreciate that many of us have better things to do. But I had been thinking about why I find D appealing, and how I would get this across to future partners, and had also

using vibe.d to parse json

2015-03-23 Thread Laeeth Isharc via Digitalmars-d-learn
Hi. struct RawGoogleResults { string version_; string status; string sig; string[string][][string] table; } enum json = {version:0.6,status:ok,sig:717451517,table:{cols:[{id:date,label:Date,type:date,pattern:},{id:query0,label:euro

Re: using vibe.d to parse json

2015-03-23 Thread Laeeth Isharc via Digitalmars-d-learn
On Tuesday, 24 March 2015 at 04:53:39 UTC, Laeeth Isharc wrote: Hi. struct RawGoogleResults { string version_; string status; string sig; string[string][][string] table; } enum json =

Re: using vibe.d to parse json

2015-03-25 Thread Laeeth Isharc via Digitalmars-d-learn
Yeah, it is not very intuitive. But it works. Thanks. Next question - how can I correctly deal with inconsiderately chosen JSON field names like 'private' (which conflict in a struct declaration with D language keywords). A hack is to do a search and replace on the JSON before presenting

  1   2   3   4   >