Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

design a better scheme

Name: Anonymous 2016-07-20 20:06

Hello

In one post write everything you feel is essential to fixing the scheme language.

No whitespace sensitive syntax changes

Name: Anonymous 2016-07-20 20:11

it's called Common Lisp

Name: Anonymous 2016-07-20 20:34

Scheme is by design minimal and low-level. In other words, its core constructs are shit by design.

Name: Anonymous 2016-07-20 23:08

Other than an official module system, Scheme is perfect for me.

Name: Anonymous 2016-07-21 4:22

>>2
that isn't scheme

>>3
you seem like an idiot

>>4
yeah module system is the most important thing that it currently lacks

Name: Anonymous 2016-07-21 6:15

>>5
So you like building everything out of the equivalent of GOTO. Small minded cretin.

Name: Anonymous 2016-07-21 7:44

>>6
le goto is always bad maymay pisses me off. goto was often used badly and led to unreadable code but sometimes it is the better choice. Knuth understood it, cargo cult programmers didn't

Name: Anonymous 2016-07-21 11:32

>>6
>>7
what are you niggers talking about. get back on topic

Name: Anonymous 2016-07-21 11:53

>>8
They're talking about call/cc I reckon

Name: Anonymous 2016-07-21 12:48

call/cc is not really a goto, from my limited understanding of lisp its sort of complex setjmp/longjmp sequence with alot of state passed.

Name: Anonymous 2016-07-21 14:18

>>9
if so, then they really are retards

Name: Anonymous 2016-07-21 19:29

>>9
Tail recursion is a GOTO as well.

Name: Anonymous 2016-07-21 19:31

>>12
you are a retard as well

Name: Anonymous 2016-07-21 19:54

tail recursion is a while loop is a conditional GOTO

Name: Anonymous 2016-07-21 20:54

>>14
you are a retard as well

Name: Anonymous 2016-07-21 21:22

>>15
Oh I'm sorry, I meant optimized tail recursion.

Name: Anonymous 2016-07-21 21:27

>>5,11,13,15-chan has no idea how Scheme is actually implemented. It's just GOTOs. Seriously, a tail recursion is LITERALLY a GOTO! It's not even a conditional operation.

It can be the right thing to do in certain cases, but if that GOTO is the only thing you've got, your language is a mess.

Name: Anonymous 2016-07-21 21:49

>>17
stop posting retard

tail recursion is LITERALLY a GOTO
show this line of code in a scheme compiler, ideally one you have written

Name: Anonymous 2016-07-21 22:16

>>17
I'm not familiar with Scheme, but if tail recursion is optimized to unconditional GOTO, how would it ever terminate? Is there a conditional exit statement preceding it in the function body?

Name: Anonymous 2016-07-22 4:04

>>18,19
Well, he's dumb, but he isn't wrong. The function call is effectively removed and the stack frame isn't saved. Consider (define (fact x) (if (= x 1) 1 (* x (fact (- x 1))))). A non-tco'd compiled code segment may look something like:
fact_non_tco:
push rbp
mov rbp, rsp
mov rax, 1
sub rsp, 8
mov [rsp], rcx
cmp rcx, 1
je .unwind
dec rcx
call fact
.unwind:
imul rax, [rsp]
add rsp, 8
leave
ret

. While non-TCO may compile too something like:
fact_tco:
mov rax, 1
.recurse:
cmp rcx, 1
je .exit
imul rax, rcx
dec rcx
jmp .recurse
.exit:
ret

. The first has to save the stack, making space complexity dependent on the size of the input, while the second does not.

Name: Anonymous 2016-07-22 4:10

>>19
The conditional isn't part of the tail call, just like it isn't part of any other non-tail call! How the fuck do you think you make conditional function/procedure/method calls in any other language?

The only difference with tail recursion is it GOTOs back to the start of the function, rather than to a new function or establishing a new stack frame. Fuck, it's even more gimped than GOTO because you can't even specify a god damned label!

>>18
Lol, looking into disassemblies in Racket scheme, which I do use on occasion, and googling around it looks like Scheme implementers are still using fucking continuation thunks to tail recurse. What a fail language. Show me a scheme compiler that can actually fucking compile, and I'll point you straight to the GOTO/JMP. Even the most simple infinite loop tail recursion pops out to continuation thunks, even though it's 100% statically provable that there will never be any continuation escaping.

The only thing a tail recursion is conceptually is a GOTO back to the beginning of the function. It's a failure of Scheme and its ultra-shitty call/cc

