Re: Input from a newbie
On Monday, 9 April 2012 at 20:18:29 UTC, Ali Çehreli wrote: The GCC C compiler proves you wrong :) They have warnings. I guess it's a hack (because printf really doesn't belong into the compiler) but that doesn't matter. What matters is user-friendliness. Indeed. dmd should warn about any incompatible data passed as variadic parameters. It's simple to decide: only fundamental types that correspond to C counterparts should be allowed. Hmmm... Even that's not that simple: int is 32 bits in D but unspecified in C. Maybe printf should not be visible at all - or under a different name (cprintf or something similar). It's just too tempting... C variadic arguments are one of the most unsafe features of the C language. A total mess. Stefan
Re: Multiple %s format specifiers with a single argument
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.
Re: Latest versions of Entice Designer and DFL?
Greetings, I went to a second computer, and reDownloded Installed D/Dfl/Entice: dinstaller.exe , dfl098-installer.exe , entice08502.exe The following are A few more things that confuses and frustrates us newbies. 1) dinstall.exe creates 'C:\D\dmd2\'. 2) But Dfl-installer(dfl098.exe) looks for this 'C:\D\dmd\' and wont install without it. At least is said so. I don't know if dfl installed or not. Confusing. 3) Entice-installer(entice08502) installs here == C:\Program Files (x86)\Entice Trial and error, isn't my favorite MO. BTW: How can I see if things are installed correctly. I can edit myForm.d (from Entice Tutorial) with Entice, but can't yet compile. I am having trouble with the Compile Command. Entice keeps asking me for 'Compile Commands'. I tried a whole bunch of dmd.exe 'Keyword Options' like 'dmd.exe -D -quiet -Dddocdir -H', and even just 'dmd.exe' . But the best I could squeeze out of it was a list of Keyword Options. Can anyone help me with this? This is my fourth day of trying to get D/Dfl/Entice working correctly. Thanks...vm
Re: Latest versions of Entice Designer and DFL?
I have been up all nite,trying to figure this out (6:21am). Well, I have gotten this far with compile myForm.d . C:\D\dmd2\windows\vmPrograms\myFormcall dmd.exe C:\D\dmd2\windows\vmPrograms\my Form\myForm.d -D -quiet -Dddocdir -H C:\D\dmd2\windows\vmPrograms\myForm\myForm.d(1): Error: module all is in file 'dfl\all.d' which cannot be read import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import Press any key to continue . . . I have searched my entire computer, but there is no file named: dfl.all . There is an all.d , but i think it is saying above, that all.d is corrupt. Can anyone help me compile this puppy? Here is the code: import dfl.all; int main() { Form myForm; Label myLabel; myForm = new Form; myForm.text = DFL Example; myLabel = new Label; myLabel.font = new Font(Verdana, 14f); myLabel.text = Hello, DFL World!; myLabel.location = Point(15, 15); myLabel.autoSize = true; myLabel.parent = myForm; Application.run(myForm); return 0; } Thanks...vm
Re: Latest versions of Entice Designer and DFL?
I have been up all nite,trying to figure this out (6:21am). Well, I have gotten this far with compile myForm.d . C:\D\dmd2\windows\vmPrograms\myFormcall dmd.exe C:\D\dmd2\windows\vmPrograms\my Form\myForm.d -D -quiet -Dddocdir -H C:\D\dmd2\windows\vmPrograms\myForm\myForm.d(1): Error: module all is in file 'dfl\all.d' which cannot be read import path[0] = C:\D\dmd2\windows\bin\..\..\src\phobos import path[1] = C:\D\dmd2\windows\bin\..\..\src\druntime\import Press any key to continue . . . I have searched my entire computer, but there is no file named: dfl.all . There is an all.d , but i think it is saying above, that all.d is corrupt. Can anyone help me compile this puppy? Here is the code: import dfl.all; int main() { Form myForm; Label myLabel; myForm = new Form; myForm.text = DFL Example; myLabel = new Label; myLabel.font = new Font(Verdana, 14f); myLabel.text = Hello, DFL World!; myLabel.location = Point(15, 15); myLabel.autoSize = true; myLabel.parent = myForm; Application.run(myForm); return 0; } Thanks...vm
Re: Multiple %s format specifiers with a single argument
On 09/04/2012 18:35, 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 Andrej, are emails from Bugzilla not getting through to you? And Jonathan, you ought to know that you already submitted one of the duplicate bug reports about this. You shouldn't submit bug reports without searching first anyway. Always include resolved bugs in the search - the bug you're about to report might have been fixed ready for the next release, and duplicates already in the system help to catch different ways of phrasing the same statement, among other things. Stewart.
Re: Multiple %s format specifiers with a single argument
On 4/10/12, Stewart Gordon smjg_1...@yahoo.com wrote: Andrej, are emails from Bugzilla not getting through to you? I'm not getting any emails. Bugzilla stopped emailing me for quite a while now, I don't know why (except the monthly password reminder). The emails page has all the ticks set except this row: The issue is in the UNCONFIRMED state . I've clicked the Enable All Email button just now and it unselected all ticks from the row The change was made by me , but I don't think that was causing bugzilla to stop mailing me. On 4/10/12, Stewart Gordon smjg_1...@yahoo.com wrote: You shouldn't submit bug reports without searching first anyway. I did, but the default search box doesn't seem to search duplicate reports (I didn't know this until now). E.g. if I search for format positional I get this lone result: http://d.puremagic.com/issues/buglist.cgi?quicksearch=format+positional But with an advanced search the reports do show up: http://d.puremagic.com/issues/buglist.cgi?query_format=advancedshort_desc=format%20positionalbug_status=UNCONFIRMEDbug_status=NEWbug_status=ASSIGNEDbug_status=REOPENEDbug_status=RESOLVEDbug_status=VERIFIEDbug_status=CLOSEDshort_desc_type=allwordssubstrcomponent=Phobosproduct=D There's an option in advanced search and remember these as my default search options, but even though I have this ticked and it says it saved it, it doesn't actually work.
Re: Multiple %s format specifiers with a single argument
On 4/10/12, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: E.g. if I search for format positional I get this lone result: http://d.puremagic.com/issues/buglist.cgi?quicksearch=format+positional I mean this result: http://d.puremagic.com/issues/show_bug.cgi?id=4927
Re: Latest versions of Entice Designer and DFL?
On Monday, 9 April 2012 at 20:18:06 UTC, vmars316 wrote: C:\D\dmd2\windows\bin\dfl.exe -gui C:\D\dmd2\windows\bin\vmPrograms\myForm\myForm.d (the above is all one line) pause I got the following results: C:\D\dmd2\windows\bin\vmPrograms\myFormC:\D\dmd2\windows\bin\dfl.exe -gui C:\D\ dmd2\windows\bin\vmPrograms\myForm\myForm.d DFL lib files not found. Would you like to build the DFL lib files now? [Y/n] y Error: DFL import directory not found I suggest trying to get this method to work. DFL.exe is very picky about the directory structure. I'll have to double check the exact relationship I have (at work), but the source files for dfl are in an import folder. To get a working intsall I just extracted the zip from the main site into what I think will be your c:\D\dmd2\ then I copied the github source for win32 on top of that. The zip file ended up just being a way to install dfl.exe and know where things need to go.
Re: Latest versions of Entice Designer and DFL?
On Tuesday, 10 April 2012 at 14:21:35 UTC, Jesse Phillips wrote: I suggest trying to get this method to work. DFL.exe is very picky about the directory structure. I'll have to double check the exact relationship I have (at work), but the source files for dfl are in an import folder. To get a working intsall I just extracted the zip from the main site into what I think will be your c:\D\dmd2\ then I copied the github source for win32 on top of that. The zip file ended up just being a way to install dfl.exe and know where things need to go. My structure is: C:\opt\dmd\import\dfl\ (source files) C:\opt\dmd\bin\dfl.exe So if you place dfl.exe in dmd2\windows\bin then it stands to reason import\ should be in windows\ Oh, and in one of your other replies you mention dfl.all, that is not what the message said, it was dfl/all.d which is the file you found. Hopefully that will get you off the ground.
Re: Multiple %s format specifiers with a single argument
On Tuesday, April 10, 2012 13:06:08 Stewart Gordon wrote: On 09/04/2012 18:35, 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 Andrej, are emails from Bugzilla not getting through to you? And Jonathan, you ought to know that you already submitted one of the duplicate bug reports about this. LOL. There's no way that I'd remember all of the bug reports that I've filed. I haven't filed anywhere near as many as Bearophile has, but I've filed quite a a few, and unless a problem is one that I run into regularly or comes up regularly in the newsgroup, I'm not likely to remember that it exists, let alone that I reported it. - Jonathan M Davis
Re: Multiple %s format specifiers with a single argument
On 10/04/2012 13:30, Andrej Mitrovic wrote: On 4/10/12, Stewart Gordonsmjg_1...@yahoo.com wrote: Andrej, are emails from Bugzilla not getting through to you? I'm not getting any emails. Bugzilla stopped emailing me for quite a while now, I don't know why (except the monthly password reminder). snip Assuming that you did hit the Submit Changes button and that the email address you have registered with Bugzilla is correct, I don't know. Have you checked with your email provider to see if they're being flagged as spam? On 4/10/12, Stewart Gordonsmjg_1...@yahoo.com wrote: You shouldn't submit bug reports without searching first anyway. I did, but the default search box doesn't seem to search duplicate reports (I didn't know this until now). E.g. if I search for format positional I get this lone result: http://d.puremagic.com/issues/buglist.cgi?quicksearch=format+positional Indeed, it seems that quick search is designed only as a means of quickly finding an open bug that you know is in the system. snip There's an option in advanced search and remember these as my default search options, but even though I have this ticked and it says it saved it, it doesn't actually work. It seems that and remember these as my default search options affects only the advanced search. Or are you finding that it isn't working even there? Stewart.
Re: Latest versions of Entice Designer and DFL?
On Tuesday, 10 April 2012 at 15:19:40 UTC, Jesse Phillips wrote: On Tuesday, 10 April 2012 at 14:21:35 UTC, Jesse Phillips wrote: I deleted all of D files and started over: OK, yes, I used the dfl098.zip structure you recommended: My install structure now looks like this: C:\D\dmd2\windows\bin C:\D\dmd2\windows\Dfl\bin (dfl.exe) C:\D\dmd2\windows\Dfl\import\dfl (dfl.exe) C:\D\dmd2\windows\Entice C:\D\dmd2\windows\Entice\vmPrograms (myForm.d) * 'myForm.d' is the Tutorial-program I am trying to Compile. To get a working intsall I just extracted the zip from the main site into what I think will be your c:\D\dmd2\ then I copied the github source for win32 on top of that. So if you place dfl.exe in dmd2\windows\bin then it stands to reason import\ should be in windows\ I don't understand what copied the github source for win32 on top of that is all about. Do I need to Build something from this source? I sure hope I can get this compile working before day 5. Thanks...vm
Re: Latest versions of Entice Designer and DFL?
* I tried to compile myForm.d like this: When Entice asks for a CommandLine, I enter the following: C:\D\dmd2\windows\Entice\vmPrograms\myFormcall C:\D\dmd2\windows\bin\dfl.exe -g ui C:\D\dmd2\windows\Entice\vmPrograms\myForm\myForm.d C:\D\dmd2\windows\Dfl\lib DFL lib files not found. Would you like to build the DFL lib files now? [Y/n] y Error: DFL import directory not found Press any key to continue . . . Other than a commandLine, How can I connect up Entice/dfl ? C:\D\dmd2\windows\Dfl\lib C:\D\dmd2\windows\Dfl\import Thanks...vm
Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.
Hello Chris Miller, This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice. I am not getting the answers I need from dprogramming Forums.. Could you please help me with this. I am beginning to hate D-programming. But I’ll try to hang on a bit longer. http://forum.dlang.org/thread/daltsisbevgtmkbny...@forum.dlang.org?page=2#post-lxpqntoshkhjjempujth:40forum.dlang.org Thanks for your help...Vernon
Re: Multiple %s format specifiers with a single argument
On 4/10/12, Stewart Gordon smjg_1...@yahoo.com wrote: Assuming that you did hit the Submit Changes button and that the email address you have registered with Bugzilla is correct, I don't know. Have you checked with your email provider to see if they're being flagged as spam? Looks like you're right, it's in spam. I don't get Google, apparently your email won 1.000.000$ is not spam, but mails from d-bugm...@puremagic.com are marked as spam. I'll have to add that mail to the whitelist. It seems that and remember these as my default search options affects only the advanced search. I see. I assumed default search meant the search box at the top. Oh well, lesson learned. :)
Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.
On 4/10/12, vmars316 vmars...@live.com wrote: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice. Almost a year ago a newbie had the same issue. I gave him some short instructions but apparently this post isn't in the archives for some reason. Anyway the instructions were: 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.
Re: Dear ChrisMiller: This is day 4 of me trying to Compile a (tutorial) myForm.d program with D/Dfl/Entice.
On 4/10/12, vmars316 vmars...@live.com wrote: On Tuesday, 10 April 2012 at 20:07:41 UTC, Andrej Mitrovic wrote: On 4/10/12, vmars316 vmars...@live.com wrote: Ah, this looks thorough. It'll probably be a while before I respond, because GIT is all new to me. I am starting here: http://help.github.com/win-set-up-git/ Thanks...vm You can use the zip download: https://github.com/Rayerd/dfl/zipball/master
Higher-order functions?
Hi everyone, does D have any runtime higher-order function facilities? (I'm not talking about templates.) 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
Re: Higher-order functions?
On Wed, Apr 11, 2012 at 01:13:17AM +0200, Jonas H. wrote: Hi everyone, does D have any runtime higher-order function facilities? (I'm not talking about templates.) 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) [...] You can use delegates. Example: struct Car { int price; int wheels; int get_price() { return price; } int get_wheels() { return wheels; } } int sum(int delegate(Car) dg, Car[] cars) { int sum = 0; foreach (c; cars) { sum += dg(c); } return sum; } void main() { Car[] cars; cars ~= Car(); ... // add some stuff to the list int total_price = sum((Car c) = (c.get_price()), cars); int total_wheels = sum((Car c) = (c.get_wheels()), cars); } T -- IBM = I'll Buy Microsoft!
Re: Higher-order functions?
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?
Jonas H. jo...@lophus.org wrote in message news:mailman.1600.1334099651.4860.digitalmars-d-le...@puremagic.com... Hi everyone, does D have any runtime higher-order function facilities? (I'm not talking about templates.) Yes. Fully. Many are already in the std lib: http://dlang.org/phobos/std_algorithm.html 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) Just as one example (These all work as of DMD 2.058): import std.algorithm; // For 'map' class Car {...blah...} int getPrice(Car c) {return ...blah...;} void main() { auto listOfCars = [new Car()]; auto carPrices = listOfCars.map!getPrice(); } Or: import std.algorithm; // For 'map' class Car { ...blah... @property int price() {return ...blah...;} } void main() { auto listOfCars = [new Car()]; auto carPrices = listOfCars.map!( (Car c) = (c.price) )(); //or auto getPrice = (Car c) = (c.price); // getPrice can be reassigned at runtime auto carPrices = listOfCars.map!getPrice(); } car = new Car foobar(car.get_price) class Car { ...blah... int getPrice() {return ...blah...;} } void foobar(int delegate() dg) { auto x = dg(); } void main() { auto car = new Car(); foobar(car.getPrice); }
Re: Higher-order functions?
Timon Gehr timon.g...@gmx.ch wrote in message news:jm2hnp$s0s$1...@digitalmars.com... (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) And keep in mind, too, even though those high-order functions take the delegate/closure as a template paramater, you CAN still rig it up for the delegate/closure to be changed at runtime (as long as the delegate's signature is the same): auto myDelegate = (Car c) = c.getPrice; // Change it at runtime: if(foo) myDelegate = (Car c) = c.getPrice + 7; auto carPrices = map!myDelegate(list_of_cars);