Re: Higher-order functions?
Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And call it with: IO.writeLine(add: .. someprocedure(2, 3, { a, b = a + b })) IO.writeLine(multiply: .. someprocedure(2, 3, { a, b = a * b })) (Read the = as gives) Is it possible to have this? Thanks, Xan On Wednesday, 11 April 2012 at 00:03:05 UTC, Timon Gehr wrote: On 04/11/2012 01:13 AM, Jonas H. wrote: Hi everyone, does D have any runtime higher-order function facilities? D has full runtime support for higher-order functions and closures. import std.stdio; int[] map(scope int delegate(int) f, int[] a){ auto b = new int[a.length]; foreach(i,x;a) b[i] = f(x); return b; } void main(){ int a = 2; writeln(map(x=a*x, [1,2,3])); } (I'm not talking about templates.) You will often use templates together with runtime higher order functions. Eg: import std.stdio; T[] map(T,S)(scope T delegate(S) f, S[] a){ auto b = new T[a.length]; foreach(i,x;a) b[i] = f(x); return b; } void main(){ int a = 2; writeln(map((int x)=a*x, [1,2,3])); writeln(map((double x)=a*x, [1.6,2.7,3.8])); } For function literals that contain more than one statement, there is an alternate syntax: auto dg = (int a, double b){a*=b; return a+b;} You can explicitly specify 'function' or 'delegate': auto fp = function (int x) = 2*x; // not a closure, simple function pointer (uses less space, but is less powerful) int a = 2; auto dg = delegate (int x) = a*x; // closure, can refer to a You can leave out argument types when they can be directly deduced from the context. Finally, if the literal has an explicit 'function' or 'delegate' it is possible to explicitly specify the return type: auto dg = delegate int(int x) = x; More specifically, is something like this possible? (That's how I'd do it in Python) car_prices = map(Car.get_price, list_of_cars) car = new Car foobar(car.get_price) Thanks Jonas (Well, the standard way to do what that python code does is using templates. auto car_prices = map!(car = car.get_price)(list_of_cars);// lazy range auto car_prices = array(map!(car = car.get_price(list_of_cars)); // eager array)
Re: Higher-order functions?
On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And call it with: IO.writeLine(add: .. someprocedure(2, 3, { a, b = a + b })) IO.writeLine(multiply: .. someprocedure(2, 3, { a, b = a * b })) (Read the = as gives) Is it possible to have this? If I understand the above code correctly: import std.stdio; int someprocedure (int a, int b, int delegate (int, int) f) { return f(a, b); } void main () { writeln(add: , someprocedure(2, 3, (a, b) = a + b)); writeln(multiply: , someprocedure(2, 3, (a, b) = a * b)); } -- /Jacob Carlborg
Re: Higher-order functions?
On Wednesday, 11 April 2012 at 09:17:12 UTC, Jacob Carlborg wrote: On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And call it with: IO.writeLine(add: .. someprocedure(2, 3, { a, b = a + b })) IO.writeLine(multiply: .. someprocedure(2, 3, { a, b = a * b })) (Read the = as gives) Is it possible to have this? If I understand the above code correctly: import std.stdio; int someprocedure (int a, int b, int delegate (int, int) f) { return f(a, b); } Yes, you undertood correcty. Your code gives me an error: $ gdmd-4.6 funcions.d funcions.d:10: expression expected, not '' funcions.d:10: found 'a' when expecting ',' funcions.d:11: expression expected, not '' funcions.d:11: found 'a' when expecting ',' void main () { writeln(add: , someprocedure(2, 3, (a, b) = a + b)); writeln(multiply: , someprocedure(2, 3, (a, b) = a * b)); }
Re: Higher-order functions?
On 04/11/2012 11:37 AM, Xan wrote: On Wednesday, 11 April 2012 at 09:17:12 UTC, Jacob Carlborg wrote: On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And call it with: IO.writeLine(add: .. someprocedure(2, 3, { a, b = a + b })) IO.writeLine(multiply: .. someprocedure(2, 3, { a, b = a * b })) (Read the = as gives) Is it possible to have this? If I understand the above code correctly: import std.stdio; int someprocedure (int a, int b, int delegate (int, int) f) { return f(a, b); } Yes, you undertood correcty. Your code gives me an error: $ gdmd-4.6 funcions.d funcions.d:10: expression expected, not '' funcions.d:10: found 'a' when expecting ',' funcions.d:11: expression expected, not '' funcions.d:11: found 'a' when expecting ',' void main () { writeln(add: , someprocedure(2, 3, (a, b) = a + b)); writeln(multiply: , someprocedure(2, 3, (a, b) = a * b)); } AFAIK GDC does not yet support the new lambda literal syntax. You can use void main () { writeln(add: , someprocedure(2, 3, (a, b) { return a + b; })); writeln(multiply: , someprocedure(2, 3, (a, b) { return a * b; })); }
Re: Higher-order functions?
On Wednesday, 11 April 2012 at 09:43:27 UTC, Timon Gehr wrote: On 04/11/2012 11:37 AM, Xan wrote: On Wednesday, 11 April 2012 at 09:17:12 UTC, Jacob Carlborg wrote: On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And call it with: IO.writeLine(add: .. someprocedure(2, 3, { a, b = a + b })) IO.writeLine(multiply: .. someprocedure(2, 3, { a, b = a * b })) (Read the = as gives) Is it possible to have this? If I understand the above code correctly: import std.stdio; int someprocedure (int a, int b, int delegate (int, int) f) { return f(a, b); } Yes, you undertood correcty. Your code gives me an error: $ gdmd-4.6 funcions.d funcions.d:10: expression expected, not '' funcions.d:10: found 'a' when expecting ',' funcions.d:11: expression expected, not '' funcions.d:11: found 'a' when expecting ',' void main () { writeln(add: , someprocedure(2, 3, (a, b) = a + b)); writeln(multiply: , someprocedure(2, 3, (a, b) = a * b)); } AFAIK GDC does not yet support the new lambda literal syntax. You can use void main () { writeln(add: , someprocedure(2, 3, (a, b) { return a + b; })); writeln(multiply: , someprocedure(2, 3, (a, b) { return a * b; })); } Better but with error ;-) $ gdmd-4.6 func2.d func2.d:10: Error: undefined identifier a func2.d:10: Error: undefined identifier b func2.d:10: Error: function func2.someprocedure (int a, int b, int delegate(int, int) f) is not callable using argument types (int,int,_error_ delegate(_error_, _error_)) func2.d:10: Error: cannot implicitly convert expression (__dgliteral1) of type _error_ delegate(_error_, _error_) to int delegate(int, int) With: import std.stdio; int someprocedure (int a, int b, int delegate (int, int) f) { return f(a, b); } void main () { writeln(add: , someprocedure(2, 3, (a, b) { return a + b; } )); writeln(multiply: , someprocedure(2, 3, (a, b) { return a * b; } )); } What is the error?
Re: Higher-order functions?
What is the error? e.g. try this: auto someprocedure (int a, int b, int delegate (int, int) f)
Re: Higher-order functions?
On Wednesday, 11 April 2012 at 10:14:21 UTC, Mirko Pilger wrote: What is the error? e.g. try this: auto someprocedure (int a, int b, int delegate (int, int) f) I receive the same error
Re: Higher-order functions?
On 04/11/2012 11:51 AM, Xan wrote: On Wednesday, 11 April 2012 at 09:43:27 UTC, Timon Gehr wrote: On 04/11/2012 11:37 AM, Xan wrote: On Wednesday, 11 April 2012 at 09:17:12 UTC, Jacob Carlborg wrote: On 2012-04-11 10:45, Xan wrote: Good answer. For the other hand, what is the simplest method for implementing this (in pseucode) in D: Sure: FUNC someprocedure(int a, int b, funcint, int: int f) int RETURN f(a, b) } And call it with: IO.writeLine(add: .. someprocedure(2, 3, { a, b = a + b })) IO.writeLine(multiply: .. someprocedure(2, 3, { a, b = a * b })) (Read the = as gives) Is it possible to have this? If I understand the above code correctly: import std.stdio; int someprocedure (int a, int b, int delegate (int, int) f) { return f(a, b); } Yes, you undertood correcty. Your code gives me an error: $ gdmd-4.6 funcions.d funcions.d:10: expression expected, not '' funcions.d:10: found 'a' when expecting ',' funcions.d:11: expression expected, not '' funcions.d:11: found 'a' when expecting ',' void main () { writeln(add: , someprocedure(2, 3, (a, b) = a + b)); writeln(multiply: , someprocedure(2, 3, (a, b) = a * b)); } AFAIK GDC does not yet support the new lambda literal syntax. You can use void main () { writeln(add: , someprocedure(2, 3, (a, b) { return a + b; })); writeln(multiply: , someprocedure(2, 3, (a, b) { return a * b; })); } Better but with error ;-) $ gdmd-4.6 func2.d func2.d:10: Error: undefined identifier a func2.d:10: Error: undefined identifier b func2.d:10: Error: function func2.someprocedure (int a, int b, int delegate(int, int) f) is not callable using argument types (int,int,_error_ delegate(_error_, _error_)) func2.d:10: Error: cannot implicitly convert expression (__dgliteral1) of type _error_ delegate(_error_, _error_) to int delegate(int, int) With: import std.stdio; int someprocedure (int a, int b, int delegate (int, int) f) { return f(a, b); } void main () { writeln(add: , someprocedure(2, 3, (a, b) { return a + b; } )); writeln(multiply: , someprocedure(2, 3, (a, b) { return a * b; } )); } What is the error? Apparently your compiler does not support parameter type deduction yet. void main () { writeln(add: , someprocedure(2, 3, (int a, int b) { return a + b; })); writeln(multiply: , someprocedure(2, 3, (int a, int b) { return a * b; })); }
Re: Higher-order functions?
Apparently your compiler does not support parameter type deduction yet. void main () { writeln(add: , someprocedure(2, 3, (int a, int b) { return a + b; })); writeln(multiply: , someprocedure(2, 3, (int a, int b) { return a * b; })); } Yes, now it works! Thanks,
Passing function as values and returning functions
Hi, Following the thread of Higher-order functions, how can I do to pass a function as a parameter and return a function. That is a something like: import std.functional, std.stdio; int f (int a) { return 2*a; } int delegate (int) g(int function(int a) p) { return p; } void main() { writeln(g(f)(1)); } but it gives me: $ gdmd-4.6 functions.d functions.d:8: Error: cannot implicitly convert expression (p) of type int function(int a) to int delegate(int) functions.d:13: Error: function functions.f (int a) is not callable using argument types () functions.d:13: Error: expected 1 function arguments, not 0 functions.d:13: Error: function functions.g (int function(int a) p) is not callable using argument types (int) functions.d:13: Error: cannot implicitly convert expression (f()) of type int to int function(int a) Thanks, Xan.
Re: Passing function as values and returning functions
On 2012-04-11 13:10, Xan wrote: Hi, Following the thread of Higher-order functions, how can I do to pass a function as a parameter and return a function. That is a something like: import std.functional, std.stdio; int f (int a) { return 2*a; } int delegate (int) g(int function(int a) p) { return p; } void main() { writeln(g(f)(1)); } but it gives me: $ gdmd-4.6 functions.d functions.d:8: Error: cannot implicitly convert expression (p) of type int function(int a) to int delegate(int) functions.d:13: Error: function functions.f (int a) is not callable using argument types () functions.d:13: Error: expected 1 function arguments, not 0 functions.d:13: Error: function functions.g (int function(int a) p) is not callable using argument types (int) functions.d:13: Error: cannot implicitly convert expression (f()) of type int to int function(int a) Use delegate or function both for the argument type and return type. -- /Jacob Carlborg
Re: Passing function as values and returning functions
On Wednesday, 11 April 2012 at 11:59:14 UTC, Jacob Carlborg wrote: On 2012-04-11 13:10, Xan wrote: Hi, Following the thread of Higher-order functions, how can I do to pass a function as a parameter and return a function. That is a something like: import std.functional, std.stdio; int f (int a) { return 2*a; } int delegate (int) g(int function(int a) p) { return p; } void main() { writeln(g(f)(1)); } but it gives me: $ gdmd-4.6 functions.d functions.d:8: Error: cannot implicitly convert expression (p) of type int function(int a) to int delegate(int) functions.d:13: Error: function functions.f (int a) is not callable using argument types () functions.d:13: Error: expected 1 function arguments, not 0 functions.d:13: Error: function functions.g (int function(int a) p) is not callable using argument types (int) functions.d:13: Error: cannot implicitly convert expression (f()) of type int to int function(int a) Use delegate or function both for the argument type and return type. How to do that?
Re: Passing function as values and returning functions
On Wed, 11 Apr 2012 08:08:44 -0400, Xan xancor...@gmail.com wrote: On Wednesday, 11 April 2012 at 11:59:14 UTC, Jacob Carlborg wrote: Use delegate or function both for the argument type and return type. How to do that? int function(int) g(int function(int a) p) { return p; } Should do the trick. delegates are not implicitly convertible to/from function pointers. You can, however, explicitly convert a function to a delegate. But this should be done only when there is a requirement to use delegates. However, use std.functional.toDelegate if you are interested. -Steve
stdout redirect
How can I redirect stdout / stderr to file (from D not shell)?
Re: Passing function as values and returning functions
On Wednesday, 11 April 2012 at 12:19:06 UTC, Steven Schveighoffer wrote: On Wed, 11 Apr 2012 08:08:44 -0400, Xan xancor...@gmail.com wrote: On Wednesday, 11 April 2012 at 11:59:14 UTC, Jacob Carlborg wrote: Use delegate or function both for the argument type and return type. How to do that? int function(int) g(int function(int a) p) { return p; } Should do the trick. delegates are not implicitly convertible to/from function pointers. You can, however, explicitly convert a function to a delegate. But this should be done only when there is a requirement to use delegates. However, use std.functional.toDelegate if you are interested. -Steve Thanks, Steve, but another problem: $ gdmd-4.6 functions.d functions.d:13: Error: function functions.f (int a) is not callable using argument types () functions.d:13: Error: expected 1 function arguments, not 0 functions.d:13: Error: function functions.g (int function(int) p) is not callable using argument types (int) functions.d:13: Error: cannot implicitly convert expression (f()) of type int to int function(int) import std.functional, std.stdio; int f (int a) { |___return 2*a; } int function(int) g(int function(int a) p) { |___return p; } void main() { |___writeln(g(f)(1)); } I want to g return f and then f evaluate 1.
Re: Passing function as values and returning functions
On Wed, 11 Apr 2012 08:53:00 -0400, Xan xancor...@gmail.com wrote: Thanks, Steve, but another problem: [snip] void main() { |___writeln(g(f)(1)); } writeln(g(f)(1)); Unlike C, you *must* take the address of a function symbol to get a function pointer. -Steve
Re: stdout redirect
On Wednesday, 11 April 2012 at 12:46:30 UTC, Andrea Fontana wrote: How can I redirect stdout / stderr to file (from D not shell)? Self-reply: It works using std.c way: import std.cstream; std.c.stdio.freopen(args[4].ptr, w+, dout.file); std.c.stdio.freopen(args[4].ptr, w+, derr.file);
Re: D Dll injection problem
I went ahead and went back to as far as 2.045 and I still couldn't get a working dll. This would suggest something is wrong with my dll injection code but I've tested with a few other random dll's and that appears to work. according to my debugger the problem is an access violation while executing the main function of the D dll. the code I use for injecting is /** * injectDLL injects a dll in a given process using the CreateRemoteThread function. * * arguments: * HANDLE proc = A HANDLE to the process * string dllName = A string containting the name of the dll **/ void injectDLL(HANDLE proc,string dllName) { //first we need to get a pointer to the loadlibrary function LPVOID LoadLibAddy = cast(LPVOID)GetProcAddress(GetModuleHandle(kernel32.dll), LoadLibraryA); //The problem is that we need to pass an argument(string) but that string is in our memory space //so we have to allocate space to write our dllName to using writeprocessmemory LPVOID RemoteString = VirtualAllocEx(proc,null,dllName.length,MEM_COMMIT | MEM_RESERVE,PAGE_READWRITE); //write the dllName WriteProcessMemory(proc,RemoteString,toStringz(dllName),dllName.length,null); //create a thread in the remote process loading the dll CreateRemoteThread(proc, null, 0, cast(LPTHREAD_START_ROUTINE)LoadLibAddy, cast(LPVOID)RemoteString, 0, null); } Op 28 maart 2012 13:13 schreef Trass3r u...@known.com het volgende: this works on every dll I try to inject apart from dll's written in D (starting with dmd version 2,054 or something like that). If this is a regression, please narrow it down to the exact version.
Re: D Dll injection problem
On Wednesday, 11 April 2012 at 13:26:23 UTC, maarten van damme wrote: I went ahead and went back to as far as 2.045 and I still couldn't get a working dll. This would suggest something is wrong with my dll injection code but I've tested with a few other random dll's and that appears to work. according to my debugger the problem is an access violation while executing the main function of the D dll. How do you initialize runtime and GC?
Re: D Dll injection problem
On Wednesday, 11 April 2012 at 13:26:23 UTC, maarten van damme wrote: the code I use for injecting is /** * injectDLL injects a dll in a given process using the CreateRemoteThread function. * * arguments: * HANDLE proc = A HANDLE to the process * string dllName = A string containting the name of the dll **/ void injectDLL(HANDLE proc,string dllName) { //first we need to get a pointer to the loadlibrary function LPVOID LoadLibAddy = cast(LPVOID)GetProcAddress(GetModuleHandle(kernel32.dll), LoadLibraryA); //The problem is that we need to pass an argument(string) but that string is in our memory space //so we have to allocate space to write our dllName to using writeprocessmemory LPVOID RemoteString = VirtualAllocEx(proc,null,dllName.length,MEM_COMMIT | MEM_RESERVE,PAGE_READWRITE); //write the dllName WriteProcessMemory(proc,RemoteString,toStringz(dllName),dllName.length,null); //create a thread in the remote process loading the dll CreateRemoteThread(proc, null, 0, cast(LPTHREAD_START_ROUTINE)LoadLibAddy, cast(LPVOID)RemoteString, 0, null); } Try to run a simple C program like --- #include windows.h void main() { LoadLibraryA(mydll.dll); } --- And check whether it fails and how.
Re: stdout redirect
On Wednesday, 11 April 2012 at 13:00:45 UTC, Andrea Fontana wrote: On Wednesday, 11 April 2012 at 12:46:30 UTC, Andrea Fontana wrote: How can I redirect stdout / stderr to file (from D not shell)? Self-reply: It works using std.c way: import std.cstream; std.c.stdio.freopen(args[4].ptr, w+, dout.file); std.c.stdio.freopen(args[4].ptr, w+, derr.file); Careful: D strings are not zero-terminated. args[4].toStringz() is the safer choice. Cheers, Stefan
Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.
On Tuesday, 10 April 2012 at 22:31:44 UTC, Andrej Mitrovic wrote: On 4/10/12, vmars316 vmars...@live.com wrote: On Tuesday, 10 April 2012 at 20:07:41 UTC, Andrej Mitrovic You can use the zip download: https://github.com/Rayerd/dfl/zipball/master A couple years ago i learned HotBasic. An awesome language. (www.vmars316.com has some freeware programs, with source.) Quick to write, and tiny executables. But no workem on MAC. No HotBasic GUI, so I built my own blockStyle GUI. This year I started on a DIY EECP (external heart pump), which led me to Arduino, for which I have to learn C. Also. This year i decided to leard a language that IS crossplatform, like D. So I Bought the D book. I used to program on IBM mainframes. I am a retired senior citizen. My vocation became my vacation. :) But this GitHub seems to be a horrendous chore. It looks like at least a weeks worth of asking questions. Is there any way of downloading an already built DFL_LIB DFL_IMPORT Or if git is the only way to build these, is there a portable version available. Thanks...Vernon
Re: Higher-order functions?
Wow, thanks for all the answers! Seems to be a great community here. What do you guys think about adding the term anonymous functions to the frontpage and features page? I think that one's a lot more comman than delegates (even if it's not exactly the same thing).
Re: Higher-order functions?
On Wed, Apr 11, 2012 at 07:29:20PM +0200, Jonas H. wrote: Wow, thanks for all the answers! Seems to be a great community here. Welcome to the community! :-) What do you guys think about adding the term anonymous functions to the frontpage and features page? I think that one's a lot more comman than delegates (even if it's not exactly the same thing). Keep in mind that there are two kinds of function here, one is function which is just like a C function pointer (cannot access variables in its containing lexical scope), the other is delegate, which is a fat function pointer (has access to variables in containing scope). Furthermore, there's a distinction between the function pointers/delegates themselves vs. function literals (i.e., the syntax of writing (int x) = (x^^2)), which is probably what you mean by anonymous functions here. T -- One disk to rule them all, One disk to find them. One disk to bring them all and in the darkness grind them. In the Land of Redmond where the shadows lie. -- The Silicon Valley Tarot
Re: Passing function as values and returning functions
On Wednesday, 11 April 2012 at 13:04:01 UTC, Steven Schveighoffer wrote: On Wed, 11 Apr 2012 08:53:00 -0400, Xan xancor...@gmail.com wrote: Thanks, Steve, but another problem: [snip] void main() { |___writeln(g(f)(1)); } writeln(g(f)(1)); Unlike C, you *must* take the address of a function symbol to get a function pointer. -Steve Yes, it works, finally. Thanks, Steve. Xan.
Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.
On Tuesday, 10 April 2012 at 22:31:44 UTC, Andrej Mitrovic wrote: You can use the zip download: https://github.com/Rayerd/dfl/zipball/master ...ok, i downloaded PortableGit-1.7.10-preview20120409.7z and i put it here: C:\D\dmd2\windows\Dfl\import\dfl\win32\dflexe I am not sure if i need GTK (for D DFL and Entice), but i put it here: C:\D\dmd2\windows\Dfl\import\dfl\gtk\dfl and i ran the following: Start configuring git with your personal settings: git config --global user.name ... git config --global user.name ... and ran git --help How do I build the dfl.lib (DFL_LIB DFL_IMPORT), and whatever else i need to run D DFL and Entice ? Thanks..vm
Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.
On 4/11/12, vmars316 vmars...@live.com wrote: How do I build the dfl.lib (DFL_LIB DFL_IMPORT), Didn't you get this message: msysgit: $ git clone https://github.com/Rayerd/dfl.git cmd.exe (set these paths to where DM and DMD are installed) $ set dmc_path=C:\dm $ set dmd_path=C:\DMD\dmd2 $ cd dfl\win32\dfl $ makelib.bat Wait for it to build, then: $ set dfl_lib=%cd%\dfl.lib $ cd.. $ set dfl_import=%cd% $ cd ../.. $ mkdir testdfl $ cd testdfl Copy this example to a test.d file: http://wiki.dprogramming.com/Dfl/Tutorial2 And then run: $ dmd test.d -I%dfl_import% %dfl_lib% $ test.exe Ultimately you would use the dfl_import and dfl_lib variables in a build script of some sort, maybe a batch file. E.g. if you've cloned the DFL repository to C:\git\dfl you could use this build.bat batch file: @echo off setlocal EnableDelayedExpansion set DFL_LIB=C:\git\dfl\win32\dfl\dfl.lib set DFL_IMPORT=C:\git\dfl\win32 dmd -I%DFL_IMPORT% %DFL_LIB% test.d and this would build test.d to test.exe.
Name of files causes error. Why?
Hi, With helloworld program named with score or underscore, I receive the following __annoying__ error: $ gdmd-4.6 hola-temp.d hola-temp.d: Error: module hola-temp has non-identifier characters in filename, use module declaration instead Why? Can someone fix it. It's really annoying Thanks in advance, Xan.
Re: Name of files causes error. Why?
On 4/11/12, Xan xancor...@gmail.com wrote: With helloworld program named with score or underscore, I receive the following __annoying__ error: Underscores should work fine (and they do for me). Scores (or dashes) can't work because an indentifier with a dash is not a valid identifier, so a module declaration can't have dashes, and hence d files can't have them either.
Re: Name of files causes error. Why?
On Wed, 11 Apr 2012 15:33:56 -0400, Xan xancor...@gmail.com wrote: Hi, With helloworld program named with score or underscore, I receive the following __annoying__ error: $ gdmd-4.6 hola-temp.d hola-temp.d: Error: module hola-temp has non-identifier characters in filename, use module declaration instead Why? Can someone fix it. It's really annoying Thanks in advance, Xan. All d module files (i.e. d source files) must be a valid identifier. See this document for what an identifier can contain: http://dlang.org/lex.html#Identifier Now, you *can* possibly name the module differently using a module statement, but this is highly discouraged. If you do this, the only way another module can import your differently-named module is if you pass the file on the command line. -Steve
Re: Multiple %s format specifiers with a single argument
* Mike Parker aldac...@gmail.com [2012-04-10 18:46:42 +0900]: On 4/10/2012 3:43 AM, Ali Çehreli wrote: On 04/09/2012 10:35 AM, Andrej Mitrovic wrote: On 4/9/12, Jonathan M Davisjmdavisp...@gmx.com wrote: Posix positional arguments seem to work for writefln but not format for whatever reason. Report it as a bug. Thanks, http://d.puremagic.com/issues/show_bug.cgi?id=7877 Thanks. I hadn't seen this branch of the thread before sending my response. Some newsgroup software break threads into multiple branches. Could be my Thunderbird... (?) Ali It's not Thunderbird. IIRC it's an issue with some users posting via the email interface. Its less using the email interface, and more people using braindead email clients. Gmail and Mutt (the two I use most) seem to handle replying well, setting the correct headers to indicate things. But I've seen some odd postings from people posting using things like Windows Live Mail. And it seems that Outlook Express is better at mailing lists than Outlook, which is strange... -- James Miller
Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.
On Wednesday, 11 April 2012 at 18:39:40 UTC, Andrej Mitrovic wrote: On 4/11/12, vmars316 vmars...@live.com wrote: Didn't you get this message: Andrej, Yes, I got it. But lost track of it, sorry. Anyways, yahoo, I am almost there. I now have a dfl.lib . I ran following (~myForm-compile-2.bat) : echo Compile myForm.d setlocal EnableDelayedExpansion set DFL_LIB=C:\D\dmd2\windows\Dfl\import\dfl\win32\dfl\dfl.lib set DFL_IMPORT=C:\D\dmd2\windows\Dfl\import\dfl\win32\ dmd -I %DFL_IMPORT% %DFL_LIB% myForm.d And these are the results: C:\D\dmd2\windows\Entice\vmPrograms\myFormecho Compile myForm.d Compile myForm.d C:\D\dmd2\windows\Entice\vmPrograms\myFormsetlocal EnableDelayedExpansion C:\D\dmd2\windows\Entice\vmPrograms\myFormset DFL_LIB=C:\D\dmd2\windows\Dfl\import\dfl\win32\dfl\dfl.lib C:\D\dmd2\windows\Entice\vmPrograms\myFormset DFL_IMPORT=C:\D\dmd2\windows\Dfl\import\dfl\win32\ C:\D\dmd2\windows\Entice\vmPrograms\myFormdmd -I C:\D\dmd2\windows\Dfl\import\dfl\win32\ C:\D\dmd2\windows\Dfl\import\dfl\win32\dfl\dfl.lib myForm.d Error: invalid file name 'C:\D\dmd2\windows\Dfl\import\dfl\win32\' What is looking for? *import* something? Thanks...vm
Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.
On 4/12/12, vmars316 vmars...@live.com wrote: What is looking for? *import* something? Remove the space between '-I' and the import path.