<polarian>
oh and its not the "void" keyword, I checked that by changing it to a string, still returns void :)
<shawnw>
Use else, not #t, for the catch-all final clause to cond. This isn't Common Lisp.
<shawnw>
And for always evaluates to a void value.
<polarian>
shawnw: thanks... university teaches to always use #t though
<polarian>
what I am trying to do with the for is find the struct which matches the name passed into the function
<shawnw>
You possibly can use for/first instead.
<polarian>
is there a better way to do this? would using "contains?" with structs work?
<polarian>
ah for/first worked thanks :)
<polarian>
if you dont mind me asking, why use else instead of #t?
<bremner>
because else is idiomatic
<bremner>
meaning people are less surprised by your code
Tuplanolla has quit [Quit: Leaving.]
<polarian>
aka it makes more sense... alrighty :)
<polarian>
I guess my university just likes teaching bad habits :P
<bremner>
well, the instructor might have learned common lisp first
<shawnw>
Common Lisp allows 'otherwise' for its case syntax; they could have used that in cond too. Bunch of weirdos.
<bremner>
I guess it makes it a bit easier to catch syntax errors, since else in other places is a syntax error, while #t is just an expression
<polarian>
I seem to be having the left padding issue with racket
<polarian>
cond cond cond cond and now I am half way across the terminal...
<polarian>
with C you would just invert the condition, say "if (x == 0) return; if (x < 10) return;"
<polarian>
but racket has no break... so how do you stop all your conditions causing nested hell?
synthmeat has quit [Ping timeout: 246 seconds]
synthmeat has joined #racket
<polarian>
hit another issue google won't solve... and no way I am asking an AI, say I need to chain conditions such as two set!'s, ((set! x 5) (set! y 10)) will fail
<leah2>
use begin
<polarian>
leah2: but begin makes you jump to that line... I thought?
<polarian>
when I trailed it, it changes the entrypoint?
<leah2>
it runs all expressions inside in sequence
<polarian>
oh wait... I am blind
<polarian>
I literally had it working but too tired to even realise... I say call it a night
<polarian>
last thing, include doesn't seem to work, I declare a struct in one file, include the file, and then "unbound identifier"
<leah2>
sleep well ;)
<polarian>
thanks for the help btw
<leah2>
yw :) i have to look that up, on my phone atm
lucasta has quit [Quit: Leaving]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
skapata has quit [Read error: Connection reset by peer]
<dzoe>
polarian: Or you can be adventurous and start your procedure with (let/cc return expressions ...) and anywhere in expressions you can (return value) to make the whole expression return the value immediately.
<dzoe>
But if you have no idea how continuations work, this can lead to VERY surprising results ;-)
<dzoe>
And no, I do not suggest to use this approach generally - it's just that I've spent about a year in custom DSLs heavily using continuations for various things, so now I see them everywhere.
<polarian>
I guess LISP (and its dialects) really does open your brain up to different ways of thinking
<polarian>
instead of crutch statements, you are forced to think differently...
<polarian>
I still can't for the life of me figure out why "racket/include" doesn't let me include another rkt file containing struct and function declarations, if I reference the struct in the included file it is "unbound identifier"
<polarian>
I read the entire documentation on include, and require and neither of them answer why its not working :P
<polarian>
as far as I know, require requires it to be a module, while include is meant to be used for single/unmodularised code
<polarian>
*correct me if I am wrong*
<dzoe>
polarian: use require
<dzoe>
I never used include to be honest.
<dzoe>
Some sanboxed evaluation using custom environment - yes - but include ... never.
<polarian>
(require "somefile.rkt")
<polarian>
correct?
<dzoe>
Yup
<polarian>
it didn't work last night, but I was half asleep so lets try again
<dzoe>
And in that file you just (provide binding1 binding2 ...) whatever you want to be actually required when it is required.
<polarian>
ah I haven't done provides
<dzoe>
Or if you are lazy (provide (all-defined-out))
<dzoe>
With the usual warning about possible problems if you get back to your code in the future ;-)
<polarian>
so provide you just list the identifiers you want to be public of sorts?
<dzoe>
Kinda yeah
<polarian>
I will just read the wiki on it, thanks :)
<dzoe>
Does anyone know how Racket class system implements inherit on fields?
<dzoe>
I am working on R5RS-based class system and for method inheritance it is pretty straightforward - however for fields it seems virtually impossible to allow for set! of fields in derived classes.
<dzoe>
Although I am fine with having only "private" fields and only virtual methods everywhere (with super support), I am curious whether I am not overlooking something.
<dzoe>
And as since I started using CHICKEN for one project, part of my work is to reimplement Racket features in R5RS (with some tiny CHICKEN-specific hacks) to make my life less miserable ;-)
<polarian>
dzoe: that worked thank you :D
polarian has quit [Quit: Polarian has disappeared]
polarian has joined #racket
danse-nr3 has joined #racket
morte has joined #racket
szkl has joined #racket
FreeFull has quit [Remote host closed the connection]
pounce has quit [*.net *.split]
meimei has quit [*.net *.split]
energizer has quit [*.net *.split]
Ekho has quit [*.net *.split]
<samth>
dzoe: it really depends how you implement fields
energizer has joined #racket
meimei has joined #racket
pounce has joined #racket
Ekho has joined #racket
danse-nr3 has quit [Remote host closed the connection]
<dzoe>
samth: well, the Racket implementation exposes the fields as bindings directly in the lexical scope of the class - which is pretty neat.
<samth>
dzoe: right, it appears that way, but the `set!` is translated to a structure mutation of the record representing the object
<dzoe>
That's what I thought ;-)
<dzoe>
But in that case I have no idea how they can be used as regular bindings in expressions.
<dzoe>
Redirecting set! is (sort of) trivial even in r5rs here, however in that case the bindings themselves cannot be a simple define/let bindings...
<dzoe>
So yes, my question is more related to using the bindings in expressions - that's where I don't see an obvious way how to do it.
morte has quit [Read error: Connection reset by peer]
parai has joined #racket
<samth>
dzoe: you need identifier macros for that. but really my view is that this just all points to the folly of trying to do real work in r5rs
<dzoe>
samth: I agree - however as an exercise it is an iteresting problem. And the project in question is small and specific. For "real" work we are using Racket everywhere ...
<samth>
I guess I think if you're using chicken I would use eggs that provide fancier macro support, not just r5
skapata has joined #racket
shawnw has joined #racket
szkl has quit [Quit: Connection closed for inactivity]
Tuplanolla has joined #racket
kengruven has quit [Ping timeout: 272 seconds]
kengruven has joined #racket
chiselfuse has quit [Remote host closed the connection]