• Programming - WAYWO [38]
    12,604 replies, posted
[QUOTE=Foxtrot200;42449564]User input/UI elements? Data formats like JSON and YAML?[/QUOTE] JSON actually allows boolean constants, not sure about YAML. In any case, I think it depends on what you're doing. A function called ParseBoolean() should clearly return false for the string "false", but casting (not parsing, just a typecast) "false" to a boolean should either return true because the string is nonempty, or throw an error, depending on the desired behavior. Having if("false") fail the condition statement is beyond even Javascript's level of "what the fuck are you doing with your type system".
[QUOTE=calzoneman;42450742]JSON actually allows boolean constants, not sure about YAML. In any case, I think it depends on what you're doing. A function called ParseBoolean() should clearly return false for the string "false", but casting (not parsing, just a typecast) "false" to a boolean should either return true because the string is nonempty, or throw an error, depending on the desired behavior. Having if("false") fail the condition statement is beyond even Javascript's level of "what the fuck are you doing with your type system".[/QUOTE] While I agree, Lua doesn't really have a concept of casting (at least, not within the language itself.) Within the language, converting between numbers, strings, tables, and userdata is almost always a matter of parsing.
[QUOTE=Banandana;42447625]um [img]http://img812.imageshack.us/img812/8494/e1fy.png[/img] [editline]7th October 2013[/editline] w0t[/QUOTE] bahah wtf i thought that came up for me im trying to click cancel :rolleyes:
[QUOTE=Banandana;42447625]um [img]http://img812.imageshack.us/img812/8494/e1fy.png[/img] [editline]7th October 2013[/editline] w0t[/QUOTE] I had this happen. It actually did fix it for me.
So I just signed up for [url=http://www.y-hack.com/]Y-Hack[/url] with a few of my friends. Will I see any other fpers there?
[QUOTE=acpm;42447504]Clever, but in Lua it's not feasible; I also need an absolute solution to all native types in Lua.[/QUOTE] I forgot Lua doesnt natively have a ! operator, in GLua !! works fine though However, this has the exact same output [code]not not v and v ~= "false" and v ~= "nil"[/code]
Snipped. Um, I don't have any other content. Eh, I found this handy: [url]http://vivekcek.wordpress.com/2009/10/22/how-to-get-cpu-and-memory-usage-c-net/[/url] For getting total system RAM, this was useful [CODE] using Microsoft.VisualBasic; ... private static ulong GetTotalMemoryInBytes() { return new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory; }[/CODE]
Here have some more mindfuck [img]https://dl.dropboxusercontent.com/u/28926055/mindfuck.png[/img]
[cpp]public class UnassPaymentButtAction[/cpp] I found this class name far too funny :v:
new [B]operation bloodshed[/B] video - [I]new elements, multi-level sectors[/I] [media]http://www.youtube.com/watch?v=1iPkM9olna0[/media] In the video: * Editing 32x speed timelapse * Playthrough of a multi-level sector * New elements (green/red doors, trapdoors, enemy spawners) * More aggressive enemies (tweaked bouncing) * Energy shard collection Devlog: [url]http://forums.tigsource.com/index.php?topic=36131.0[/url] GitHub: [url]https://github.com/SuperV1234/SSVBloodshed[/url]
I'd say "false" converting to false is asking for trouble. Sooner than you know it you'll be doing 1336 + "one" - "elite" == false, and nobody needs another one of those.
[QUOTE=acpm;42449587]Why would Lua's architect include tonumber() when developers could simply just use the actual number?[/QUOTE] Because that actually makes sense. toboolean should only be written for a specific use-case. Trying to make it generic is insane. Also tonumber actually matches the language's handling of numbers, why the hell would you create a toboolean for which the sole purpose is to have _different_ handling than the rest of the language.
processing [img]http://31.media.tumblr.com/0d5293d30f58ff4851886aa7e54b9430/tumblr_mtvhofdrCX1qmdokno2_1280.png[/img] [IMG]http://25.media.tumblr.com/10ec4df236ca7f14ed4dec8aa6826456/tumblr_mtwl448HWJ1qmdokno4_1280.png[/IMG]
Added some spikes + death. Getting death right (as in, deleting and recreating everything again properly) was hard for me in my last game, so I decided to get it done early now! [IMG]http://i.minus.com/iVcqf405Qga3g.gif[/IMG]
[QUOTE=qqqqqqqq;42454350]Because that actually makes sense. toboolean should only be written for a specific use-case. Trying to make it generic is insane. Also tonumber actually matches the language's handling of numbers, why the hell would you create a toboolean for which the sole purpose is to have _different_ handling than the rest of the language.[/QUOTE] Adding to that, conversion and parsing are different things. "false" and "true" can be parsed to boolean with their corresponding values as the results. Anything other to that should be and exception anyways. When casting/converting, if you insist on string being castable to bool, everything but "" and null should be true. Including "false"
[QUOTE=twoski;42454417] [IMG]http://25.media.tumblr.com/10ec4df236ca7f14ed4dec8aa6826456/tumblr_mtwl448HWJ1qmdokno4_1280.png[/IMG][/QUOTE] [IMG]http://www.facepunch.com/fp/ratings/weed.png[/IMG]
[QUOTE=nomad1;42448443]Are mobile device emulators always shit? Tizen is running my donkey kong clone using webgl at 10 frames, while my ipod running canvas 2d (much slower then webgl) is running my game at 30 - 45 fps. Edit: Did I mention i'm using Intel HAXM? Wel I am and that is what the emulator gives me.[/QUOTE] Apple's done some library-fu to make the iOS simulator essentially just a hot code-loader that plugs within the same process as the simulator's chrome itself - which is yet another reason, mind you, why they wag their fingers at any use of a non-exposed function.
[QUOTE=qqqqqqqq;42454350]Because that actually makes sense. toboolean should only be written for a specific use-case. Trying to make it generic is insane. Also tonumber actually matches the language's handling of numbers, why the hell would you create a toboolean for which the sole purpose is to have _different_ handling than the rest of the language.[/QUOTE] okay that's cool
I still don't see why you'd ever [I]need[/I] a toboolean. Is this really such a common enough issue to make a generic function for? [editline]8th October 2013[/editline] I'm just a scrub programmer and all but seriously why
[QUOTE=robmaister12;42434407]So I've been working on a library called [url=https://github.com/Robmaister/SharpNav]SharpNav[/url] for [url=http://rcos.rpi.edu/]RCOS[/url], a form of undergraduate research here that gives you either course credit or a stipend for working on open source software. You can also propose your own open source project to work on. The kicker is that you get to keep the copyright for the work you've done, it doesn't belong to the school. We have to give at least 2 presentations per semester, I'm giving my first this Tuesday. So far I can conservatively voxelize a level and convert it to open spans, I'm hoping I can get regions generated reliably by then. Here's a screenshot of the voxelized world: [img]http://i.imgur.com/1sNH8En.png[/img] Also, I've got my powerpoint ready if anyone wants to take a look at them: [url]http://slid.es/robertrouhani/sharpnav-10-8-13[/url] I go over the algorithm at a very high level in there (and slid.es is a really cool website!)[/QUOTE] the slides made me sea sick.
[QUOTE=BlkDucky;42455585]I still don't see why you'd ever [I]need[/I] a toboolean. Is this really such a common enough issue to make a generic function for? [editline]8th October 2013[/editline] I'm just a scrub programmer and all but seriously why[/QUOTE] i've needed it once when reading bools from sql, you get 0 and 1 and since 0 is true in lua you cant do something like if !boolval which is a bit annoying. Always used a very simple a = a == 1 or false for that case though. Don't see why a lib would need it
[QUOTE=Kamshak;42456252]i've needed it once when reading bools from sql, you get 0 and 1 and since 0 is true in lua you cant do something like if !boolval which is a bit annoying. Always used a very simple a = a == 1 or false for that case though. Don't see why a lib would need it[/QUOTE] The [i]or false[/i] at the end is superfluous.
weird man i was looking at vgui, snoopin' around their panel hierarchy when i noticed some of their shit is broken i was checking it out for some inspiration to a problem, but it doesn't help that their stuff has issues, so nvm, i guess
I've been spending some time writing a proof of concept C++11 style variant<Ts...> type, like the one found in boost. One of the big differences between C++ and other languages that have proper discriminate unions, is that the boost variant requires you to write a visitor, with an overload of operator () for each T, unless the action you are doing to the T is generic enough to not require it. In C++14 we're going to have generic lambdas. Which is fine, but I do not have that luxury, and hey, maybe you want to mix and match visitors, instead of having to write a new one each time? Well, part of my proof of concept is that I wanted a variant that allowed pattern matching via lambdas, or any other callable. So right now, the following code works with my variant: [cpp] core::variant<std::string, std::vector<std::string>, uint32_t> variant = std::string { "hello, world!" }; variant.match( [](std::string const& val) { std::clog << val << std::endl; }, [](std::vector<std::string> const& val) { for (auto const& str : val) { std::clog << str << std::endl; } } [](uint32_t val) { std::clog << "This integer is like Detroit. No one cares anymore. :'(" << std::endl; } ); [/cpp] (It's not true pattern matching, because I have as of yet to figure out how to have a 'default' visitor. There's a few things I need to cleanup, like how gcc will always ALWAYS choose the const version of match even when I have an explicitly declared mutable reference to the variant ([i]very[/i] annoying, when trying to call a destructor). I've also not tested this code on clang, though I believe it should work just fine. The only issue with my internal code is a bug with GCC where it does not expand lambdas in parameter packs. Much to my dismay. I'm really excited though. Once I get this variant type finished, I just need to finish the unit tests, write a ton of documentation, mark a release, and then distribute. :v:
While I don't want to imply that it's not pretty, pattern matching goes beyond matching types. At least with this overload, I can't imagine how you'd do something like [code]variant.match( [](0){ std::clog << "True" << std::endl; }, [](1){ std::clog << "False" << std::endl; }, [](2){ std::clog << "File not found" << std::endl; }, //even if you can whip up the above, this is going to be difficult [](std::make_pair(5, x)){ std::clog << "second element is " << x << std::endl; } );[/code] C++ also doesn't have first-class pairs and lists and such, meaning that even if you had some form of matching them, it'd still be less pretty writing for example std::make_pair(5, x) like in the example above than just (5, x).
im in AP Java and I don't know/nor have the desire to program anymore. I liked regular java last year but what was fun is now work and I feel like i'm too busy to for it now. I also don't want to fail
[QUOTE=ZeekyHBomb;42458841]While I don't want to imply that it's not pretty, pattern matching goes beyond matching types. At least with this overload, I can't imagine how you'd do something like [code]variant.match( [](0){ std::clog << "True" << std::endl; }, [](1){ std::clog << "False" << std::endl; }, [](2){ std::clog << "File not found" << std::endl; }, //even if you can whip up the above, this is going to be difficult [](std::make_pair(5, x)){ std::clog << "second element is " << x << std::endl; } );[/code] C++ also doesn't have first-class pairs and lists and such, meaning that even if you had some form of matching them, it'd still be less pretty writing for example std::make_pair(5, x) like in the example above than just (5, x).[/QUOTE] Variants are discriminate unions, not records of values (tuples, structs, etc.), and pattern matching with types is dependent on compile time information, and the visitation done by boost is entirely type dependent. That said, I could do your pseudo-match with the following (it would require some wrapper stuff to do it exactly as you have BUT I DIGRESS) [cpp] template <std::int32_t N> using integer = typename std::integral_constant<std::int32_t, N>::type; core::variant<integer<0>, integer<1>, integer<2>, decltype(std::make_pair(integer<5> { }, x))> variant { }; variant.match( [](integer<0>) { std::clog << "True" << std::endl; }, [](integer<1>) { std::clog << "False" << std::endl; }, [](integer<2>) { std::clog << "File not found" << std::endl; }, [](decltype(std::make_pair(integer<5> { }, x)) pair) { std::clog << "second element is " << std::get<1>(pair) << std::endl; } ); [/cpp] Not as pretty, obviously, and it doesn't let you do runtime stuff (though you totally could if you were okay with 15 levels of indirection of feeding an integer into a function to get a integral_constant back. Oh and it won't link. yeah :v:) Hopefully with the eventual reflection TS, we'll get typelists, which terrify me (only because of what I'll be able to do which is basically write a reflection runtime without an 'any' type and std::tuple), but are going to be necessary to get away from using std::tuple EVERYWHERE for type lists (which is what I've been doing in my core library. It's a huge pain in the dick. We're talking 22.86 centimeter spikes of pain here). For those who wish to know what a typelist is, it's going to be this: [cpp] using some_typelist = <int, double, std::string>; [/cpp]
gross [editline]8th October 2013[/editline] [QUOTE=DesolateGrun;42458916]im in AP Java and I don't know/nor have the desire to program anymore. I liked regular java last year but what was fun is now work and I feel like i'm too busy to for it now. I also don't want to fail[/QUOTE] these types of posts scare me, i hope your slump ends soon
I wrote an algorithm in Lua to emulate Horse_ebooks using some sample text [img]http://puu.sh/4LlVi/8738039bb0.png[/img] Is it convincing enough?
It would be more convincing if your source material came from ads.
Sorry, you need to Log In to post a reply to this thread.