|
http://gigamonkeys.com/book/numbers-characters-and-strings.html quote:One of the reasons Lisp is a nice language for math is its numbers behave more like true mathematical numbers than the approximations of numbers that are easy to implement in finite computer hardware. For instance, integers in Common Lisp can be almost arbitrarily large rather than being limited by the size of a machine word. And dividing two integers results in an exact ratio, not a truncated value. And since ratios are represented as pairs of arbitrarily sized integers, ratios can represent arbitrarily precise fractions.
|
# ? Aug 1, 2016 19:31 |
|
|
# ? Jun 12, 2024 07:29 |
|
my friend, have you heard of the glory of unums?
|
# ? Aug 1, 2016 19:34 |
|
how do i represent a non-rational real value like sqrt2 or pi in common lisp
|
# ? Aug 1, 2016 20:24 |
|
a big float, i guess paging eschaton, we need a way better lisp nerd than me in here.
|
# ? Aug 1, 2016 20:29 |
|
Suspicious Dish posted:how do i represent a non-rational real value like sqrt2 or pi in common lisp a lazily evaluated chebyshev series
|
# ? Aug 1, 2016 20:43 |
|
fritz posted:a lazily evaluated chebyshev series algebraic numbers are ez u just compute in the correct field extension of Q. u can then extend this by stapling on e and pi and poo poo chebfun is cool but inexact at heart
|
# ? Aug 1, 2016 21:40 |
|
jony neuemonic posted:a big float, i guess or a big rational, say 314159265358979/100000000000000, which lets you choose a precision instead of having it dictated by where the value falls in the floating point range. but yeah lisp uses floats fritz posted:a lazily evaluated chebyshev series more likely than you think! there are libraries that do this e: lazy evaluations of approximations I mean, not specifically a chebyshev series (which I confused with the taylor series because I'm bad at math) hackbunny fucked around with this message at 21:58 on Aug 1, 2016 |
# ? Aug 1, 2016 21:51 |
|
No, this is exactly the crap that makes for a lovely compiler target. Python has bignums too. But if I have a language that has an "8 bit integer" type, programs in the language that depends on overflowing behaviour for correctness, then I get the joy of packing it in a Numpy or ctypes int8 class if I want to target Python. What a human wants in the language is not necessarily what a code generator wants. I do remember something about Common Lisp supporting some strange user-defined modular arithmetic types, but I'm hazy on the details. Common Lisp has so much weird crap that nobody asks for (displaced arrays yay).
|
# ? Aug 1, 2016 23:08 |
|
JawnV6 posted:my friend, have you heard of the glory of unums?
|
# ? Aug 2, 2016 12:50 |
|
rjmccall posted:if you're not checking types, but are just rewriting source structures to similar structures in the target language, what you have is not a "compiler" because you aren't really implementing the source language anyway I literally can't stop reading this guy. today's entry almost garners praise for staving off type mysticism until the first value bullet point, but the abstract implies it's one of two points of comparison between langs along with 'efficiency'. i personally didn't understand that languages should be providing ASLR, but i only made it to bronze palm
|
# ? Aug 3, 2016 20:53 |
|
tcp is the worst it has too many magical config options udp for life
|
# ? Aug 3, 2016 23:22 |
|
Sweeper posted:tcp is the worst it has too many magical config options udp for life ecn bithc
|
# ? Aug 4, 2016 18:56 |
|
Does JavaScript just lend itself to or even encourage globals and sloppiness? When I'm using compiled languages I'm almost always giving a called method from the caller everything it needs to know to do what it needs to do EXPLICITLY. JavaScript likes closures and just grabbing variables that aren't passed as parameters, it seems, and there's a big pile of globals I can't even loving find the definitions of text searching every source file in the project I'm fixing up right now. Is this idiomatic or more symptomatic? JFC there's a big script tag with globals injected by .NET MVC that the app uses: code:
Space Whale fucked around with this message at 17:32 on Aug 11, 2016 |
# ? Aug 11, 2016 17:06 |
|
javascript in a web browser starts with a big bundle of global state, so it probably does give people the wrong idea about that being a reasonable way to write programs i don't know what your beef with closures is, though
|
# ? Aug 11, 2016 17:27 |
|
rjmccall posted:javascript in a web browser starts with a big bundle of global state, so it probably does give people the wrong idea about that being a reasonable way to write programs I just like being able to look at the argument list of a function/method, probably because I'm really more of a C# guy. The thought of "just being there" instead of explicitly passed down makes me grunt. There's a good chance I'm not using the right terminology or just full of poo poo.
|
# ? Aug 11, 2016 17:30 |
|
Space Whale posted:The thought of "just being there" instead of explicitly passed down makes me grunt. it's not that different from members
|
# ? Aug 11, 2016 17:38 |
|
Space Whale posted:Does JavaScript just lend itself to or even encourage globals and sloppiness? the MVC stuff there is all request variables. ex: User.Identity.Name is the current request's user's name. It would be nicer to put the logic of currentRole, isAdmin, etc... into a viewmodel instead of in the view like this, but none of this is really too bad. This would be a problem if A) the resulting javascript variables are used for security purposes client side instead of just display or B) the returned view is being used as a partial that will be referenced over and over thru multiple requests (like in an SPA). It would be cleaner to maybe return these things as json or as a javascript module to keep it out of the javascript globals but then again its javascript and garbage is standard operating procedure.
|
# ? Aug 11, 2016 17:39 |
|
Space Whale posted:There's a good chance I'm just full of poo poo. its this, op closures are an abstraction tool and a good way of separating things into independently reusable and testable components also they exist in c#, so you do not actually have an excuse
|
# ? Aug 11, 2016 17:41 |
|
closures are stupid bullshit for when you're in a language with bad type support.
|
# ? Aug 11, 2016 17:43 |
|
closures with explicit capture are pretty good
|
# ? Aug 11, 2016 17:49 |
|
Shaggar posted:closures are stupid bullshit for when you're in a language with bad type support. what does it have to do with types?
|
# ? Aug 11, 2016 17:51 |
|
rjmccall posted:its this, op Linq is one thing, but having a method that just grabs a variable that wasn't passed in makes me go "where the hell is it getting fooThing from?" With a linq closure (that is a closure, right?) it's an anonymous inlined method that's literally right there, not just expecting a variable with that name to be in scope when it's called. Right?
|
# ? Aug 11, 2016 17:52 |
|
Shaggar posted:closures are stupid bullshit for when you're in a language with bad type support. Isn't LINQ all about closures though?
|
# ? Aug 11, 2016 17:53 |
|
Space Whale posted:Linq is one thing, but having a method that just grabs a variable that wasn't passed in makes me go "where the hell is it getting fooThing from?" are you talking about dynamic scoping or something, because that doesn't exist in javascript. the javascript scoping rules are weird and evil, lookups just resolve to properties of the global object, but that has nothing to do with closures closures are when you have nested objects/functions that capture ("close over") local variables that are in scope. linq makes some closures implicitly but delegates and lambdas are the general features
|
# ? Aug 11, 2016 18:01 |
|
Now that I look harder at it, I think it's just "globals everywhere" and I was confused as poo poo. I'm also a crybaby because I've avoided doing serious JS for years and I'm finally dealing with it. I'm still mad though. Offshored poo poo being used by a pretty major isp that you might be on right now? I'm fixing it. It's tooling for analysts, not infrastructure stuff, if that makes you feel better.
|
# ? Aug 11, 2016 18:06 |
|
the only time I shake my limp-wristed fist at closures is when i have to refactor out a nested function and figure out what all context it's capturing so i can add it as arguments
|
# ? Aug 11, 2016 18:11 |
|
Always be explicit
|
# ? Aug 11, 2016 18:22 |
Higher-order functions suck without closures, and higher-order functions are very good, therefore closures are very good.
|
|
# ? Aug 11, 2016 20:22 |
|
Space Whale posted:I've avoided doing serious JS for years and I'm finally dealing with it. this should help you get started: JavaScript code:
|
# ? Aug 11, 2016 21:37 |
|
javascript definitely feels like a "closures are a poor man's objects" lang as opposed to the other way around.
|
# ? Aug 11, 2016 22:03 |
|
Space Whale posted:Does JavaScript just lend itself to or even encourage globals and sloppiness? people like to pretend they dont have global mutable state by putting little pretty curtains around it
|
# ? Aug 12, 2016 02:17 |
did anyone say pjavascript yet?
|
|
# ? Aug 12, 2016 02:26 |
|
comedyblissoption posted:virtually all mainstream langs encourage this imo likewise all control statements are no better than gotos
|
# ? Aug 12, 2016 02:30 |
|
comedyblissoption posted:virtually all mainstream langs encourage this imo
|
# ? Aug 12, 2016 02:31 |
|
we're all naked under our clothes man
|
# ? Aug 12, 2016 02:32 |
|
Volte posted:we're all naked under our clothes man deep
|
# ? Aug 12, 2016 02:34 |
|
the sane way to structure the vast majority of programs is probably glueing together mutable state transformations with pure-enough functions where the pure-enough functions make up most of the program most mainstream langs dont really encourage the above
|
# ? Aug 12, 2016 02:38 |
|
if you have a globally mutable variable but you put it inside an effectively singleton class and dependency inject the state, somehow it's no longer a global variable
|
# ? Aug 12, 2016 02:41 |
|
if you are using singletons with mutable state inside them then you've hosed up already
|
# ? Aug 12, 2016 02:45 |
|
|
# ? Jun 12, 2024 07:29 |
|
dependency injection frameworks let you pretend singletons arent singletons
|
# ? Aug 12, 2016 02:46 |