
Is there an easy way to extend an arbitrary language? For example, I want to extend #lang pollen
with my own #%top
. What’s the best way to accomplish that?
I’m following http://blog.racket-lang.org/2017/03/languages-as-dotfiles.html, but the problem is that the blog post assumes that something like scribble/reader
exists. I don’t think that kind of thing exists for pollen
.

This is a bit off-topic, but since this group probably will appreciate an example of how things can blow up, when scope rules are unclear, I’ll post it anyways. Note that the blue graph of a(x) has a local minimum at x=2.8, but the red graph of a’(x) doesn’t cross the x-axis at x=2.8.

I guess it’s because the right answer may be 1.1835, which seems more likely to be crossed on the graph (but it looks more like 1.8 or something.. weird)

I remember in math class being told that you can toss out irrelevant results somehow when you get multiple answers like that.

@sorawee you can make a module which does (require (all-from-except pollen #%top)) (provide (all-from-out pollen))

@samth You mean except-in
? . As I understand all-from-except
is for #%provide
.
Would you mind telling me exactly what I should put in my-pollen/main.rkt
? Let’s not even care about overriding #%top
. Here are my attempts that failed:
#lang racket/base
(require pollen)
(provide (all-from-out pollen))
fails on the program
#lang my-pollen
abc
because of the error collection not found for module path: my-pollen/lang/reader
.
So I do need to create a reader.
#lang racket/base
(require pollen)
(provide (all-from-out pollen))
(module* reader syntax/module-reader
my-pollen
#:read p:read
#:read-syntax p:read-syntax
(require (prefix-in p: pollen)))
fails because p:read-syntax
is unbound.

you probably need to require whatever provides pollen’s read-syntax etc

which i guess isn’t pollen

you could probably do the same thing that pollen
does, which is: (module reader "private/reader-base.rkt"
default-mode-auto)

of course you’d need to change that language to pollen/private/reader-base

@jerome.martin.dev The problem is that the x in the definition of y has global scope, but in am(x) the differentiation happens with respect to a “local x”. If one enter am(z) then the result returned is 1/(x–2)+3 (nope that’s not a typo). am(z) = d/dz( am(z) ) = d/dz ( z*y) = y = 1/(x–2)+3. Sigh.

oh

Thanks! This works :slightly_smiling_face:

so that’s definitely a programming issue :stuck_out_tongue:

maths are always right, it’s what they say

It’s not exactly easy to explain in a high school math class …

That x is not always x.

First teach them about Gödel, and then it’ll all be clear :troll:

I think it’s the study they did at MIT: They asked their students at the beginning of classes something like: a = 10;
b = 20;
a = b;
What is the value of a and b?
About 40% got it right, the others did not understand. Then at the end of the semester, they ask the same question again, and get… exactly the same results.

I don’t remember if it was MIT or Harvard, or some other big uni

They realized two things: a lot of people are not good at “doing the computer in their heads”, and that maybe the way they teach IT was not that good to begin with

I think the fact that we tend to program with this idea of a state machine in our head is also part of the problem. We were told the correct result was that “a becomes the value of b”. But in declarative or functional languages, the answer “error: illegal equality” might be perfectly acceptable.

so in the end, the people who answer “I don’t know” or “It’s impossible” are as legitimate as the 40% who answer “a = b = 20”

The state machine is only a limit from the Turing/Von Neumann architecture we use as computers. Mathematics don’t care about that and can have x be whatever the reader has in her mind.

But i think I’m slowly losing track there.. I’ll see myself out and leave you dealing with the philosophical repercussions :stuck_out_tongue:

You may be thinking of http://www.eis.mdx.ac.uk/research/PhDArea/saeed/paper1.pdf

Yes, thanks for bringing the reference!

@jerome.martin.dev have you seen https://cs.brown.edu/~sk/Publications/Papers/Published/kf-prog-paradigms-and-beyond/paper.pdf ?

@sorawee No, but I’m definitely reading this right now!

Is there a way to change what object-name
produces on classes, similar to how procedure-rename
works on procedures?

@robby The documentation for front-end/finished-complete-program
says: “It must return without raising an error, or else the DrRacket window will be wedged.”

What does it mean fo a window to be wedged
?

Generic badness

Undefined behavior

(But highly likely to be unresponsive and highly unlikely to produce nasal demons)

Ah, okay, thanks. :slightly_smiling_face:

Out of pure curiosity, did you choose that word, or is it a term from somewhere else?

(I couldn’t find it after a quick search, but I could be searching for the wrong thing. :wink: )

Dunno

That’s what it means to me

lol…thanks. :slightly_smiling_face:

hmm … american heritage dictionary says: (1) having the shape of a wedge; thick at one end tapered at another (2) stuck; jammed

@leif maybe the docs should say “If this method raises an exception, the behavior of the DrRacket window is undefined.”

Mmm….maybe? Although honestly, now that robby explained it to me, wedged seems pretty accurate here.

Although I would probably say, the behavior is undefined, but likely the window will be frozen.

Or something like that?

I think it would be good to keep the more specific meaning

Probalby my use of undefined is because I’m watching jesse type C++ code :slightly_smiling_face:

Agreed.

happy to use a different word

“wedged” is pretty common for this situation in my experience

it’s a fun word :slightly_smiling_face:

@samth Interesting, may I ask where?

(Also I 100% agree, the word is pretty awesome.)

ok (I was confused by wedged)

I’ve heard unresponsive, frozen, stuck, but this is the first time I’ve heard of wedged. :smile:


Ah, okay.

So its a cooperative multitasking specific term.

That makes a lot of sense. Thanks @samth

@robby & @samth (@ben just suggested that we add a margin note linking or explaining the definition of wedged, since its apparently fallen out of modern parlance. Would you be opposed to that?)

Personally I am 100% on side wedged here. But I also think linking to a definition isn’t a bad idea. :slightly_smiling_face:

I don’t think this word is that unknown

and if it were, we should change it

I don’t think it is in common usage for people in general, but I think it is for people who work with computers that get wedged a lot

:slightly_smiling_face:

FWIW, I asked about 10 people in physical space (in and around the PL labs), and none of us had heard the term before. :slightly_smiling_face:

But, I could have easily just asked the wrong 10 people. :slightly_smiling_face:

I mean, I’ve certainly used it in this context, often

FWIW, I didn’t have trouble inferring the meaning of the word “wedged” in a computing context since I was familiar with it in a non-computing context, such as “the door is wedged”. But maybe that isn’t a common use.

While I also inferred the general meaning of the word, I had never heard of it used in computer science context. I found it enlightening that the more nuanced meaning is related to cooperative multitasking which makes sense since it is dependent on tasks behaving cooperatively and keeping things moving smoothly without capturing and holding on the control of the machine.

Hello! :wave: There doesn’t seem to be a Pollen-specific channel, so I’ll ask here: I’ve been building a multilingual website using Pollen, and haven’t figured out a good method to “isolate” or “separate” pagetrees by language. For example, I’d like to be able to say:
#lang pollen
about.html
◊foo.html{
bar.html
baz.html
etc.html
}
--- separator ---
accueil.html
◊foo.html{
bar.html
baz.html
etc.html
}
For now my solution has been to organize each language as it’s own pollen document. This works, but it’s really repetitive and seems like overkill. If anyone has ideas or knows of simpler ways to do this, I’d be very thankful to hear them. I am new to Racket and really having fun, thanks to everyone involved developing and supporting it!

I’m building a multilingual website using Pollen too! (English and Thai)
Here’s my idea: use only one file per one document, but for each document, do something like this:
@english{<my english content here>}
@thai{<my thai content here>}
@english
and @thai
should create a div
with an identifiable class/id.
Then in the template, include a JavaScript that hides one language (sth like document.getElementById('thai-lang').style.display = "none";
). And then there might be a button that lets you switch a language, etc. It’s totally up to you how you want to design this.