Re: Why can't functions and struct types have the same name?

2015-01-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 26 January 2015 at 11:15:26 UTC, Joakim wrote: Right now, any attempt to have symbols with the same name errors out, regardless of how they're used. This caused a problem for me because I'm trying to use a third-party C library that defines a struct type called "socket" and my code

Re: Threads and stdio and HANDLE

2015-01-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 28 January 2015 at 11:50:46 UTC, Danny wrote: Hello, I'm trying to write some toy examples using threads in D. Is the std.stdio.File thread-local or shared? Is flockfile used when I synchronize on it? I tried checking phobos myself and found some things I don't get (in stdio.d

Re: BitArray crash

2015-01-30 Thread Nicholas Wilson via Digitalmars-d-learn
I think I have to set "length" first. Yes. Declaring BitArray b; is like declaring int[] a; // ={.length = 0, . ptr = null} you get the segfault for invalid dereference.

Re: Error when profiling

2015-02-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 31 January 2015 at 14:12:59 UTC, Phil wrote: When trying to run my program with profiling enabled it dies before the first line of my main function runs. Everything works fine without profiling. I get the following stack trace: thread #1: tid = 0x38de4, 0x00010008d985 vision

Re: Syntax for checking if an element exists in a list

2015-02-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 5 February 2015 at 12:31:31 UTC, Stéphane wrote: Syntax for checking if an element exists in a list Hello, I would like to know if there is a better (easier to wite, easier to read, easier to understand) way to check if an element (string) is in a list of strings. Here are t

Re: Syntax for checking if an element exists in a list

2015-02-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 5 February 2015 at 13:31:21 UTC, Nicholas Wilson wrote: On Thursday, 5 February 2015 at 12:31:31 UTC, Stéphane wrote: Syntax for checking if an element exists in a list Hello, I would like to know if there is a better (easier to wite, easier to read, easier to understand) way to

Re: Issue with template function

2015-02-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 6 February 2015 at 17:09:29 UTC, Charles wrote: I'm trying to create a template function that can take in any type of array and convert it to a ubyte array. I'm not concerned with endianness at the moment, but I ran into a roadblock when trying to do this with strings. It already wor

Re: Issue with template function

2015-02-07 Thread Nicholas Wilson via Digitalmars-d-learn
The original code I was using was written in Java, and only had a method for strings. This is closer to what I wanted. My unit tests were just going back and forth with readString function, so I was completely missing this for other types. Nice catch! There were a couple issues with your cod

Re: Binding C++ value types

2015-02-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 9 February 2015 at 19:30:32 UTC, Benjamin Thaut wrote: When binding C++ value types you might want to use them by placing them on the D-Stack. This however seems to be not supported as the mangling for the constructor is completely wrong. Is this supposed to work? Kind Regards Benj

Re: How to make Application bundle from Executable? (Mac)

2015-02-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 20 February 2015 at 03:26:47 UTC, Gan wrote: Also I can't get my application to load images that I place in the Resources folder(or any folder in the bundle for that matter). I suggest to have a look at the projects generated by SFML regarding locating the resources in C++/ObjC and t

Re: How to make Application bundle from Executable? (Mac)

2015-02-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 20 February 2015 at 06:19:29 UTC, Gan wrote: On Friday, 20 February 2015 at 06:10:51 UTC, Nicholas Wilson wrote: On Friday, 20 February 2015 at 03:26:47 UTC, Gan wrote: Also I can't get my application to load images that I place in the Resources folder(or any folder in the bundle for

Re: DMD Zip for Mac OS X

2015-02-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 28 February 2015 at 06:45:58 UTC, Mike Parker wrote: I'm not a Mac user and I'm fairly clueless about it. The DMD zip for OS X contains one executable. I assume it's a 64-bit binary. Is that true? Most likely a disk image (.dmg). (en.wikipedia.org/wiki/Apple_Disk_Image)

Re: Structs as template parameters: weird error message

2015-04-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 2 April 2015 at 23:12:25 UTC, biozic wrote: The code below doesn't compile. Why this error message? --- struct Item { int i; } struct Params { Item* item; this(int i) { item = new Item(i); // line 9 } } struct Foo(Params params) {} enum foo = Foo!(Params(

Re: Is it possible to add items to the arrays and hashes at compile time?

2015-06-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 7 June 2015 at 12:42:12 UTC, Nicholas Wilson wrote: On Sunday, 7 June 2015 at 12:30:12 UTC, Dennis Ritchie wrote: Does D the ability to add items to arrays and hashes at compile time? For example, how do I do it in compile time?: int[][int][int] hash; hash[4][6] ~= [34, 65]; hash[

Re: Is it possible to add items to the arrays and hashes at compile time?

2015-06-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 7 June 2015 at 12:30:12 UTC, Dennis Ritchie wrote: Does D the ability to add items to arrays and hashes at compile time? For example, how do I do it in compile time?: int[][int][int] hash; hash[4][6] ~= [34, 65]; hash[5][7] ~= [4, 78, 21]; try using a pure function + static e.g.

Re: compilation issues in a shared library project

2015-06-14 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 7 June 2015 at 00:38:17 UTC, Jonathan Villa wrote: module dt2.DataBlock; class DataBlock { public DataBlock * NextBlock; public DataBlock * PrevBlock; public string value; this() { NextBlock = null; PrevBlock =

aa.byKeyValue().sort!"a.key < b.key"

2015-06-27 Thread Nicholas Wilson via Digitalmars-d-learn
How do I iterate through an AA sorted by key? I am unable to .dup the aa.byKeyValue(). I have tried both foreach(e; aa.byKeyValue().sort!"a.key < b.key") { //... use e. key && e.value } and foreach(k,v; aa.byKeyValue().sort!"a.key < b.key") { } i get : template std.algorithm.sorting.sort

Re: aa.byKeyValue().sort!"a.key < b.key"

2015-06-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 27 June 2015 at 12:27:59 UTC, H. S. Teoh wrote: On Sat, Jun 27, 2015 at 12:22:06PM +, Nicholas Wilson via Digitalmars-d-learn wrote: How do I iterate through an AA sorted by key? I am unable to .dup the aa.byKeyValue(). Because it is a range, not an array. To turn it into

Re: Packing enums

2015-06-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 29 June 2015 at 22:05:47 UTC, qznc wrote: I stumbled upon this interesting programming challenge [0], which imho should be possible to implement in D. Maybe someone here wants to try. Task: Given two enums with less than 256 states, pack them into one byte and provide convenient ac

Re: Mutable reference to const objects

2015-07-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 1 July 2015 at 08:33:44 UTC, Yuxuan Shui wrote: On Wednesday, 1 July 2015 at 08:30:23 UTC, Yuxuan Shui wrote: How do I express a mutable reference to a const object in D? What I want to do is to define a variable, which refers a constant object, but I can change which constant ob

linking external libs

2015-07-02 Thread Nicholas Wilson via Digitalmars-d-learn
So test.d depends on libgmp.a Unsurprisingly: $dmd test.d fails to find libgmp.a So tell it to look $dmd -L-lgmp test.d finds the wrong one or doesn't find it. Tell it where to look $dmd -L-L/usr/local/lib -L-lgmp test.d Ok. Now it fails to find Phobos. Ok $dmd -L-L/usr/local/lib -L-L/us

Re: etc.c.zlib help

2015-07-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 2 July 2015 at 03:07:43 UTC, Matthew Gamble wrote: I am trying to make the transition from C++ to D. I've hit a snag with the etc.c.zlib module where any attempt to use this module to open a file yields an error: Error 42: Symbol Undefined __lseeki64. Here is a simple example of c

Re: linking external libs

2015-07-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 2 July 2015 at 12:19:06 UTC, Steven Schveighoffer wrote: On 7/2/15 8:10 AM, Nicholas Wilson wrote: [...] Try dmd -v, it will tell you the link line. Then you can try it yourself to see how to get it to work. I know dmd has problems with link line parameters, because it always pu

Re: How to setup GDC with Visual D?

2015-07-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 3 July 2015 at 23:45:15 UTC, Guy Gervais wrote: On Friday, 3 July 2015 at 19:17:28 UTC, Marko Grdinic wrote: Any advice regarding how I can get this to work? Thanks. I got GDC to work with VS2013 + VisualD by going into "Tools->Options" (The VS menu, not the one under "Visual D")

Re: Array operations with array of structs

2015-07-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote: Hi, I have a struct with arithmetic operations defined using opBinary but array operations with arrays of it don't work. struct Vector3 { public double[3] _p; ... Vector3 opBinary(string op)(in Vector3 rhs) const if (op == "+

Re: Array operations with array of structs

2015-07-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 6 July 2015 at 03:02:59 UTC, Nicholas Wilson wrote: On Monday, 6 July 2015 at 01:16:54 UTC, Peter wrote: Hi, I have a struct with arithmetic operations defined using opBinary but array operations with arrays of it don't work. struct Vector3 { public double[3] _p; ... Ve

Re: Comparison of struct with Nullable member

2015-07-17 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 17 July 2015 at 12:18:56 UTC, TC wrote: Hello, I came around a strange behavior and I'm not sure if it is a bug or feature. import std.typecons : Nullable; struct Foo { string bar; Nullable!int baz; } auto a = Foo("bb"); auto b = Foo("bb"); assert(a == b); This end

Re: String Metaprogramming

2015-07-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 18 July 2015 at 13:48:20 UTC, Clayton wrote: Am new to D programming, am considering it since it supports compile-time function execution . My challenge is how can I re-implement the function below so that it is fully executed in compile-time. The function should result to tabel1 b

Re: std.algorithm each documentation terse

2015-07-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 20 July 2015 at 14:59:21 UTC, John Colvin wrote: On Monday, 20 July 2015 at 14:40:59 UTC, jmh530 wrote: [...] Everything is exactly as I would expect. Lambdas with => are just shorthand that skips the return expression and std.algorithm.each just calls the lambda for each element

Re: Template-Parameterized Variadic isInstaceOf

2015-08-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 7 August 2015 at 11:45:22 UTC, Nordlöw wrote: To implement a new trait isSortedRange(R, pred) needed for SortedRange specializations I need a variant of enum bool isInstanceOf(alias S, T) = is(T == S!Args, Args...); that takes the `pred` argument aswell. But I have no cl

Re: Specify variable type for range of associative arrays.

2015-08-09 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 9 August 2015 at 01:29:16 UTC, Christopher Davies wrote: I'm just learning D. Something I often do in C# is have an IEnumerable (Range) of some type that is then conditionally filtered. It looks like this: IEnumerable> foo = bar; if (baz) { foo = foo.Where(d => d["key"] == valu

Re: SList container problem

2015-08-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 13 August 2015 at 08:40:13 UTC, ted wrote: have upgraded from 2.066.1 to 2.068.0, and have a change in behaviour: import std.container: SList; void main() { SList!int tmp; tmp.insertAfter( tmp[], 3 ); } used to work happily with dmd2.066.1, causes assert (core.excepti

Re: D Classes Passed By Reference or Value?

2015-08-16 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 16 August 2015 at 23:40:41 UTC, Brandon Ragland wrote: On Sunday, 16 August 2015 at 23:31:46 UTC, Ali Çehreli wrote: On 08/16/2015 04:13 PM, Brandon Ragland wrote: > That makes more sense. Though it does make the ref method > signature unclear, as it only applies to literals at this

Re: App Build Error

2015-08-16 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 16 August 2015 at 17:33:52 UTC, Benjamin wrote: I'm having an issue with building my app - even a simple trivial app (shown below). [...] OS X version? Have you configured your dmd.conf? iirc it requires linker path changes or something. Have you looked in /usr/local/lib for li

Re: Pointers to Dynamic Arrays

2015-08-16 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 17 August 2015 at 02:45:22 UTC, Brandon Ragland wrote: Howdy, Since Dynamic Arrays / Slices are a D feature, using pointers to these has me a bit confused... Consider: Now what is especially confusing about this, is that the above seems to works fine, while this does not: if(

Re: Empty struct, any runtime cost?

2015-08-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 19 August 2015 at 09:54:33 UTC, SimonN wrote: Hi, in a release-like build, I'm using the tharsis profiler, which is a frame-based profiler. Zone is a RAII struct that measures how long its own lifetime is. with (Zone(my_profiler, "zone name to appear in output")) {

Re: New to D - playing with Thread and false Sharing

2015-08-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 20 August 2015 at 20:01:58 UTC, tony288 wrote: On Thursday, 20 August 2015 at 15:37:35 UTC, Dejan Lekic wrote: [...] Thanks, I changed the code and the previous one was already using shared. import std.stdio; import core.time; import core.thread; [...] Keep in mind java may b

Re: Odd stacktrace: Access Violation in object.TypeInfo_Interface.getHash

2015-09-07 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 7 September 2015 at 08:55:31 UTC, Fra wrote: I encountered a runtime error in my code and all I can get (even in debug mode) is the following stacktrace: object.Error@(0): Access Violation 0x0051C308 in const(nothrow @trusted uint function(const(void*))) object.Type

Re: Massive linker error after upgrade to DMD 2.068.1-1

2015-09-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 12 September 2015 at 20:05:28 UTC, rcorre wrote: After upgrading from DMD 2.068.0-1 to DMD 2.068.1-1, my project began producing a large linker error (when built using dub). I was able to trace it down to a single line: target = target.adjacent(Diagonals.yes).randomSample(1).front

Re: Why is the constructor of B called?

2015-09-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 23 September 2015 at 21:25:15 UTC, tcak wrote: On Wednesday, 23 September 2015 at 21:14:17 UTC, Adam D. Ruppe wrote: On Wednesday, 23 September 2015 at 21:08:37 UTC, tcak wrote: I wouldn't expect B's constructor to be called at all unless "super" is used there. "If no call to co

Re: Why is the constructor of B called?

2015-09-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 24 September 2015 at 11:26:12 UTC, Marc Schütz wrote: On Thursday, 24 September 2015 at 01:01:09 UTC, Nicholas Wilson wrote: On Wednesday, 23 September 2015 at 21:25:15 UTC, tcak wrote: On Wednesday, 23 September 2015 at 21:14:17 UTC, Adam D. Ruppe wrote: [...] Is there any way

Re: I can't get passing an array by reference to work anymore...

2015-09-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 25 September 2015 at 02:37:22 UTC, TheGag96 wrote: So I'm just doing a small test program here: http://pastebin.com/UYf2n6bP (I'm making sure I know quicksort for my algorithms class, I know functionally this won't work as-is) I'm on Linux, 64-bit, DMD 2.068.1, and when I try to c

Re: Can I check if a value is convertible to a valid value of an enum?

2015-09-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 25 September 2015 at 03:12:20 UTC, French Football wrote: ...without having to loop over the enum? enum SomeType : string { CHEESE = "cheese", POTATO = "potato" } string valid_value = "cheese"; string invalid_value = "pizza"; bool test( string value ){ if( value.isConvertableToSo

Re: pi program

2015-09-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 25 September 2015 at 05:50:58 UTC, Charanjit Singh wrote: import std.stdio; import std.math; void main() { float sum,pi,t; int n=1; sum=0; while (n<100 ) { t=1/( n*n); n=n+1; sum=sum+t; } writeln("value of PI= " , (sum*6)^^.5); that is pi pr

enum to flags

2015-09-28 Thread Nicholas Wilson via Digitalmars-d-learn
so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? use like: enum blah { foo, bar, baz, } alias blahFlags = EnumToFlags!blah; static assert(blahFlags.baz == 1 << blah.baz)

Re: enum to flags

2015-09-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 06:08:03 UTC, Cauterite wrote: On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? You coul

Re: enum to flags

2015-09-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:18:52 UTC, John Colvin wrote: On Tuesday, 29 September 2015 at 03:31:44 UTC, Nicholas Wilson wrote: so I have a bunch of enums (0 .. n) that i also want to represent as flags ( 1 << n foreach n ). Is there anyway to do this other than a string mixin? use li

Re: std.Algebraic alias this

2015-10-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 5 October 2015 at 11:31:32 UTC, Radu wrote: There is a weird rule on how compiler treats alias this for the N and S types bellow. [...] Please file a bug report. Also do the errors change if you reverse the order in T i.e. alias T = Algebraic!(S,N); ?

Re: Check template parameter whether it has "length"

2015-10-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 8 October 2015 at 09:29:30 UTC, tcak wrote: I am "trying" to write a function that takes an array of items, and returns the length of longest item. [code] size_t maxLength(A)( const A[] listOfString ) if( __traits( hasMember, A, "length" ) ) { return 0; // not implemented

extract .manglof of template with lambda parameters

2016-07-23 Thread Nicholas Wilson via Digitalmars-d-learn
so I have a main as follows int main(string[] args) { int a = 3; map!((int x) => x*x)((GlobalPointer!int(&a)),a); return 0; } I want to get the mangleof of the generated call to map but without referencing it in the .o and then pass the mangleof to another function. the call to map

Re: extract .manglof of template with lambda parameters

2016-07-23 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 July 2016 at 06:03:59 UTC, Nicholas Wilson wrote: so I have a main as follows int main(string[] args) { int a = 3; map!((int x) => x*x)((GlobalPointer!int(&a)),a); return 0; } I want to get the mangleof of the generated call to map but without referencing it in the .o

Re: extract .manglof of template with lambda parameters

2016-07-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 24 July 2016 at 06:03:59 UTC, Nicholas Wilson wrote: so I have a main as follows int main(string[] args) { int a = 3; map!((int x) => x*x)((GlobalPointer!int(&a)),a); return 0; } I want to get the mangleof of the generated call to map but without referencing it in the .o

dub set default compiler for project

2016-07-25 Thread Nicholas Wilson via Digitalmars-d-learn
dub build has the --compiler= option. Is there any way to set it to default a custom version (own branch, resides in ../../ldcbuild/bin/ldc2 ) of ldc2 in the dub.json (or .sdl)? The project will only compile with that compiler.

Re: Template Inheritance

2016-07-31 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 31 July 2016 at 03:04:27 UTC, Gorge Jingale wrote: I like to build structures using template mixins because one can pick and choose functionality at compile time, but still have a relationship between different types. It would be really nice if one could sort of test if a template

Re: Replace (ie: substitute) a type in varadic args

2016-08-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 2 August 2016 at 08:22:15 UTC, Saurabh Das wrote: On Tuesday, 2 August 2016 at 08:20:22 UTC, Saurabh Das wrote: On Tuesday, 2 August 2016 at 08:16:48 UTC, Sean Campbell wrote: [...] Thanks. Yes that is one approach. I figured out another approach that seems decent: auto targetF

Re: Best way of checking for a templated function instantiation

2016-08-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 10 August 2016 at 12:36:14 UTC, Arafel wrote: Hi, I'm trying to check at compilation time if a given type implements some operator (let's assume it's '+' in this case), without caring about the type of the parameters it accepts. Since operator overloading is expressed in D throu

Re: Metaprogramming, generate argument list.

2016-08-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 22 August 2016 at 22:01:51 UTC, ciechowoj wrote: Is it possible to generate an argument list that contains pointers to local variables at compile time? For example, consider following code: template Repeat(alias int N, alias variable) { // Magic alias Repeat = /* Even more

Re: How to call a method of class D from function of C++ in DLL?

2016-08-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 27 August 2016 at 04:44:10 UTC, MGW wrote: Method which I use now: source D: - extern (C) { int on_metFromD(CEditWin* uk, int aa, int bb) { return (*uk).metFromD(int aa, int bb); } } class CEditWin { . . . // Method for to call int metFromD(int a

Re: How to call a method of class D from function of C++ in DLL?

2016-08-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 28 August 2016 at 08:20:52 UTC, MGW wrote: On Saturday, 27 August 2016 at 07:13:01 UTC, Nicholas Wilson wrote: easiest method would be to mark the D class extern(C++) noting that in C++ a D class reference becomes a pointer to the C++ class. In "the D class extern(C++)" do't work p

Re: Equivalent of FirstOrDefault with ranges

2016-09-02 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 2 September 2016 at 06:56:07 UTC, Lutger wrote: I was looking for something like FirstOrDefault* from .NET in phobos. For example, I have this piece of code: string findBobOrReturnNull(string[] names) { auto r = names.find("bob"); if(r.empty) return null; return r.front;

Re: Keen to learn D

2016-09-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 4 September 2016 at 20:12:09 UTC, Abhishek Mishra wrote: Hi! I am a newbie and I would like to know more about D language. I have prior knowledge of C++(12th Grade/ Pre-University College Level). How should I start? What more do I need to learn. Thanks in advance. :) in addition to

Re: Using OpenGL

2016-09-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 3 September 2016 at 17:13:49 UTC, Darren wrote: On Saturday, 3 September 2016 at 16:07:52 UTC, Mike Parker wrote: [...] The dynamic array! Thank you so much, I changed that on another file and it finally drew the triangle. And I ran your code and it works brilliantly. I shoul

Re: Binary heap: obtain a _reference_ to the front of the heap

2016-09-13 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen wrote: In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization) Thanks, Johan [1]

Re: construct range from tuple?

2016-09-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 18 September 2016 at 08:06:54 UTC, Lutger wrote: I have a tuple of strings generated at compile time, for example: alias names = AliasSeq!("Alice", "Bob"); How is it possible to construct a range of strings from this, in order to use it at runtime with other range algorithms? F

Re: D and math, can you isolate this ?

2016-09-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 20 September 2016 at 12:35:18 UTC, Basile B. wrote: I've recently started an easing/interpolation family of function in my D user library. It's based on something I know well since I've already used them in 2012 in a VST plugin called GrainPlot (RIP). However for one of the functi

Re: D and math, can you isolate this ?

2016-09-21 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 08:21:29 UTC, Basile B. wrote: On Wednesday, 21 September 2016 at 01:34:06 UTC, Nicholas Wilson wrote: On Tuesday, 20 September 2016 at 12:35:18 UTC, Basile B. wrote: [...] So if we rearrange and take the logs of both sides and divide by c we get 2*log(1-

Re: how to access struct member using [] operator?

2016-09-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 25 September 2016 at 04:54:31 UTC, grampus wrote: Dear all For example, I have a struct struct point{int x;int y} point a; Is there an easy way to access x and y by using a["x"] and a["y"] I guess I need to overload [], but can't figure out how. Someone can help? Thank you very m

Re: How to create dynamically sized objects

2016-09-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 29 September 2016 at 07:10:44 UTC, Straivers wrote: Hi, Say I wanted to create an object that has a string member, and I want the string to be allocated with the object contiguously instead of as a pointer to another location (as a constructor would do). For example: class C {

Re: Should I brush up on my C before plunging fully into D?

2016-10-15 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 15 October 2016 at 01:46:52 UTC, Chris Nelson wrote: I'm mainly a scripting language, .NET, and SQL programmer. I've been looking for a good programming language for Linux/BSD other than Python. I've surveyed the options and D appears to be a sane modern choice for me. (Thanks Ali

[vibe.d] showing images

2016-10-26 Thread Nicholas Wilson via Digitalmars-d-learn
doctype html html body -foreach(s; images) // it doesn't seem to like #{s} or !{s} img(src=s) -- shared static this() { auto router = new URLRouter; router.registerWebInterface(new CamController); auto settings = new HTTPServerSettings;

Re: [vibe.d] showing images

2016-10-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 12:57:24 UTC, wobbles wrote: On Wednesday, 26 October 2016 at 12:42:09 UTC, Nicholas Wilson wrote: [...] When you get the 404, do you see the contents of 'writeln(images);' in your terminal? yes. the 404 is only for the image the page still renders fine, bu

Re: [vibe.d] showing images

2016-10-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Wednesday, 26 October 2016 at 18:39:00 UTC, Rene Zwanenburg wrote: On Wednesday, 26 October 2016 at 12:42:09 UTC, Nicholas Wilson wrote: [...] You need to make the images accessible over HTTP. Note the use of staticFileServer in the following example: http://vibed.org/docs#http-routing

dub build --force but only for this package

2016-10-28 Thread Nicholas Wilson via Digitalmars-d-learn
So I'm trying to debug a project with the work flow of ssh into remote box edit/compile/run if it hangs yank the power out repeat this appears to corrupt the the last modification time to some time in the future and leads to the warning File '../.dub/packages/vibe-d-0.7.29/vibe-d

Re: system's "kill " signal

2016-11-04 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 5 November 2016 at 02:24:00 UTC, Konstantin Kutsevalov wrote: Hi, is there a way to catch system signal of "kill" command or "shutdown"? PS: are there some other ways also to send signals to running a D application? have a look in std.process I don't think you can catch kill.

Re: typeof(SortedRange) and is operator

2016-11-08 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 8 November 2016 at 13:22:35 UTC, RazvanN wrote: Sorry, I accidentally posted the above message and I don't know how to erase it. You can't, this is a mailing list not a forum. The following post is the complete one: Given the following code: int[] arr = [1, 2, 9, 4, 10, 6]; auto

Re: what is mean? ( Offset 78887H Record Type 00C3)

2016-11-18 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 19 November 2016 at 06:54:37 UTC, xky wrote: hello. i got a problem when i build my source code(windows7 x64 / DMD32 D Compiler v2.072.0), here: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-201

Re: How to declare function with the same call signature as another?

2016-11-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 20 November 2016 at 11:19:24 UTC, Tofu Ninja wrote: I feel like this should be simple but I can't seem to figure it out. How do I declare a function to have the same call signature as another function/callable type? Like if I have: alias Sig = int function(int x, int y); How do I

Re: How to declare function with the same call signature as another?

2016-11-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 20 November 2016 at 11:19:24 UTC, Tofu Ninja wrote: I feel like this should be simple but I can't seem to figure it out. How do I declare a function to have the same call signature as another function/callable type? Like if I have: alias Sig = int function(int x, int y); How do I

Re: Memory allocation failed. Why?

2016-11-20 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote: On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote: [...] For me there's no exception. Maybe the GC is poluted. Try to add this after each iteration in the first test loop: import core.memory: GC; GC.collect()

Re: Get return type of a template function without instantiating it

2016-11-22 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 22 November 2016 at 12:21:18 UTC, Yuxuan Shui wrote: Is there a way to get a template function return type with instantiating it? The return type is independent of the template arguments. I'm asking because there's potentially recursive template instantiation if I do try to instan

mixin templates as ailas paramters

2016-11-24 Thread Nicholas Wilson via Digitalmars-d-learn
Is there any reason why mixin template Foo(T) { } Struct Bar(ailas a) { mixin a!int } doesn't work? It gives an error saying that mixin templates are not normal templates. I hacked around this by making Bar take an enumeration and then "static switch"ing on it to select the correct mixin

Re: mixin templates as ailas paramters

2016-11-24 Thread Nicholas Wilson via Digitalmars-d-learn
On Friday, 25 November 2016 at 01:08:38 UTC, ketmar wrote: On Friday, 25 November 2016 at 00:43:25 UTC, Nicholas Wilson wrote: works like a charm: mixin template Foo(T) { int z = 42; } auto Bar(alias a) () { mixin a!int; return z; } void main () { writeln(Bar!Foo); } Hmm, maybe i

Re: Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ?

2016-11-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 06:01:13 UTC, Tofu Ninja wrote: Basically the title says it all. alias A = AliasSeq!(...); alias B = AliasSeq!(...); static assert(A.length == B.length); template T(An, Bn){ ... } alias C = AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])); // how to make this :/ How

Re: Given two AliasSeq (A and B) and template T, how to make AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])) ?

2016-11-26 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 06:01:13 UTC, Tofu Ninja wrote: Basically the title says it all. alias A = AliasSeq!(...); alias B = AliasSeq!(...); static assert(A.length == B.length); template T(An, Bn){ ... } alias C = AliasSeq!(T!(A[0], B[0]) ... T!(A[n], B[n])); // how to make this :/ How

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 11:49:25 UTC, Suliman wrote: On Sunday, 27 November 2016 at 11:21:58 UTC, drug007 wrote: On 27.11.2016 14:07, Suliman wrote: I am getting deprecation message: "Using the result of a comma expression is deprecated" on this code: string sqlinsert = (`INSERT INTO

Re: Creating array of structs being used in C interface

2016-11-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 12:59:32 UTC, Timoses wrote: Hi there, I've got a problem interfacing to a C library. The following structs are used by the library's .d file that I've written. struct neo4j_map_entry_t { neo4j_value_t key; neo4j_value_t value; }; s

Re: Creating array of structs being used in C interface

2016-11-27 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 27 November 2016 at 13:54:54 UTC, Adam D. Ruppe wrote: On Sunday, 27 November 2016 at 12:59:32 UTC, Timoses wrote: [...] It is a linker problem because you didn't link to it... D structs have an initializer, even if they are used for interfacing with C. This is a small blob of dat

Re: Use class template as a type

2016-11-28 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 28 November 2016 at 11:26:41 UTC, dm wrote: Hi. Is it possible to write in D something like this? ``` abstract class MyClass(T) { public: @property const(T) value(){return _value;} @property void value(T val){_value = val;} ... private: T _value; ... } ... class MyClassFl

Re: How can I concatenate a string, a char array and an int

2016-11-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 29 November 2016 at 10:21:24 UTC, Anders S wrote: Hi guys, just started to get into Dlang, comming from C and C++ I like to use methods like there if possible. Now I want to catenate something like this, but don't get it to work in standard C i code: char str[80]; sprintf(

Re: Cannot implicitly convert expression (&sbuf) of type char [1024] to IOREQ *

2016-11-29 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 29 November 2016 at 23:33:19 UTC, Ali Çehreli wrote: On 11/29/2016 07:30 AM, Anders S wrote: > INTargv[1];/* list of arguments */ Speculation, but given that you say "list of args" is it possible OP means to use int[0] for an inline array. In addition to what Ne

Re: how to catch D Throwables (or exceptions) from C++?

2016-11-30 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 December 2016 at 01:58:13 UTC, Timothee Cour wrote: eg: ``` dlib.d: extern(C) void dfun(){assert(0, "some_msg");} clib.cpp: extern "C" void dfun(); void fun(){ try{ dfun(); } catch(...){ // works but how do i get "some_msg" thrown from D? } } ``` portably not su

Re: The module 'foo' is already defined in 'libmylib.so'

2016-12-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 December 2016 at 22:05:06 UTC, Timothee Cour wrote: I want to update a library with new symbols (ie partial recompilation): libmylib.so : compiled from bar.d and foo.d now update the file foo.d dmd -c -fPIC foo.d -offoo.o clang++ -o libmylib_update.so foo.o -shared -Wl,-lmylib

Re: Two part question. Making a dynamic array of delegates, and taking in a delegate with unknown parameters as an argument .

2016-12-01 Thread Nicholas Wilson via Digitalmars-d-learn
On Thursday, 1 December 2016 at 23:51:19 UTC, Payotz wrote: So, to give context, I am trying to make an event manager for a game I'm making. I was writing the "register()" method so I ran into a problem. The register method will take in delegates as an argument, but those delegates have varied

Re: Returning structs from COM

2016-12-03 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 3 December 2016 at 09:51:00 UTC, John C wrote: Some DirectX methods return structs by value, but when I try calling them I either get garbage or an access violation. [...] I know for ldc that function that return struct by value actually return by a hidden return parameter point

Re: Set Intersection of SortedRanges

2016-12-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 5 December 2016 at 22:10:34 UTC, Nordlöw wrote: On Monday, 5 December 2016 at 21:48:49 UTC, Nordlöw wrote: Ahh, setops has intersection aswell: https://dlang.org/phobos/std_algorithm_setops.html#setIntersection I should have a guessed that. Ahh again, but current Phobos is current

Re: Set Intersection of SortedRanges

2016-12-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 6 December 2016 at 01:46:38 UTC, Nicholas Wilson wrote: On Monday, 5 December 2016 at 22:10:34 UTC, Nordlöw wrote: On Monday, 5 December 2016 at 21:48:49 UTC, Nordlöw wrote: Ahh, setops has intersection aswell: https://dlang.org/phobos/std_algorithm_setops.html#setIntersection I s

Re: Set Intersection of SortedRanges

2016-12-05 Thread Nicholas Wilson via Digitalmars-d-learn
Whoops forgot to add checks for .empty on the ranges, and I don't think reduce!equal work but you get the point.

Re: [Semi-OT] I don't want to leave this language!

2016-12-05 Thread Nicholas Wilson via Digitalmars-d-learn
On Monday, 5 December 2016 at 20:49:50 UTC, e-y-e wrote: On Monday, 5 December 2016 at 20:25:00 UTC, Ilya Yaroshenko wrote: [...] You know from the 15th December I will have a month of free time, and I would love to get myself up to speed with Mir to contribute to it. If you don't mind me sa

Re: Separate IP parts

2016-12-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Saturday, 10 December 2016 at 13:21:40 UTC, notna wrote: On Saturday, 10 December 2016 at 08:03:00 UTC, biozic wrote: [...] Well, you know, that's one of the not so great things about Dlang... you cannot even trust the provided examples, if there are any: [...] Those statements ne

Re: faster "stringification"

2016-12-10 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 11 December 2016 at 02:09:41 UTC, Orut wrote: D nub here. I have a Python script that I'd like to implement in D. For certain parts, the D equivalent was slower than Python's. For example, Python code: #dummy code s = ["abc", "fjkd", "L", "qwa", "r", "uw", "tiro", "bc", "sg", "k",

<    1   2   3   4   5   6   7   >