Re: with (auto p = new ...)
aOn Tuesday, 23 September 2014 at 15:19:59 UTC, Andre wrote: Hi, I just wonder why with (auto p = new ...) is not working. It would be some syntax sugar in this scenario: with (auto p = new Panel()) { parent = this; text = bla; with (auto b = new Button()) { parent = p; // Here p is needed text = bla2; } } source\app.d(8): Error: expression expected, not 'auto' source\app.d(8): Error: found 'p' when expecting ')' source\app.d(8): Error: found '=' instead of statement ... Kind regards see more example http://techgurulab.com/course/java-quiz-online/ see more example http://techgurulab.com/course/java-quiz-online/e example
Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together
On Wednesday, 24 September 2014 at 03:08:55 UTC, csmith wrote: Hi everyone, I've got derelict.opengl3.gl3 and derelict.glfw3.glfw3 setup with dub and can get a window to open up and close with glfw3. I can also use glClear(GL_COLOR_BUFFER_BIT); however, beyond this most OpenGL commands fail and I can't seem to figure out how to fix it. Code: import std.stdio; import derelict.opengl3.gl3, derelict.glfw3.glfw3; void main(string args[]) { DerelictGL3.load(); // Loads OpenGL v1.0 and v1.1 DerelictGLFW3.load(); // Loads GLFW3 assert (glfwInit(), Failed to initialize GLFW3); scope (exit) glfwTerminate(); glfwSetErrorCallback(error_callback); auto window = glfwCreateWindow(640, 480, Simple see more example http://techgurulab.com/course/java-quiz-online/ example, null, null); assert (window !is null); glfwMakeContextCurrent(window); auto vers = DerelictGL3.reload(); // Created GLFW3 context, so GL3 needs to be reloaded while (!glfwWindowShouldClose(window)) { if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS) glfwSetWindowShouldClose(window, GL_TRUE); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POINTS); glEnd(); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); } extern (C) void error_callback(int error, const(char)* description) nothrow { printf(%s %s, error, description); } Compiler Output: derelict-util: [derelict-util] derelict-util: [derelict-util] derelict-glfw3: [derelict-glfw3, derelict-util] derelict-util: [derelict-util] derelict-gl3: [derelict-gl3, derelict-util] myproj: [myproj, derelict-util, derelict-glfw3, derelict-util, derelict-gl3, derelict-util] Target is up to date. Using existing build in /home/csmith/.dub/packages/derelict-util-1.0.2/.dub/build/library-debug-linux.posix-x86_64-dmd-A741715720F146208FFF241F87E468DD/. Use --force to force a rebuild. Target is up to date. Using existing build in /home/csmith/.dub/packages/derelict-glfw3-1.0.2/.dub/build/library-debug-linux.posix-x86_64-dmd-DD1819CE8266F370192AAD3190CA5B06/. Use --force to force a rebuild. Target is up to date. Using existing build in /home/csmith/.dub/packages/derelict-gl3-1.0.6/.dub/build/library-debug-linux.posix-x86_64-dmd-59B635D839F3A8CFC2737986D4B622FD/. Use --force to force a rebuild. Building myproj configuration application, build type debug. Compiling... source/app.d(25): Error: undefined identifier glBegin source/app.d(26): Error: undefined identifier glEnd FAIL .dub/build/application-debug-linux.posix-x86_64-dmd-357CCD4CB91CACEC384AF7BAA514E3A7 myproj executable Error executing command run: DMD compile run failed with exit code 1 Any ideas? Thanks, Charles
Re: How to export a deduced template type to the enclosing scope?
On Tuesday, 23 September 2014 at 22:09:11 UTC, Ali Çehreli wrote: I think similar questions were asked by others in different contexts before. I played with core.thread.Fibre a little bit. As others have done a number of times before, I tried to make the following syntax possible inside fiber code: yield(42); I wonder whether there is a clever trick to pull out a deduced type from a template. I don't think it is possible, because there may be many instantiations of the template and it would not be clear which one to pull out. (I don't think there is any way of getting all of the instantiations of a template because the compiler has only a partial view of the program at a time.) However, what if there is exactly one instantiation allowed? struct S(alias Func) { /* This template mixin will instantiate the yield(T) template. */ mixin Func!(); see more example http://techgurulab.com/course/java-quiz-online/ void yield(T)(T) { /* As expected and demonstrated by the following pragma, in * this case T happens to be 'double'. Assuming that Func is * not allowed to call yield() with more than one type, can we * pull the actual type of T out into S's scope? */ alias YieldedT = T; pragma(msg, YieldedT);/* Prints 'double'. */ } /* QUESTION: Can we know the type for the single instantiation of * yield(T) here? */ YieldedT data;/* What is YieldedT? */ } mixin template MyFunc() { void foo() { double d; yield(d);/* -- The single instantiation */ } } void main() { auto s = S!MyFunc(); s.foo(); } So near and yet so far... :) Ali
Re: Does remove immutability using cast to pass in a function make sense?
On Tuesday, 23 September 2014 at 02:07:09 UTC, AsmMan wrote: I have this array: static immutable string[] months = [jan, fev, ...]; I need to pass it into canFind(). But it doesn't works with immutables so I need to cast it like in canFind(cast(string[]) months, month) to work. There's a reason related to design why it doesn't work with immutables or a function just wasn't written? What I want to know is if I'm doing something wrong in casting it to work. I know from C which such casts should be done carefully see more example http://techgurulab.com/course/java-quiz-online/
Re: New changes to DDOC where is the u tag coming from in parent classes?
On Tuesday, 23 September 2014 at 07:26:06 UTC, Gary Willoughby wrote: On Monday, 22 September 2014 at 20:44:25 UTC, Gary Willoughby wrote: Below is a change that results from re-generating my documentation using ddoc. I wonder where the new u tags are coming from that wrap the parent class name. -div class=module-membersh2a name=Button/aclass span class=symbolButton/span: tkd.widget.textwidget.TextWidget; +div class=module-membersh2a name=Button/aclass span class=symbolButton/span: utkd.widget.textwidget.TextWidget/u; Has there been a new ddoc symbol defined and not mentioned in: http://dlang.org/ddoc.html I've redefined most of these in my own .ddoc file and can't seem to get rid of the new tag. Is there a master ddoc file being read from somewhere? Any help? This has started to occur with the latest compiler release. see mora example http://techgurulab.com/course/java-quiz-online/
Re: New changes to DDOC where is the u tag coming from in parent classes?
On Monday, 22 September 2014 at 20:44:25 UTC, Gary Willoughby wrote: Below is a change that results from re-generating my documentation using ddoc. I wonder where the new u tags are coming from that wrap the parent class name. -div class=module-membersh2a name=Button/aclass span class=symbolButton/span: tkd.widget.textwidget.TextWidget; +div class=module-membersh2a name=Button/aclass span class=symbolButton/span: utkd.widget.textwidget.TextWidget/u; Has there been a new ddoc symbol defined and not mentioned in: http://dlang.org/ddoc.html I've redefined most of these in my own .ddoc file and can't seem to get rid of the new tag. Is there a master ddoc file being read from somewhere? Any help? see more example http://techgurulab.com/course/java-quiz-online/
Re: can't understand why code do not working
On Monday, 22 September 2014 at 19:36:39 UTC, Suliman wrote: Already 1 hour I am looking at example from http://ddili.org/ders/d.en/concurrency.html and my modification of it, and can't understand what's difference? Why it's output only: 1 3 and then do not do nothing! import std.stdio; import std.concurrency; import core.thread; void main() { Tid wk = spawn(worker); foreach(v; 1..5) { wk.send(v); int result = receiveOnly!int(); writeln(result); } } see more example http://techgurulab.com/course/java-quiz-online/ void worker() { int value = 0; value = receiveOnly!int(); writeln(value); int result = value * 3; ownerTid.send(result); } see more example http://techgurulab.com/course/java-quiz-online/
Re: Can't get Visual D to come up. No warnings, no errors, no nothing
On Monday, 22 September 2014 at 03:21:44 UTC, WhatMeWorry wrote: Anybody installed Visual D recently? As per the install instructions, I downloaded the Visual Studio isolated Shell 2013 and its integrated package. Everything went smoothly. I then downloaded Visual D and installed it with no problems. However, when I try to run the vdserver.exe application, nothing happens? Am I missing something obvious? see more example http://techgurulab.com/course/java-quiz-online/
Re: Segfault in DMD OSX
On Monday, 22 September 2014 at 16:36:03 UTC, Etienne wrote: I'm having issues with DMD returning exit code -11 rather than compiling my project. I have no idea how to debug this, I'm using Mac OS X 10.9.4 with latest git DMD tagged 2.066, and this project: https://github.com/etcimon/event.d When I hit `dub run`, I get the exit code. Not sure why or where the problem comes from, I can't get GDB to run on the mac (something about Mach task port error in gdb), and dmd DEBUG gives no additional info. Any ideas? see more example http://techgurulab.com/course/java-quiz-online/
Re: Cannot deduce from type
On Monday, 22 September 2014 at 14:45:31 UTC, Chris wrote: Why is that? import std.stdio, std.array void main() { auto output = appender!(string); output ~= world!; // output.data.insertInPlace(0, Hello, ); // Doesn't work auto asString = output.data; asString.insertInPlace(0, Hello, ); // Works writeln(asString); // prints Hello, world! } Error: template std.array.insertInPlace cannot deduce function from argument types !()(string, int, string), candidates are: .dvm/compilers/dmd-2.066.0/linux/bin/../../src/phobos/std/array.d(1031): std.array.insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff) if (!isSomeString!(T[]) allSatisfy!(isInputRangeOrConvertible!T, U) U.length 0) .dvm/compilers/dmd-2.066.0/linux/bin/../../src/phobos/std/array.d(1097): std.array.insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff) if (isSomeString!(T[]) allSatisfy!(isCharOrStringOrDcharRange, U)) see ore example ://techgurulab.com/course/java-quiz-online/ore example
Re: parallel foreach hangs
On Monday, 22 September 2014 at 11:25:53 UTC, Daniel Kozak wrote: this code never end import std.stdio; import std.file; import std.parallelism : parallel; import std.algorithm : filter; void main(string[] args) { foreach(d; parallel(args[1 .. $], 1)) { auto phpFiles = filter!`endsWith(a.name,.php)`(dirEntries(d,SpanMode.depth)); writeln(phpFiles); } } see more example http://techgurulab.com/course/java-quiz-online/
Re: how to create and compile reesources for dmd 64
`On Friday, 19 September 2014 at 22:20:59 UTC, Cassio Butrico wrote: Hello everyone, When I create and compile resouces to 32 works perfect, but when I try to compilat of 64 error LNK1136: invalid or corrupt file. I do not know if it has to do with comverter COFF to OMF. can someone give me a light? Thank you for your attention. see more example http://techgurulab.com/course/java-quiz-online/
Re: put string[] into a appender without loop?
On Sunday, 21 September 2014 at 23:41:58 UTC, AsmMan wrote: I'd like to copy an array string into a appender!string() but I can't see how to do this without loop myself over the string array. Is there a native function or should I write it myself? see more example http://techgurulab.com/course/java-quiz-online/
Re: How does GC.addRange work?
On Saturday, 20 September 2014 at 20:14:36 UTC, Gary Willoughby wrote: How does GC.addRange work? i.e. what is it doing? I'm assuming reading the docs that it adds a range for the GC to scan but what actually happens? Does the GC look into this range and check for the existence of pointers it's currently managing? For example, if i nulled a pointer in the range i added would that trigger the GC to collect that resource on the next sweep? (assuming it was the last reference.) see more example http://techgurulab.com/course/java-quiz-online/
Re: Unicode arithmetic at run-time
On Sunday, 21 September 2014 at 03:00:34 UTC, Charles McAnany wrote: Friends, I note that there are playing cards in unicode: http://en.wikipedia.org/wiki/Playing_cards_in_Unicode They follow a nice pattern, so I can quickly convert from a rank and suit to the appropriate escape sequence in D. I'd like to automate this, but I can't seem to do arithmetic on unicode characters as I could in ascii. writefln(%c, '/U0001F0A1'); //works fine, ace of spades. Backslash replaced with / for displayability. //So logically, this would be the two of spades: writefln(%c, '/U0001F0A1'+1); // std.format.FormatException@format.d(1325): integral Would this be solvable with a mixin (return //U1F0A ~ rank;), or are escape sequences impossible to generate after the source has been lexed by dmd? I looked in std.uni and std.utf, but they don't seem to want to generate a unicode character from an int, they're more concerned about switching between encodings. Cheers, Charles. see more example http://techgurulab.com/course/java-quiz-online/
Re: Cannot deduce from type
On Monday, 22 September 2014 at 14:45:31 UTC, Chris wrote: Why is that? import std.stdio, std.array void main() { auto output = appender!(string); output ~= world!; // output.data.insertInPlace(0, Hello, ); // Doesn't work auto asString = output.data; asString.insertInPlace(0, Hello, ); // Works writeln(asString); // prints Hello, world! } Error: template std.array.insertInPlace cannot deduce function from argument types !()(string, int, string), candidates are: .dvm/compilers/dmd-2.066.0/linux/bin/../../src/phobos/std/array.d(1031): std.array.insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff) if (!isSomeString!(T[]) allSatisfy!(isInputRangeOrConvertible!T, U) U.length 0) .dvm/compilers/dmd-2.066.0/linux/bin/../../src/phobos/std/array.d(1097): std.array.insertInPlace(T, U...)(ref T[] array, size_t pos, U stuff) if (isSomeString!(T[]) allSatisfy!(isCharOrStringOrDcharRange, U)) see more example http://techgurulab.com/course/java-quiz-online/
isCallable is not an expression
Hi, following code throws an error when I uncomment method getPropertyDuplicate. getPropertyDuplicate is just a copy of getProperty except the method name. Why these errors are thrown? C:\D\dmd2\windows\bin\..\..\src\phobos\std\traits.d(1257): Error: isCallable!(ge tPropertyDuplicate) is not an expression source\app.d(25):while looking for match for functionAttributes!(getProp ertyDuplicate) C:\D\dmd2\windows\bin\..\..\src\phobos\std\traits.d(1257): Error: template insta nce std.traits.isCallable!(getPropertyDuplicate) error instantiating source\app.d(11):instantiated from here: functionAttributes!(getProperty Duplicate) source\app.d(11):while looking for match for functionAttributes!(getProp ertyDuplicate) Kind regards André template MyTemplate() { import std.traits : isSomeFunction, functionAttributes, FunctionAttribute, ReturnType; string[] getPropertyNames() { string[] result; foreach(m;__traits(allMembers, typeof(this))) { static if (isSomeFunction!(__traits(getMember, typeof(this), m)) functionAttributes!(__traits(getMember, typeof(this), m)) FunctionAttribute.property) { result ~= m; } } return result; } /*string[] getPropertyDuplicate() { string[] result; foreach(m;__traits(allMembers, typeof(this))) { static if (isSomeFunction!(__traits(getMember, typeof(this), m)) functionAttributes!(__traits(getMember, typeof(this), m)) FunctionAttribute.property) { result ~= m; } } return result; }*/ } class A { mixin MyTemplate; } void main() { auto a = new A(); }
Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together
Make sure to call DerelictGL3.reload() to get all the OpenGL calls, if you don't, you only get OpenGL 1.1
Remove filename from path
What is the best way to remove file name from full path? string path = thisExePath()
Re: Remove filename from path
On Wednesday, 24 September 2014 at 10:11:04 UTC, Suliman wrote: What is the best way to remove file name from full path? string path = thisExePath() Seems like dirName in std.path is a good candidate ;) http://dlang.org/phobos/std_path.html#.dirName You'll find many other path manipulation functions there.
Re: Remove filename from path
string path = thisExePath() Seems like dirName in std.path is a good candidate ;) http://dlang.org/phobos/std_path.html#.dirName You'll find many other path manipulation functions there. Thanks! But if I want to strip it, how I can cut it?
Re: Remove filename from path
I can't understand how to use strip? For example I would like to cut just extension. path = path.stripRight(exe); Error: no overload matches for stripRight(C)(C[] str) if
Recursive function call
string getFileName() { //чтобы было проще обрабатываемый файл будем хранить рядом с бинариком string filename = chomp(readln()); string path = getcwd(); writeln((path ~ \\ ~ filename)); if (exists(path ~ \\ ~ filename)) return (path ~ \\ ~ filename); else { writeln(File do not exists. Please try again); getFilename(); //I need something similar, to call function again. } } In case of error, how I can call function getFileName again?
Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together
On 9/24/2014 12:08 PM, csmith wrote: Hi everyone, Compiling... source/app.d(25): Error: undefined identifier glBegin source/app.d(26): Error: undefined identifier glEnd FAIL .dub/build/application-debug-linux.posix-x86_64-dmd-357CCD4CB91CACEC384AF7BAA514E3A7 myproj executable Error executing command run: DMD compile run failed with exit code 1 Any ideas? You're using deprecated OpenGL calls. The gl3 module only declares and loads modern OpenGL. If you really want to use the deprecated stuff, change the gl3 import to this: import derelict.opengl3.gl; And call load/reload on the DerelictGL instance rather than DerelictGL3. All of the modern stuff will still be available. --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com
Re: Remove filename from path
On Wed, 24 Sep 2014 10:35:28 + Suliman via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I can't understand how to use strip? For example I would like to cut just extension. std.path.setExtension is your friend. signature.asc Description: PGP signature
Re: Remove filename from path
On Wednesday, 24 September 2014 at 10:35:29 UTC, Suliman wrote: I can't understand how to use strip? For example I would like to cut just extension. path = path.stripRight(exe); Error: no overload matches for stripRight(C)(C[] str) if stripExtension would be your friend here. If you want the extension, then extension. As a general rule, everything you need to manipulate paths and filenames is in std.path: http://dlang.org/phobos/std_path.html
Re: Recursive function call
How about using a loop? string getFileName() { while(true) { string filename = chomp(readln()); string path = getcwd(); writeln((path ~ \\ ~ filename)); if (exists(path ~ \\ ~ filename)) return (path ~ \\ ~ filename); writeln(File do not exists. Please try again); } }
Re: Remove filename from path
On Wednesday, 24 September 2014 at 10:35:29 UTC, Suliman wrote: I can't understand how to use strip? For example I would like to cut just extension. path = path.stripRight(exe); Error: no overload matches for stripRight(C)(C[] str) if strip doens't work that way. It simply removes leading/trailing white. There's a version in std.algorithm which is more generic, but it accepts either a predicate, or an element, but not a range. Unfortunately, there is no generic function that allows striping of a specific ending range (though there are ways to either detect it, or strip it from the end). If you want something generic, then: string path = myFile.doc; string extension = .doc; if (path.endsWith(extension)) path = path[0 .. $ - extension.length]; Would work.
Re: Remove filename from path
On Wed, 24 Sep 2014 12:21:40 + monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Unfortunately, there is no generic function that allows striping of a specific ending range but for strings we have std.string.chomp. signature.asc Description: PGP signature
Re: Recursive function call
On Wednesday, 24 September 2014 at 10:57:27 UTC, Suliman wrote: string getFileName() { //чтобы было проще обрабатываемый файл будем хранить рядом с бинариком string filename = chomp(readln()); string path = getcwd(); writeln((path ~ \\ ~ filename)); if (exists(path ~ \\ ~ filename)) return (path ~ \\ ~ filename); Don't do `path ~ \\ ~ filename`. Instead, use std.path.buildPath. It's more portable, faster, and convenient. Also, you should store the result in a named variable, or you'll reallocate a new string everytime. else { writeln(File do not exists. Please try again); getFilename(); //I need something similar, to call function again. } } In case of error, how I can call function getFileName again? Any kind of looping control structure would work. I'd advocate the while(1) loop with a break or return: while(1) { string filename = chomp(readln()); string path = getcwd(); string fullPath = buildPath(path, filename); if (exists(fullPath)) return fullPath; writeln(File does not exists. Please try again); }
Re: Recursive function call
On Wednesday, 24 September 2014 at 10:57:27 UTC, Suliman wrote: string getFileName() { [...] getFilename(); //I need something similar, to call function again. You mistyped the function name, it's getFileName (capital N), and you forgot return. So: return getFileName();
Re: Remove filename from path
On Wednesday, 24 September 2014 at 12:29:09 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 24 Sep 2014 12:21:40 + monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Unfortunately, there is no generic function that allows striping of a specific ending range but for strings we have std.string.chomp. I missread that documentation. I thought it removed all characters that can also be found in delim. Power to me.
Re: Remove filename from path
On Wed, 24 Sep 2014 12:39:01 + monarch_dodra via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: I missread that documentation. I thought it removed all characters that can also be found in delim. Power to me. ah, i just found this function (really, less than hour ago), that's why i still remember where it is and what it's doing. ;-) signature.asc Description: PGP signature
Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together
On Wednesday, 24 September 2014 at 11:07:56 UTC, Mike Parker wrote: You're using deprecated OpenGL calls. The gl3 module only declares and loads modern OpenGL. If you really want to use the deprecated stuff, change the gl3 import to this: import derelict.opengl3.gl; And call load/reload on the DerelictGL instance rather than DerelictGL3. All of the modern stuff will still be available. Thanks for this. Was using GLFW's example trying to troubleshoot it. Wasn't really considering them using the outdated functions. I guess I'll look for a different tutorial elsewhere. Also, thanks for making it in the first place!
Re: with (auto p = new ...)
Enhancement 13526 filed: https://issues.dlang.org/show_bug.cgi?id=13526
Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together
Whoops, I just saw that my earlier answer was totally inaccurate. I was on my phone at the time, so didn't look at the code in detail. On Wednesday, 24 September 2014 at 13:59:41 UTC, csmith wrote: On Wednesday, 24 September 2014 at 11:07:56 UTC, Mike Parker wrote: You're using deprecated OpenGL calls. The gl3 module only declares and loads modern OpenGL. If you really want to use the deprecated stuff, change the gl3 import to this: import derelict.opengl3.gl; And call load/reload on the DerelictGL instance rather than DerelictGL3. All of the modern stuff will still be available. Thanks for this. Was using GLFW's example trying to troubleshoot it. Wasn't really considering them using the outdated functions. I guess I'll look for a different tutorial elsewhere. Also, thanks for making it in the first place! Yes, ##opengl on freenode has good tutorials and examples in the topic. If you've been reading NeHe, drop it. NeHe is severely out of date and anyone still recommending it probably don't know what they're talking about. Here's some links: http://www.arcsynthesis.org/gltut/ https://github.com/progschj/OpenGL-Examples https://github.com/g-truc/ogl-samples Note that modern OpenGL is a bit more involved to get something on the screen. You'll be writing a lot more boilerplate in the beginning, but a lot of the modern features are definitely worth it.
Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together
Whoops, I just saw that my earlier answer was totally inaccurate. I was on my phone at the time, so didn't look at the code in detail. No big deal, figured you just missed it / auto response to this kinda question. I did my best to google this question, but wasn't really sure where to begin. Yes, ##opengl on freenode has good tutorials and examples in the topic. If you've been reading NeHe, drop it. NeHe is severely out of date and anyone still recommending it probably don't know what they're talking about. Here's some links: http://www.arcsynthesis.org/gltut/ https://github.com/progschj/OpenGL-Examples https://github.com/g-truc/ogl-samples Exactly the kinda thing I was looking for. Thanks for the heads up about NeHe. Note that modern OpenGL is a bit more involved to get something on the screen. You'll be writing a lot more boilerplate in the beginning, but a lot of the modern features are definitely worth it. I came from web development, you're meaning to tell me there's coding outside of writing boilerplate? Jokes aside, figured if I took the time to learn a modern language, I'd be consistent with adding in newer technologies :)
Re: Remove filename from path
On 09/24/2014 05:21 AM, monarch_dodra wrote: On Wednesday, 24 September 2014 at 10:35:29 UTC, Suliman wrote: I can't understand how to use strip? For example I would like to cut just extension. path = path.stripRight(exe); Error: no overload matches for stripRight(C)(C[] str) if strip doens't work that way. It simply removes leading/trailing white. There's a version in std.algorithm which is more generic, but it accepts either a predicate, or an element, but not a range. Unfortunately, there is no generic function that allows striping of a specific ending range (though there are ways to either detect it, or strip it from the end). If you want something generic, then: string path = myFile.doc; string extension = .doc; if (path.endsWith(extension)) path = path[0 .. $ - extension.length]; Would work. find() and friends can be used: import std.algorithm; void main() { string path = myFile.doc; string extension = .doc; path = findSplitBefore(path, extension)[0]; assert(path == myFile); } And three retro()s make one modern(): :p import std.algorithm; import std.range; void main() { string path = myFile.doc; string extension = .doc; path = findSplitAfter(path.retro, extension.retro) [1].retro; assert(path == myFile); } Ali
Re: isCallable is not an expression
On 09/24/2014 01:11 AM, andre wrote: static if (isSomeFunction!(__traits(getMember, typeof(this), m)) Submitted the following bug report: https://issues.dlang.org/show_bug.cgi?id=13528 import std.traits; mixin template MyTemplate() { void foo() { pragma(msg, __traits(getMember, typeof(this), foo)); } } class A { mixin MyTemplate; } void main() { auto a = new A(); } Error: Internal Compiler Error: CTFE DotType: this.A while evaluating pragma(msg, __traits(getMember, A, foo)) Ali
Re: Trying to get Derelict.opengl3.gl3 and derelict.glfw3.glfw3 to work together
On Wednesday, 24 September 2014 at 16:36:29 UTC, csmith wrote: I came from web development, you're meaning to tell me there's coding outside of writing boilerplate? Jokes aside, figured if I took the time to learn a modern language, I'd be consistent with adding in newer technologies :) In that case, here's some two things on the way that may not be all that intuitive for a web developer when it comes to dealing with OpenGL, as they are quirks stemming mostly from how C works: 1. When you need to pass an array of some sort to an OpenGL function, remember to use foo.ptr, not foo. foo.ptr will get you a pointer to an array that the rest of the world, not just D, understands. 2. The OpenGL spec mandates that empty error logs for shader compilation are to report length 0, but if you ask on an nvidia machine about the length of its empty error log, it will reply with length 1. This is because nvidia just send the length of the string in all cases, which for empty C strings is 1 due to the null-byte. I hope this helps you along, good luck!
Re: isCallable is not an expression
On 09/24/2014 01:11 AM, andre wrote: template MyTemplate() { import std.traits : isSomeFunction, functionAttributes, FunctionAttribute, ReturnType; string[] getPropertyNames() 1) You need a this template parameter: string[] getPropertyNames(this MyType)() 2) Now, replace all typeof(this) expressions with MyType below. /*string[] getPropertyDuplicate() 3) Same here: string[] getPropertyDuplicate(this MyType)() And it works! :) class A { mixin MyTemplate; @property int zzz() { return 42; } } void main() { auto a = new A(); import std.string; assert(a.getPropertyNames() == [ zzz ]); assert(a.getPropertyDuplicate() == [ zzz ]); } Ali
Re: with (auto p = new ...)
On Wed, 24 Sep 2014 14:39:25 + Andre via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Enhancement 13526 filed: https://issues.dlang.org/show_bug.cgi?id=13526 i wrote a quickhack-patch for this ER. as it's my first patch that goes outside parser it needs to be reviewed by someone who knows compiler internals. ah, and we need grammar fixes for it too, but it's completely out of my scope now. signature.asc Description: PGP signature
Does D has C#'s string.Empty?
Does D has C#'s string.Empty?