Fine, show me a scheme compiler that actually compiles decently and gives disassemblies and I'll point it out to you. I have racket, but its output is bullshit. It thunks through tail calls like Java hacks do it, even though

I'll entertain you, you brainless piece of shit with your fucking clueless nigger intellect.

I have Racket, but it does not generate tight asm code at all. Sifting through all its bullshit, let's look at the basic fucking factorial:

(define (factorial x accum)
(if (zero? x)
acc
(factorial (sub1 x) (* x accum))))


This generates 124 fucking lines of asm, with zero commenting on the bullshit non-inline utility callouts it makes, or the memory locations of its variables, whereas the obviously superior Common Lisp (SBCL) makes a very readable 32 asm instructions for the fully generic version, and down to 13 if the numbers are declared to be fixnums:

CL-USER> (disassemble #'factorial)
; disassembly for FACTORIAL
; Size: 33 bytes. Origin: #x1006AF63C0
; C0: L0: 4885C9 TEST RCX, RCX ; no-arg-parsing entry point
; C3: 7506 JNE L1 <<= Go do the work if x isn't zero

; C5: 488BE5 MOV RSP, RBP
; C8: F8 CLC
; C9: 5D POP RBP
; CA: C3 RET <<= Exit if RCX up there was zero

; CB: L1: 488BD9 MOV RBX, RCX
; CE: 4883EB02 SUB RBX, 2 <<= Subtract 1, shifted past the tag bit means an immediate 2
; D2: 48D1F9 SAR RCX, 1
; D5: 480FAFCA IMUL RCX, RDX <<= Multiply
; D9: 488BD1 MOV RDX, RCX
; DC: 488BCB MOV RCX, RBX
; DF: EBDF JMP L0 <<= GOTO FUCKING START OF FUNCTION


It can do this because there isn't this low level intrusive BULLSHIT of call/cc fucking up anything that anybody might ever want to do, even though nobody in their right mind in real applications ever touches call/cc. Just like people dick around with pure functional cons list processing in Lisp academically but use actual data structures in the Real World, call/cc is just academic hackery fuckings that kids are forced to dick around with in class that nobody uses in the few cases of Real World Scheme. Yet its presence fucks over the Scheme implementors, whereas functional cons processing doesn't affect Common Lisp one way or another.

Maybe Stalin does this properly, as its docs say "3. (1.1) Tail recursion optimization is done only on self calls." which would also imply no need for continuation escape analysis, and that static constraint would allow it to compile to a JMP. But I'll leave that as an exercise for the reader, meaning I'm not going to pile into unfamiliar territory just to make a point that's already self-evident.

But in any case, tail recursion IS a GOTO to the beginning of the function. The fact that Scheme is a shitty language and needs to do laughable workarounds at the assembly level to get GOTO to work happens to obscure that primitive fundamental axiomatic fact. Or taken differently, the bullshit in Scheme means it cannot ACTUALLY perform tail recursion optimization. It still fits in a static memory footprint, but cannot actually optimize the conceptual GOTO into a real GOTO in hardware and needs to jump out and back in to perform a simple GOTO. By definition, actual tail recursion is never NOT a GOTO, regardless of how you have to make that GOTO happen, and regardless that your idiot Scheme implementors can't detect situations where the context does not need to exit to loop back.

IHBT

Name: Anonymous 2016-07-22 4:11

>>21
shit, I had some copy/paste fail in there obviously, but fuck you anyway.

Name: Anonymous 2016-07-22 4:43

>>20
The function call is effectively removed and the stack frame isn't saved
That's basically what I meant by saying optimized tail recursion is essentially a while loop. In the context of programming, pretty much the defining characteristic of recursion is that you need a number of stack frames equal to the recursion depth, since the initial function call must wait for the second instance of the function to return, and that second instance must wait for the third instance of the function to return, and so on. But with an optimized tail call, you can overwrite the stack frame and discard the old data, since when that second instance of the function finally returns, all the initial function instance needs to do is pass its result to whoever called it in the first place. And this is similar to a while loop, because everything is done in-place, on a single stack frame.

Name: Anonymous 2016-07-22 5:11

>>21
the bullshit in Scheme means it cannot ACTUALLY perform tail recursion optimization

Ignoring the disconnected nonsense you posted otherwise, I think that's a good summary of what Scheme does in this situation. Tail recursion optimization and tail call optimization are two different things. Scheme mostly just does the latter.

Name: Anonymous 2016-07-22 13:08

>>20
he isn't wrong
he is wrong

Name: Anonymous 2016-07-22 13:09

>>21
Show me a scheme compiler that can actually fucking compile, and I'll point you straight to the GOTO/JMP

just accept that you are wrong

Name: Anonymous 2016-07-22 13:11

It's really embarassing and disappointing that people here do not even understand tail recursion. I thought you guys were trolling about 'goto' because it was epic and ruins the thread but seems we've been taken over by actual idiots that know nothing.

Name: Anonymous 2016-07-22 13:12

No one there has only been one good idea to improve scheme. Nobody here even knows how programming language implementation works. Reddit tier knowledge.

Name: Anonymous 2016-07-22 13:22

No one there has only been one good idea to improve scheme.
I agree

Name: Anonymous 2016-07-22 14:09

>>29
correction: No wonder there has only been one good idea to improve scheme.

Name: Anonymous 2016-07-22 15:11

>>27
Pretty much everything is a GOTO. If statements are conditional GOTOs, while loops are if statements that jump back to the beginning of the block, for loops are while loops controlled by a counter, and function calls are while loops using malloc'd space on the stack for storing local variables and the return address.

Name: Anonymous 2016-07-22 15:40

>>31 >function calls are while loops using malloc'd space on the stack for storing local variables and the return address.
Who needs all that bloat. Use computed gotos!
http://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables
https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

Name: Anonymous 2016-07-22 15:46

>>31
stop posting you absolute retard

Name: Anonymous 2016-07-22 19:53

Get rid of call/cc, directly support the few things that people actually build with call/cc, and then you can begin to start to think about improving Scheme.

>>31
GOTO usually isn't exposed to the high level programmer. We tend to have loop constructs, switch/cond style trees, dynamic dispatch, and all sorts of actually useful abstractions that are directly applicable to what programmers do, that happen to compile down to GOTO.

What we DON'T do is give the programmer GOTO and tell them to figure out how to make it useful.

The only looping mechanism that Scheme allows is "GOTO start of function" via tail recursion, or fiddle around with mutual recursion in tail calls, which becomes a GOTO loop. The fact that you cannot retain any lexical state as with non-tail calls, but must chain through parameters, is part of the reason it's considered a GOTO.

Name: Anonymous 2016-07-22 20:50

>>34
you ruined your good post with talking to retards about goto......

Name: Anonymous 2016-07-22 22:57

>>35
GOTO is infused through all of this. It doesn't matter if it's a literal GOTO or not, the concept is exactly the same, and the lack of abstraction beyond that is a problem. The only way you can safely loop in Scheme is to perform GOTOs that don't leave stack context around. A call is a GOTO if it doesn't return, and tail calls don't return. Often it is simply a nice performance freebie that happens to give your code a hand, but having to manage making a clean break from your prior code to make sure you don't blow up your memory is low-level hackery that high level programmers shouldn't have to deal with.

Frankly, if you don't get the concept of GOTO past the literal BASIC/C/etc statement, then you're retarded.

Name: Anonymous 2016-07-22 22:59

>>36
A call is a GOTO if it doesn't return, and tail calls don't return
...return to the caller, that is.

Name: Anonymous 2016-07-22 23:28

Tail calls do return to the original caller, i.e. whoever called the first function in the first place. TCO just means you don't need to worry about returning to intermediate function instances and can instead just jump back to the original caller.

Name: Women can't program 2016-07-23 2:07

I'm really getting tired of you fucking nigger retards

Name: Anonymous 2016-07-23 5:18

>>38
You never need to worry about the caller; the caller can worry about being returned to and how to continue on from there.

But Scheme programmers need to worry about not growing the stack, ie make sure their looping function calls are actually GOTOing out.

It's sort of like red cuts vs green cuts in Prolog. Green cuts are nice little hints and optimizations you can throw in, but aren't part of the logical semantics of your program. But red cuts are actually programming artifacts that need to be treated as such. In Scheme, the back-end means of calling a function becomes a programming artifact when it comes to looping, and that's a horrible hack-built non-abstraction compared to actual looping constructs.

Name: Anonymous 2016-07-23 5:29

>>40
Since Scheme was made for Scheme designers, not for actual users of Scheme (the designers just jerk off to Scheme and don't actually work with it), the lack of looping forms doesn't bother them. Recursion is """minimally sufficient""" so fuck the users.

Name: Women can't program 2016-07-23 13:33

>>40
kill yourself retard

>>41
you can define a loop macro if you for some reason feel the need for a more limiting less flexible way to iterate

Name: Anonymous 2016-07-23 22:36

>>42
Recess is over. Stop yelling "nuh uh!" at everybody and go back to drooling in class. The shit between your ears isn't even capable of shitboard discussion. "You retard" x50, how impressive.

Name: Anonymous 2016-07-23 22:36

(this space left intentionally blank)

Name: Women can't program 2016-07-24 0:12

>>43
do you want more a detailed reply? which post?

Name: Anonymous 2016-07-24 14:38

Name: Posting too fast 2016-07-24 14:45

>>46
back to reddit

Name: Anonymous 2016-07-24 18:42

>>47
le georges-louis sage

Name: Anonymous 2016-07-25 2:47

Ok can we get back on topic now?

Name: Anonymous 2016-07-25 3:19

>>49
FUCK A DEAD NIGGER!

Name: Anonymous 2016-07-25 10:03

>>1
Apparently, it needs to optimize its goto's

Also, they should always point back to the start of the current function, and should probably be renamed

Some options:
restart()
gotostart()
recall()
headcall()
calltrailer()

Name: Anonymous 2016-07-25 11:39

Common lisp style blocks.
(block peenus (block double-peenus (return-from peenus some-value)))
Common lisp style define-macro.

Name: Anonymous 2016-07-25 12:13

>>52
You can just define that as a macro using continuations.

Name: Anonymous 2016-07-26 0:05

>>54
Continuations are like NAND blocks. Conceptually sufficient, but an utter pain in the ass to be restricted to them. The low level details of Scheme-style continuations fuck up VMs in ways that no programming environment should be subject to. It's the wrong abstraction.

Name: Anonymous 2016-07-26 0:05

(this space left intentionally blank)

Name: Anonymous 2016-07-26 0:06

>>54
You are wrong. Check my repeating digits.

Name: Anonymous 2016-07-26 1:35

>>54
I kind of agree. I'm not sure I want continuations in my dream scheme

Name: Anonymous 2016-07-26 3:48

All this new knowledge hasn't made me happy. I'm going to forget everything I know and go back to programming in Basic and 6502 and 68k Assembly on the Commodore 64 and Amiga.

Name: Anonymous 2016-07-26 3:53

>>34
Get rid of call/cc, directly support the few things that people actually build with call/cc, and then you can begin to start to think about improving Scheme.

You mean like Lua's Coroutines?

Name: Anonymous 2016-07-26 4:41

Scheme is Jewish Algol

Name: Anonymous 2016-07-27 4:17

>>60
Algol is not a LISP not even an unacceptable one

Name: Anonymous 2016-07-27 12:24

>>61
Clojure isn't a LISP either.

Name: Anonymous 2016-07-27 14:03

>>62
Clojure is a LISP (albeit an unacceptable one), as like other LISPs it is a homoiconic functional programming language with S-expression syntax and strong macro support. ALGOL has none of these features, and is better regarded as a member of the imperative/structured family like C.

Name: Anonymous 2016-07-27 19:07

>>63
Clojure is not an s-expression language, because it does not have a consistent nesting container for standard source code and parameters.

Name: Anonymous 2016-07-27 19:07

>>63
Lisp has always been imperative/structured as well.

Name: Anonymous 2016-07-27 19:07

(this space left intentionally unconsed)

Name: Anonymous 2016-07-27 19:49

>>65
LISP is structured, but not imperative. And its structure syntax is really nothing like that of the ALGOL/Pascal/C family.

Name: Anonymous 2016-07-27 21:12

>>67
How in all of the fuck is it not imperative? All of its control structures are imperative, from the very beginning it was about firing mutating operations on lists and input/output commands, and all definitions are a recipe of ordered mutations against the running VM, one at a time.

Also, fuck syntax. Semantics are the only thing that matter.

Name: Anonymous 2016-07-27 21:34

>>67
LISP is ye olde language. Maybe you meant Lisp?

Name: Anonymous 2016-07-27 21:46

>>63,67
Please don't denigrate ALGOL by associating it to C.

Name: Anonymous 2016-07-28 2:24

>>69
No, I meant LISP.

Name: Anonymous 2016-07-28 14:02

>>70
stop using such racist terminology

Name: Anonymous 2016-07-29 6:38

denigrate my prime

Name: Anonymous 2016-07-29 15:54

>>73
your prime is a nigger

Don't change these.
Name: Email:
Entire Thread Thread List