<nisstyre>
lf94: ((lambda (x) ...) value-bound-to-x) is roughly how you can think of let, although that might not actually be true in Racket
<nisstyre>
lf94: also no define does not have a side effect
<nisstyre>
set! does
<lf94>
define modifies the global state doesnt it
<lf94>
it adds something to it
<lf94>
:p
<nisstyre>
lf94: it's not state
<nisstyre>
it's definitions
<lf94>
I say "state" but you know what I mean
<nisstyre>
when I hear "state" I think "can change"
<lf94>
it is stored somewhere globally
<lf94>
yes, a global definition
<lf94>
vs local definition
<nisstyre>
when you type (define x 3) in the top level, that won't ever change. You can of course do (define x 4) right after it, but that just means that the definition ends up using that final definition when the program rus
dddddd has quit [Remote host closed the connection]
<nisstyre>
*runs
<nisstyre>
lf94: the same thing applies in the scope of other procedures
<lf94>
(begin (begin (begin (define a 1) a)))
<nisstyre>
begin doesn't introduce new scope though
<lf94>
is a available in the top most begin?
<lexi-lambda>
Yes.
<lexi-lambda>
Nested `begin`s splice into surrounding definition contexts.
<lf94>
ok
<nisstyre>
lf94: think of define as a mathematical definition
<nisstyre>
like x*0 = 0
<nisstyre>
you're not mutating or assigning anything, you're just binding a name to a certain expression
<nisstyre>
saying these two things are equal
<nisstyre>
if you do (set! a 3) then you're actually changing a
<nisstyre>
you're re-assigning it to something
hjek has quit [Quit: hjek]
odanoburu has joined #racket
hjek has joined #racket
<lf94>
is there a way to say (+ (1 2) (3 4))
<lf94>
but get the 1 2 and 3 4 to "flatten" ?
<lf94>
all I can think of is some identity function thing might work
<lf94>
obviously this doesnt make sense because you cannot apply 2 to 1, and 4 to 3....
hjek has quit [Client Quit]
hjek has joined #racket
<aeth>
lf94: If it is only one level, it's easy (though note the ' there): (apply + (append '(1 2) '(3 4)))
<aeth>
Even if you had '((1 2) (3 4)) you'd just do (apply append '((1 2) (3 4))) instead of directly calling append.
<aeth>
append multiple lists into one list, then apply the procedure + to that list, i.e. the list '(1 2 3 4)
<aeth>
You only need to think in terms of "flatten" when there's more than one layer.
<lf94>
ah ok
<lf94>
nice
<aeth>
Racket does have a flatten, though. (flatten '((1 2) ((3) 4))) => '(1 2 3 4)
hjek has quit [Quit: hjek]
<nisstyre>
lf94: you could also just add the inner lists together with map and then use apply
<nisstyre>
(apply + (map + '(1 2) '(3 4)))
<nisstyre>
of course, that's not really the same thing
<aeth>
nisstyre: works until you try to extend your code to work with - and /
<nisstyre>
because - and / aren't commutative
FreeFull has quit []
<lexi-lambda>
If you abuse #%app, you can make functions that return several values splice into argument lists: http://pasterack.org/pastes/9185
<lexi-lambda>
But this probably isn’t very fast.
ubLIX has quit [Quit: ubLIX]
iyzsong has joined #racket
ym555 has joined #racket
ng0 has quit [Quit: Alexa, when is the end of world?]
wingsorc_ has joined #racket
YuGiOhJCJ has quit [Ping timeout: 256 seconds]
pera has quit [Ping timeout: 245 seconds]
samth has joined #racket
iyzsong has quit [Ping timeout: 258 seconds]
efm has quit [Read error: Connection reset by peer]
wingsorc_ has quit [Quit: Leaving]
efm has joined #racket
<lf94>
Does scheme have polymorphism?
<aeth>
It depends on the particular Scheme
<Duns_Scrotus>
It doesn’t even have types
<aeth>
You do get polymorphism in the numeric tower even in vanilla, portable, standard Scheme. +, -, *, /, etc. But outside of that each type foo will get its own thing, usually with the foo- prefix, with the usual exception of lists/pairs.
<aeth>
Duns_Scrotus: Scheme does have types, but afaik they're basically defined as satisfying a predicate function, e.g. "pair?"
DGASAU has quit [Read error: Connection reset by peer]
<aeth>
And there's no complexity there outside of numbers. e.g. no hierarchy where lists and vectors are both sequences, unlike in Common Lisp.
<Duns_Scrotus>
Show me the typing rules then :p
<aeth>
I don't know the current official location of r7rs.pdf for r7rs-small, but it's on page 10, §3.2 Disjointness of types
<aeth>
"No object satisfies more than one of the following predicates:" and then it lists a bunch of predicates, as well as specifying "and all predicates created by define-record-type"
<aeth>
Then it says those predicates define those types.
<Duns_Scrotus>
No I mean like gamma turnstile x colon tau
<aeth>
stuff like (+ real real) returns a real, apparently
<lexi-lambda>
Scheme is not statically typed, but that does not mean it does not have types
<aeth>
Basically every procedure has input types in r7rs-small. It's a bit clearer with numbers where z or z_i means complex, x or x_i means real, and n or n_i means integer. obj means it takes in everything.
<aeth>
The return values and/or return types are usually, but not always, specified
<aeth>
Not a formal definition for the whole language, though
odanoburu has quit [Quit: Connection closed for inactivity]
cpup has joined #racket
pera has joined #racket
amz3 has joined #racket
iyzsong has joined #racket
pie___ has joined #racket
pie__ has quit [Ping timeout: 255 seconds]
Nomenclatura has joined #racket
endformationage has quit [Quit: WeeChat 2.3]
_whitelogger has joined #racket
Arcaelyx_ has joined #racket
Arcaelyx has quit [Ping timeout: 246 seconds]
jao has quit [Ping timeout: 245 seconds]
sauvin has joined #racket
aeth has quit [Ping timeout: 268 seconds]
aeth has joined #racket
rlavery has joined #racket
aeth has quit [Ping timeout: 255 seconds]
aeth has joined #racket
Nomenclatura has quit [Quit: q]
Arcaelyx_ has quit [Ping timeout: 250 seconds]
ym555 has quit [Quit: leaving...]
pera has quit [Ping timeout: 255 seconds]
iyzsong has quit [Ping timeout: 252 seconds]
_whitelogger has joined #racket
widp_ has joined #racket
cantstanya has quit [Write error: Connection reset by peer]
ZombieChicken has quit [Remote host closed the connection]
ZombieChicken has joined #racket
dddddd has joined #racket
cantstanya has joined #racket
iyzsong has joined #racket
Fernando-Basso has joined #racket
FreeFull has joined #racket
dddddd has quit [Remote host closed the connection]
DGASAU has joined #racket
dustyweb has quit [Remote host closed the connection]
dustyweb has joined #racket
ZombieChicken has quit [Ping timeout: 256 seconds]
_whitelogger has joined #racket
iyzsong has quit [Ping timeout: 259 seconds]
catonano has joined #racket
_whitelogger has joined #racket
iyzsong has joined #racket
jao has joined #racket
iyzsong has quit [Ping timeout: 240 seconds]
endformationage has joined #racket
sagax has joined #racket
soegaard has joined #racket
dddddd has joined #racket
jao has quit [Ping timeout: 255 seconds]
Arcaelyx has joined #racket
Arcaelyx has quit [Ping timeout: 244 seconds]
orivej has quit [Ping timeout: 250 seconds]
Arcaelyx has joined #racket
widp_ has quit [Ping timeout: 244 seconds]
soegaard has quit [Quit: soegaard]
<jcowan>
On 64-bit machines it is possible to have unboxed (not too big) ints and floats at the same time.
<jcowan>
while remaining fully dynamically typed
<jcowan>
AFAIK no Lisp actually does this yet, because backward compatibility with 32-bit systems
dTal has quit [Ping timeout: 250 seconds]
<greghendershott>
jcowan: What you're describing, isn't the same as Racket flonums, because the unboxed-ness isn't automatic guaranteed?
DGASAU has quit [Read error: Connection reset by peer]
DGASAU has joined #racket
DGASAU has quit [Read error: Connection reset by peer]
DGASAU has joined #racket
aeth has quit [Ping timeout: 255 seconds]
aeth has joined #racket
DGASAU has quit [Read error: Connection reset by peer]
aeth has quit [Ping timeout: 255 seconds]
aeth has joined #racket
sz0 has joined #racket
Lowl3v3l has quit [Remote host closed the connection]
<jcowan>
greghendershott: The way it works is that all pointers are fitted into the "signaling NaN" space of flonums, and then fixnums up to 47 bits can be fitted into the pointer subspace.
DGASAU has joined #racket
DGASAU has quit [Read error: Connection reset by peer]
ZombieChicken has joined #racket
jao has quit [Remote host closed the connection]
DGASAU has joined #racket
pera has quit [Ping timeout: 240 seconds]
jao has joined #racket
DGASAU has quit [Ping timeout: 255 seconds]
soegaard has joined #racket
<ZombieChicken>
isn't 7.2 released?
<bremner>
yes?
<ecraven>
jcowan: Riastradh has been talking about moving 64 bit mit-scheme to nan-boxing
<lf94>
> obj1 and obj2 are pairs, vectors, bytevectors, records,
<lf94>
or strings that denote the same location in the store
<lf94>
(eqv? from the r7rs pdf)
<lf94>
So because '(a) and '(a) are allocated to different locations...they are not equal
<lf94>
this is nice to know
<ZombieChicken>
soegaard:ty
<ecraven>
lf94: but they might be allocated to the same location
<ecraven>
guile does this
<lf94>
I see...
<lf94>
So _that_ is why it depends on impl.
<ecraven>
nothing says two identical literals cannot have the same location (as they shouldn't be mutated anyway)
<lf94>
One impl might be trying to optimize
<ecraven>
indeed
<lf94>
I wish it was written in the document
<lf94>
Instead of just "unspecified"
<ecraven>
well, it leaves the choice to the implementor, and effectively means you cannot use eq? to compare literals in portable code
<ecraven>
or at least not depend on it to work that way
<lf94>
How do you guys say "car" and "cdr" in your heads? "c-a-r-"? "car"? "c-dee-are"?
Lowl3v3l has joined #racket
<lf94>
this is a mental barrier for me
<lf94>
why not just have 'first' and 'second'
<bremner>
history
<bremner>
also, cdr is 'rest', not 'second'
<lf94>
I know history
<lf94>
but why not say let's correct things
<lf94>
X)
<lf94>
anyway
<lf94>
rest...important
<lf94>
head and rest
<bremner>
yeah, I don't know why the new standards don't make 'first' and 'rest' first class, and deprecate 'car' and 'cdr'
<bremner>
too much old code maybe?
<lf94>
Doesnt answer though: how do you say these in your head
<ZombieChicken>
iirc, one of the reasons for not switching is the caaddar-style calls that can be made. Those are much more verbose (and possibly more confusing) than using a bunch of first/rest over and over
<bremner>
lf94: car is car and cdr is kudr
<lf94>
ku?
<lf94>
not "cuhdr"?
<bremner>
*shrug*
<lf94>
Sorry ku is "koo" to me
<lf94>
"kuhdr", ok
<bremner>
ZombieChicken: yeah, I never use caaddar thingies
<ZombieChicken>
lf94: probably car and something starting with a c-like sound and ending with 'dr'
<soegaard>
Watch the old sicp videos to hear the pronounciation.
<ZombieChicken>
bremner: sounded like people were asking why not just use first and rest, and that was the reason I'm aware of. We might could migrate to a prolog-style (_,_,_|_) system, but that's almost as bad
<lf94>
Damn what I dumb question when I look at this
<ZombieChicken>
Overthinking?
<lf94>
I think the thing that messed me up was looking at (define (square x) (+ x x))
<lf94>
_that_ doesn't make much sesne
<lf94>
but the latter makes a lot more sense
<lf94>
In the former form, (square x) should execute something
<lf94>
(apply x to square)
<lf94>
But it's a very special form
<lf94>
So of course it wont
<lf94>
I really dont like that X)
orivej has quit [Ping timeout: 255 seconds]
Lowl3v3l has joined #racket
<ZombieChicken>
the (define (name args) ...) is just shorthand for the more verbose (define name (lambda ...)).
<lf94>
I know
<lf94>
But its confusing as hell unless you know it
<bremner>
well, all languages have some syntax to learn
<lf94>
(lambda ...) is returning a procedure
<lf94>
yea but it destroys the beauty of lisp/scheme.
<bremner>
elegance is overrated
<ZombieChicken>
bremner: Forth doesn't really
<lf94>
bremner, no, it isn't
<bremner>
ZombieChicken: thank you for agreeing with me ;)
<bremner>
lf94: for working programmers, to much minimalism is just a pain in the ass
<lf94>
bremner that's why you build higher order things
<bremner>
I mean, yes, I could use lambdas and the peano axioms to impliment everything, but I'd rather not
<lf94>
there are inherent problems with peano axioms being used
<bremner>
uh. yes.
<lf94>
the major one being extreme inefficiency
<lf94>
again: another reason for lisp/scheme being beautiful.
<lf94>
it uses a nice numerical model to map to a turing machine efficiently (i.e. whatever the target cpu supports, bignums, etc)
<bremner>
well, I admire your enthusiasm, but keep in mind your lecturing people who know at least as much about scheme as you do ;)
<lf94>
I know.
<lf94>
maybe in 2 days I will turn around and say f scheme, I'm done.
<lf94>
X)
<lf94>
But I got here because of studying lambda calculus for 1-2 monhs
<lf94>
And realizing: there are some inherent issues using lambda calculus to program.
<lf94>
numbers, evaluation model, etc.
<lf94>
lisp/scheme is a really, really nice...interpretation? of lambda calculus that maps to turing machines
<lf94>
If (define name (lambda ...)) is too long, just make a function to shorten it!
<ZombieChicken>
if you have fun and like the lisp-family, give prolog a shot sometime
<lf94>
I have :)
<lf94>
prolog is on my sights too
<ZombieChicken>
have you actually used prolog, or just looked at it some?
<lf94>
I actually used it
<lf94>
to solve a few problems in uni
<ZombieChicken>
ah
<ZombieChicken>
just in case you're unaware, there is a ##prolog here
<lf94>
it ain't too bad, but I'm not crazy about it because the applications for it are pretty specific
<ZombieChicken>
(and a #minikanren, fwiw)
<lf94>
yesssss
<lf94>
kanren is awesome
<ZombieChicken>
I've yet to use kanren
<lf94>
But I'd rather impl my own prolog is r7rs :)
<lf94>
for intuitive learning reasons
<ZombieChicken>
and there are people in ##prolog that use prolog as a general purpose language
<lf94>
yee, I know I know
<ZombieChicken>
just don't expect it to be anything resembling fast.
<lf94>
never
<ZombieChicken>
and I'd suggest not even trying to make it multithreaded
<lf94>
my main goal behind learning r7rs is expressiveness, and simplicity, and with these, cement the future existence of my code
<lf94>
the "simplicity and expressive" part is super awesome
<lf94>
portable, easy to reimplement an interpreter
<lf94>
all the while remaining powerful to describe a process :)
soegaard has quit [Quit: soegaard]
selimcan has quit [Ping timeout: 268 seconds]
selimcan has joined #racket
selimcan-i_sani has joined #racket
selimcan has quit [Ping timeout: 255 seconds]
<aeth>
lf94: r7rs-small doesn't really specify enough to make a practical modern program, at least not without reinventing a bunch of wheels, and probably way more inefficiently than if those wheels were included. e.g. it lacks hash tables.
YuGiOhJCJ has joined #racket
<aeth>
A large project like a large programming language probably should be done in something larger than r7rs-small.
<aeth>
You might be able to write an extended r7rs-small dialect in Racket by exposing from Racket more functionality as needed (r7rs-large itself isn't final yet, and your extensions are probably going to be incompatible)
Arcaelyx_ has joined #racket
Arcaelyx has quit [Ping timeout: 255 seconds]
<aeth>
The problem with small languages (if you write everything in that language itself) is that you have to reinvent a bunch of things that everyone else has standard. In C, that generally means you sacrifice safety and robustness, and in most of the rest of the small languages you sacrifice performance.
<aeth>
Schemes in practice are extended, both with portable semi-standard extensions (SRFIs) and implementation-specific extensions like, well, 95% of https://docs.racket-lang.org/
widp_ has joined #racket
Fernando-Basso has quit [Remote host closed the connection]