Discussion:
[racket] TLS "atom?" definition for Scheme does not work in DrRacket
Rufus
2015-03-03 20:16:26 UTC
Permalink
On page 10 of TLS there is a note defining the "atom?" function for the
reader to use w/Lisp or Scheme. The definition for Scheme (which is the
most likely one to use for DrR) does not work. To fix one must remove
the parens that open at the "and". Apparently the DrR
compiler/interpreter sees them as an attempt to invoke a function and
that's not correct here. I don't know if other Lisp versions would find
the code in the book correct.

In the text below XXX shows where I removed a set of parens to make the
function work.

(define atom? (lambda (arg1)
XXX and (not (pair? arg1))
(not (null? arg1))
XXX
)
)


Rufus
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-03-03 20:21:17 UTC
Permalink
This works for me:
(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
Post by Rufus
On page 10 of TLS there is a note defining the "atom?" function for the
reader to use w/Lisp or Scheme. The definition for Scheme (which is the
most likely one to use for DrR) does not work. To fix one must remove
the parens that open at the "and". Apparently the DrR
compiler/interpreter sees them as an attempt to invoke a function and
that's not correct here. I don't know if other Lisp versions would find
the code in the book correct.
In the text below XXX shows where I removed a set of parens to make the
function work.
(define atom? (lambda (arg1)
XXX and (not (pair? arg1))
(not (null? arg1))
XXX
)
)
Rufus
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Rufus
2015-03-03 20:50:02 UTC
Permalink
Alexander

Well, in fact, I thought it worked for me, too. And then it stopped
working; DrR threw an "application: not a procedure;" error saying it
was given a null list instead of an application. Removing the parens got
it working again.

Now that just doesn't make any sense at all but that's what I seem to
have observed. Looking at some StackOverflow responses on similar errors
I found that parens in certain positions are interpreted as invoking a
function regardless of what may in fact be inside the parens. IOW, extra
parens will trigger that error. I believe that initially it was working.
Perhaps I had run it in the executable pane instead of loading and
running the defs file? If I have more time somewhere along, I'll try to
recreate things.

When I first defined atom? I was using a very small definitions file
with the " #lang racket" spec; IIRC atom? worked. After trying BSL and
then going back to using the #lang spec and adding some comments and the
list of variable defs - it didn't work.

At the moment I don't have any good ideas, except to chg the code to get
it to work and proceed.

Rufus
Post by Rufus
(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
Post by Rufus
On page 10 of TLS there is a note defining the "atom?" function for the
reader to use w/Lisp or Scheme. The definition for Scheme (which is the
most likely one to use for DrR) does not work. To fix one must remove
the parens that open at the "and". Apparently the DrR
compiler/interpreter sees them as an attempt to invoke a function and
that's not correct here. I don't know if other Lisp versions would find
the code in the book correct.
In the text below XXX shows where I removed a set of parens to make the
function work.
(define atom? (lambda (arg1)
XXX and (not (pair? arg1))
(not (null? arg1))
XXX
)
)
Rufus
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-03-03 21:02:27 UTC
Permalink
Well that’s weird. And after it stopped working with the parens, then it worked without them?
It doesn’t do that for me:
(define atom? (lambda (arg1)
and (not (pair? arg1))
(not (null? arg1))))
;. and: bad syntax in: and

Is there a specific way to reproduce it?
Post by Rufus
Alexander
Well, in fact, I thought it worked for me, too. And then it stopped
working; DrR threw an "application: not a procedure;" error saying it
was given a null list instead of an application. Removing the parens got
it working again.
Now that just doesn't make any sense at all but that's what I seem to
have observed. Looking at some StackOverflow responses on similar errors
I found that parens in certain positions are interpreted as invoking a
function regardless of what may in fact be inside the parens. IOW, extra
parens will trigger that error. I believe that initially it was working.
Perhaps I had run it in the executable pane instead of loading and
running the defs file? If I have more time somewhere along, I'll try to
recreate things.
When I first defined atom? I was using a very small definitions file
with the " #lang racket" spec; IIRC atom? worked. After trying BSL and
then going back to using the #lang spec and adding some comments and the
list of variable defs - it didn't work.
At the moment I don't have any good ideas, except to chg the code to get
it to work and proceed.
Rufus
Post by Rufus
(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
Post by Rufus
On page 10 of TLS there is a note defining the "atom?" function for the
reader to use w/Lisp or Scheme. The definition for Scheme (which is the
most likely one to use for DrR) does not work. To fix one must remove
the parens that open at the "and". Apparently the DrR
compiler/interpreter sees them as an attempt to invoke a function and
that's not correct here. I don't know if other Lisp versions would find
the code in the book correct.
In the text below XXX shows where I removed a set of parens to make the
function work.
(define atom? (lambda (arg1)
XXX and (not (pair? arg1))
(not (null? arg1))
XXX
)
)
Rufus
____________________
http://lists.racket-lang.org/users
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Matthias Felleisen
2015-03-03 21:20:50 UTC
Permalink
Use BSL with List Abbreviation.
Post by Rufus
Alexander
Well, in fact, I thought it worked for me, too. And then it stopped
working; DrR threw an "application: not a procedure;" error saying it
was given a null list instead of an application. Removing the parens got
it working again.
Now that just doesn't make any sense at all but that's what I seem to
have observed. Looking at some StackOverflow responses on similar errors
I found that parens in certain positions are interpreted as invoking a
function regardless of what may in fact be inside the parens. IOW, extra
parens will trigger that error. I believe that initially it was working.
Perhaps I had run it in the executable pane instead of loading and
running the defs file? If I have more time somewhere along, I'll try to
recreate things.
When I first defined atom? I was using a very small definitions file
with the " #lang racket" spec; IIRC atom? worked. After trying BSL and
then going back to using the #lang spec and adding some comments and the
list of variable defs - it didn't work.
At the moment I don't have any good ideas, except to chg the code to get
it to work and proceed.
Rufus
Post by Rufus
(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
Post by Rufus
On page 10 of TLS there is a note defining the "atom?" function for the
reader to use w/Lisp or Scheme. The definition for Scheme (which is the
most likely one to use for DrR) does not work. To fix one must remove
the parens that open at the "and". Apparently the DrR
compiler/interpreter sees them as an attempt to invoke a function and
that's not correct here. I don't know if other Lisp versions would find
the code in the book correct.
In the text below XXX shows where I removed a set of parens to make the
function work.
(define atom? (lambda (arg1)
XXX and (not (pair? arg1))
(not (null? arg1))
XXX
)
)
Rufus
____________________
http://lists.racket-lang.org/users
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Rufus
2015-03-03 23:34:53 UTC
Permalink
Matthias

My goodness. There seems to be some strangeness here.

1) When using "#lang racket" and running the defs file,
- Atom? is defined regardless of whether the "AND clause
get parens ie. "Atom?" entered on the interactive pane
(then hit Enter) tells us it's a proc regardless the
way it's defined.
- (Atom? x) (where x is defined) throws an error if its
definition used parens around the AND clause but works
as expected w/out them.

2) When using BSL-lists:
- Atom? can be defined on the interactive pane using parens
around the AND clause the way it appears in TLS; it
works as expected.
- Atom? cannot be defined on the i-pane w/out the parens
around the AND clause because it throws a syntax error.

3) As an aside: Under BSL-lists, I cannot get any code in the
defs file to run. At least none of the definitions exist
after I load the file and click "Run". So now it comes back
to me exactly what led me to use the "#lang racket" spec:
The code in the defs file was not getting executed when I
used the BSL-lists, loaded the defs file and clicked Run.

GOT IT! The toggle for the atom? weirdness is the (define and '...)
included in the variable defs I made up from the TLS examples. Ie. a
reserved word problem. Doesn't know the exact mechanism but nottt a
problem. <g>

Still unclear on why BSL-lists apparently won't run a defs file. Another
day...

Rufus
Post by Matthias Felleisen
Use BSL with List Abbreviation.
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-03-04 00:44:58 UTC
Permalink
Post by Rufus
Matthias
My goodness. There seems to be some strangeness here.
1) When using "#lang racket" and running the defs file,
- Atom? is defined regardless of whether the "AND clause
get parens ie. "Atom?" entered on the interactive pane
(then hit Enter) tells us it's a proc regardless the
way it's defined.
- (Atom? x) (where x is defined) throws an error if its
definition used parens around the AND clause but works
as expected w/out them.
When you checked that it “works as expected,” did you check that it returns false for non-empty lists?
Post by Rufus
- Atom? can be defined on the interactive pane using parens
around the AND clause the way it appears in TLS; it
works as expected.
- Atom? cannot be defined on the i-pane w/out the parens
around the AND clause because it throws a syntax error.
3) As an aside: Under BSL-lists, I cannot get any code in the
defs file to run. At least none of the definitions exist
after I load the file and click "Run". So now it comes back
The code in the defs file was not getting executed when I
used the BSL-lists, loaded the defs file and clicked Run.
GOT IT! The toggle for the atom? weirdness is the (define and '...)
included in the variable defs I made up from the TLS examples. Ie. a
reserved word problem.
One of the things I really like about DrRacket is that it can draw arrows from an identifier to its definition.
In the file with the (define and ‘…), when you hover over the and in the atom? definition,
does it show an arrow pointing to the (define and ‘…) ?
Post by Rufus
Doesn't know the exact mechanism but nottt a
problem. <g>
Still unclear on why BSL-lists apparently won't run a defs file. Another
day…
BSL+list-abbrevs doesn’t let you re-define and; Is that the reason?



____________________
Racket Users list:
http://lists.racket-lang.org/users
Rufus
2015-03-04 03:28:58 UTC
Permalink
Alexander
Post by Alexander D. Knauth
arrows
That's how I found the problem, although I had to chase it down off the
bottom of the pane. Somebody did a neat good thing there.
Post by Alexander D. Knauth
BSL+list
It apparently doesn't run the defs _at all_. The interactive pane will
not recognize _any_ of the variables or functions that appear to be
defined in the definition pane and should form the environment (or scope
or whatever the correct word) after I click on the "Run" button. And I
don't see any error msg's anywhere. I'm probably missing something
simple and dumb here like the reserved word problem; but so far no light
bulbs...

And btw thanks all for your help and suggestions.


Rufus
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexis King
2015-03-04 03:33:23 UTC
Permalink
Post by Rufus
That's how I found the problem, although I had to chase it down off the
bottom of the pane.
If the arrow goes off-screen, you can right-click the identifier and select “Jump to Binding Occurrence” to automatically scroll to where the identifier is bound. You can also select “Tack/Untack Arrows” to make the arrows persist even after you move the cursor off the identifier.

Definitely a helpful feature overall.
____________________
Racket
Rufus
2015-03-04 03:39:55 UTC
Permalink
Aha! Eureka. <g>

Thanks

I'm just starting this odyssey. The main goal is to wrap my head around
OOP and recursive concepts and hopefully I can avoid any more language
issues for a while and get through TLS. Although it doesn't hurt _that_
much to get reacquainted w/how sneaky syntax and programming interfaces
can be and how dumb blind I can get. <g>


Rufus
Post by Alexis King
Post by Rufus
That's how I found the problem, although I had to chase it down off the
bottom of the pane.
If the arrow goes off-screen, you can right-click the identifier and select “Jump to Binding Occurrence” to automatically scroll to where the identifier is bound. You can also select “Tack/Untack Arrows” to make the arrows persist even after you move the cursor off the identifier.
Definitely a helpful feature overall.
____________________
Racket Users list:
http://lists.racket-lan
Daniel Feltey
2015-03-04 03:37:58 UTC
Permalink
Post by Rufus
It apparently doesn't run the defs _at all_. The interactive pane will
not recognize _any_ of the variables or functions that appear to be
defined in the definition pane and should form the environment (or scope
or whatever the correct word) after I click on the "Run" button. And I
don't see any error msg's anywhere. I'm probably missing something
simple and dumb here like the reserved word problem; but so far no light
bulbs...
This is certainly not the expected behavior of any of the teaching languages. You say that none of the definitions seem to be recognized in the interactions window after you click the run button? Does this mean that when you try to reference a defined value you get an error? Or what exactly is happening when you try to use one of your definitions in the interactions window?

Dan
____________________
Racket Users list:
http://lists.racket-lang.org/users
Rufus
2015-03-04 03:47:49 UTC
Permalink
Daniel


Thanks for your interest.

Any reference to any definition (supposed) from the I-pane throws an
"undefined" error; there are no apparent errors when click Run
immediately after I load the definition file. I'm not going to worry
about it too much at this point. It's probably a simple noobie problem
and my main thrust is to get through TLS as effectively (maybe not as
fast) as possible and I think the "racket" spec will let me do that.

If I get sand-bagged by TLS I'll probably try setting up a new
definitions file with only one or two lines and seeing what I can promote.


Rufus
Post by Daniel Feltey
Post by Rufus
It apparently doesn't run the defs _at all_. The interactive pane will
not recognize _any_ of the variables or functions that appear to be
defined in the definition pane and should form the environment (or scope
or whatever the correct word) after I click on the "Run" button. And I
don't see any error msg's anywhere. I'm probably missing something
simple and dumb here like the reserved word problem; but so far no light
bulbs...
This is certainly not the expected behavior of any of the teaching languages. You say that none of the definitions seem to be recognized in the interactions window after you click the run button? Does this mean that when you try to reference a defined value you get an error? Or what exactly is happening when you try to use one of your definitions in the interactions window?
Dan
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-03-04 03:55:50 UTC
Permalink
When I run this program:
(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
(define and 'dummy)
It highlights the `and` in the `(define and ‘dummy)`, and gives me this error message:
define: expected a variable name, or a function name and its variables (in parentheses), but found a keyword

Do you not get an error message like that? If you don’t it looks like a bug.
Or could there possibly be some setting that turns off error messages or something?
Post by Rufus
Daniel
Thanks for your interest.
Any reference to any definition (supposed) from the I-pane throws an
"undefined" error; there are no apparent errors when click Run
immediately after I load the definition file. I'm not going to worry
about it too much at this point. It's probably a simple noobie problem
and my main thrust is to get through TLS as effectively (maybe not as
fast) as possible and I think the "racket" spec will let me do that.
If I get sand-bagged by TLS I'll probably try setting up a new
definitions file with only one or two lines and seeing what I can promote.
Rufus
Post by Daniel Feltey
Post by Rufus
It apparently doesn't run the defs _at all_. The interactive pane will
not recognize _any_ of the variables or functions that appear to be
defined in the definition pane and should form the environment (or scope
or whatever the correct word) after I click on the "Run" button. And I
don't see any error msg's anywhere. I'm probably missing something
simple and dumb here like the reserved word problem; but so far no light
bulbs...
This is certainly not the expected behavior of any of the teaching languages. You say that none of the definitions seem to be recognized in the interactions window after you click the run button? Does this mean that when you try to reference a defined value you get an error? Or what exactly is happening when you try to use one of your definitions in the interactions window?
Dan
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Daniel Feltey
2015-03-04 04:43:31 UTC
Permalink
Just one more question, for clarification. Are you using the `lambda` form in BSL? I ask because several examples in this thread have been using `lambda`, but I don't think that lambda expressions are actually valid in either of the beginning student languages, though I would expect you to receive an error about lambda being undefined in that situation.

Dan
____________________
Racket Users list:
http://lists.racket-lang.org/users
Daniel Feltey
2015-03-04 05:09:04 UTC
Permalink
Post by Daniel Feltey
Just one more question, for clarification. Are you using the `lambda` form in BSL? I ask because several examples in this thread have been using `lambda`, but I
don't think that lambda expressions are actually valid in either of the beginning student languages, though I would expect you to receive an error about lambda
being undefined in that situation.
Turns out I'm wrong, I'd never tried to use lambda in BSL before, but it should work.

Dan
____________________
Racket Users list:
http://lists.racket-lang.org/users
Matthias Felleisen
2015-03-04 13:32:39 UTC
Permalink
All of this should work out of the box, w/o any problem.

1. Please report on the following experiment. In the Definitions pane, type

(define rufus 0)

2. Click Run

3. In the Interactions pane, type
rufus
4. Please report the response of DrRacket.
____________________
Racket Users list:
http://lists.racket-lang.org/users
Rufus
2015-03-04 18:18:41 UTC
Permalink
To All

Using BSL-Lists:

Matt't basic test works.

(define rufus 0)

Run, then type and execute "rufus" in the I-pane which displays 0



If I then add Alexander's example define so the def file appears as follows:
---------
(define rufus 0)

(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
-------------

and hit Run I get an error in the I-pane:

"pair?; this function is not defined".


OK, so the BSL-Lists doesn't have that function. Then when I again type
"rufus"/Enter in the I-pane I get an error "rufus; this variable is not
defined"

So it appears the Run procedure deletes the existing environment before
running the defs file and if it finds any error in the defs file it does
not run _anything_ from that file. So "Run" will leave an empty
environment (right word?) if there is any error in the defs file.

On that note. It seems like the problems I've had relate directly to my
leaving noobie errors in the defs file. My confusion about how the defs
file code is Run - thinking that after a Run that throws and error
either the old environment (from the last successful Run) would remain
intact AND/OR that those lines which evaluate correctly in the new file
would be run despite some errors on other lines in that particular file
- slowed my understanding.

I believe that I do have a defs file w/errors which, on Run, does not
cause an error to display in the I-panealthough it does delete the
environment. I will try to recreate it this afternoon or evening.

As a last thought it still appears that the "#lang racket" yields better
effect than the BSL-Lists when trying follow through the TLS because
some functions shown in the TLS notes aimed at making examples and
exercises work in Scheme (eg. pair?) are not defined in the BSL-Lists.
Matt, I'm pretty sure you have reasons for recommending the BSL-Lists so
maybe I'm missing something else?

Thank you all.

Rufus

____________________
Racket Users list:
http://lists.racket-lang.org/users
Matthias Felleisen
2015-03-04 21:11:37 UTC
Permalink
Post by Rufus
To All
Matt't basic test works.
(define rufus 0)
Run, then type and execute "rufus" in the I-pane which displays 0
---------
(define rufus 0)
(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
-------------
"pair?; this function is not defined".
It is called cons? not pair? because BSL and friends restrict it to list construction, like TLL.
Post by Rufus
OK, so the BSL-Lists doesn't have that function. Then when I again type
"rufus"/Enter in the I-pane I get an error "rufus; this variable is not
defined"
When you have an error in a program, you get no interactions. You'd never know what these interactions really mean in the presence of an error in your definitions.

0 == 1
Post by Rufus
So it appears the Run procedure deletes the existing environment before
running the defs file and if it finds any error in the defs file it does
not run _anything_ from that file. So "Run" will leave an empty
environment (right word?) if there is any error in the defs file.
Yes.
Post by Rufus
On that note. It seems like the problems I've had relate directly to my
leaving noobie errors in the defs file. My confusion about how the defs
file code is Run - thinking that after a Run that throws and error
either the old environment (from the last successful Run) would remain
intact AND/OR that those lines which evaluate correctly in the new file
would be run despite some errors on other lines in that particular file
- slowed my understanding.
I believe that I do have a defs file w/errors which, on Run, does not
cause an error to display in the I-panealthough it does delete the
environment. I will try to recreate it this afternoon or evening.
As a last thought it still appears that the "#lang racket" yields better
effect than the BSL-Lists when trying follow through the TLS because
some functions shown in the TLS notes aimed at making examples and
exercises work in Scheme (eg. pair?) are not defined in the BSL-Lists.
Matt, I'm pretty sure you have reasons for recommending the BSL-Lists so
maybe I'm missing something else?
Thank you all.
Rufus
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-03-04 22:17:10 UTC
Permalink
Post by Rufus
---------
(define rufus 0)
(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
-------------
"pair?; this function is not defined”.
When you include this:
(define and ‘dummy)
Do you get:
define: expected a variable name, or a function name and its variables (in parentheses), but found a keyword
instead of the `pair?` error?


____________________
Racket Users list:
http://lists.racket-lang.org/users
Rufus
2015-03-05 05:21:12 UTC
Permalink
Alex

Yes, that is what happens. (with BSL) But if I remove the erroneous
(define and...) then it again flags pair? as "function not defined". I
think maybe it only prints one error msg, the last one found.

Sorry for the delay. I am rebuilding the laundry room here at my
sister's house during the day and now I'm trying to read up on the
evolution of program languages - I find that getting a handle on how/why
people did things helps me a lot to actually understand the concepts and
methods we have arrived at today. And I need all the help I can get. <g>
It's 30 yrs since I touched a line of code and I was never into the
theory stuff anyway.

Regards

Rufus
Post by Alexander D. Knauth
Post by Rufus
---------
(define rufus 0)
(define atom? (lambda (arg1)
(and (not (pair? arg1))
(not (null? arg1)))))
-------------
"pair?; this function is not defined”.
(define and ‘dummy)
define: expected a variable name, or a function name and its variables (in parentheses), but found a keyword
instead of the `pair?` error?
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-03-05 12:31:03 UTC
Permalink
Post by Rufus
Alex
Yes, that is what happens. (with BSL)
Ok, does it show that (or a similar message about not being able to re-define add1)
for your original program with BSL?
Post by Rufus
But if I remove the erroneous
(define and...) then it again flags pair? as "function not defined". I
think maybe it only prints one error msg, the last one found.
For this:
(pair? #f)
(define and 'dummy)
It reports the and error, but for this:
(define and 'dummy)
(pair? #f)
It also reports the and error.
The and error is found and reported first because it checks that definitions
are valid before it checks that functions like pair? exist.
If that weren’t the case mutual recursion couldn't work the way it does
without needing foreword declarations. (I think)



____________________
Racket Users list:
http://lists.racket-lang.org/users
Rufus
2015-03-05 22:16:29 UTC
Permalink
Alex
[racket processes variable definitions first, then functions]
Got it.
Ok, does it show that (or a similar message about not being able to re-define add1)
for your original program with BSL?
...
If I run the add1 definition, regardless I place it above or below the
definition of atom?, Racket flags it w/a "...defined previously" error;
when it does this it ignores the pair? problem in the atom? defintion.
If I remove the unneeded add1 def, it then gives a "pair?... not
defined" error for the atom? definition.

So Racket does variable defs first, then functions and checks for
"previously defined" before trying to create any new functions. I guess
this means that we cannot override existing function definitions in
Racket? OK by me. <g>

I think in Javascript and maybe others one could just redefine right
over the top of "inherited" stuff. But then that's probably
apples/oranges and I began Racket b4 really learning much JS. JS seems
to do pretty much whatever it wants, although D. Crockford has provided
a lot of "good-practice" forms that look to make it civilized. JS is
what actually got me looking at code again: It appears I need it to mess
w/some really annoying bank websites that require 6, up to 20 or so,
clicks to download images of your paper transactions. Each transaction,
that is. But I need to learn modern concepts that weren't common
practice when I left IT in the mid '80s. Crockford recommended TLS most
highly and after going cross-eyed pencilling intermediate answers I
decided I might as well just code the stuff. The rest is history...

I have to say, Racket looks _lovely_ compared to most of the development
options I've found in the last few weeks. And while I don't think I'd
actually try to _kiss_ the authors, I gotta say the documentation is
fantastic. Better than anything I've seen anywhere.
'
Rufus
____________________
Racket Users list:
http://lists.racket-lang.org/users
Alexander D. Knauth
2015-03-05 22:33:54 UTC
Permalink
Post by Rufus
So Racket does variable defs first, then functions and checks for
"previously defined" before trying to create any new functions. I guess
this means that we cannot override existing function definitions in
Racket? OK by me. <g>
Well, you sometimes can in racket, but not in BSL.

____________________
Racket Users list:
http://lists.racket-lang.org/users
Matthias Felleisen
2015-03-12 20:20:48 UTC
Permalink
Post by Rufus
Alex
[racket processes variable definitions first, then functions]
Got it.
That's not true. When you evaluate a definitions area,
you evaluate a module body and that process proceeds
top to bottom for Racket definitions and expressions.

In *SL, check-* tests are lifted to the very end of
the module so that students can specify test properly.

Keep in mind that 'value' means number, string, lambda,
etc. And also keep in mind that

(define (f x) ... x ...)

is short for

(define f (lambda (x) ... x ...))

The evaluator stops when it encounters an error. The
interactions are will not know the defined (or imported)
names then.

Can Racket programs redefine variables then? Yes. Some.
That's a careful balancing act.
Post by Rufus
Ok, does it show that (or a similar message about not being able to re-define add1)
for your original program with BSL?
...
If I run the add1 definition, regardless I place it above or below the
definition of atom?, Racket flags it w/a "...defined previously" error;
when it does this it ignores the pair? problem in the atom? defintion.
If I remove the unneeded add1 def, it then gives a "pair?... not
defined" error for the atom? definition.
So Racket does variable defs first, then functions and checks for
"previously defined" before trying to create any new functions. I guess
this means that we cannot override existing function definitions in
Racket? OK by me. <g>
I think in Javascript and maybe others one could just redefine right
over the top of "inherited" stuff. But then that's probably
apples/oranges and I began Racket b4 really learning much JS. JS seems
to do pretty much whatever it wants, although D. Crockford has provided
a lot of "good-practice" forms that look to make it civilized. JS is
what actually got me looking at code again: It appears I need it to mess
w/some really annoying bank websites that require 6, up to 20 or so,
clicks to download images of your paper transactions. Each transaction,
that is. But I need to learn modern concepts that weren't common
practice when I left IT in the mid '80s. Crockford recommended TLS most
highly and after going cross-eyed pencilling intermediate answers I
decided I might as well just code the stuff. The rest is history...
I have to say, Racket looks _lovely_ compared to most of the development
options I've found in the last few weeks. And while I don't think I'd
actually try to _kiss_ the authors, I gotta say the documentation is
fantastic. Better than anything I've seen anywhere.
'
Rufus
____________________
http://lists.racket-lang.org/users
____________________
Racket Users list:
http://lists.racket-lang.org/users

Loading...