Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 516311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:43:05+00:00 2026-05-13T07:43:05+00:00

I’m trying to make sense of the example code here (below Examples). I don’t

  • 0

I’m trying to make sense of the example code here (below Examples). I don’t understand that parametrize construct. The docs for it are here, but they don’t help. What does it do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:43:06+00:00Added an answer on May 13, 2026 at 7:43 am

    parameterize is used to have values that are “dynamically scoped”. You get a parameter with make-parameter. The parameter itself behaves as a function: call it with no inputs and you get its value, call it with one value and it will set the value. For example:

    > (define p (make-parameter "blah"))
    > (p)
    "blah"
    > (p "meh")
    > (p)
    "meh"
    

    Many functions (including many primitive ones) use parameters as a way to customize their behavior. For example printf will print stuff using the port that is the value of the current-output-port parameter. Now, say that you have some function that prints something:

    > (define (foo x) (printf "the value of x is ~s\n"))
    

    You usually call this function and see something printed on the screen — but in some cases you want to use it to print something to a file or whatever. You could do this:

    (define (bar)
      (let ([old-stdout (current-output-port)])
        (current-output-port my-own-port)
        (foo some-value)
        (current-output-port old-stdout)))
    

    One problem with this is that it is tedious to do — but that’s easily solved with a macro. (In fact, PLT still has a construct that does that in some languages: fluid-let.) But there are more problems here: what happens if the call to foo results in a runtime error? This might leave the system in a bad state, where all output goes to your port (and you won’t even see a problem, since it won’t print anything). A solution for that (which fluid-let uses too) is to protect the saving/restoring of the parameter with dynamic-wind, which makes sure that if there’s an error (and more, if you know about continuations) then the value is still restored.

    So the question is what’s the point of having parameters instead of just using globals and fluid-let? There are two more problems that you cannot solve with just globals. One is what happens when you have multiple threads — in this case, setting the value temporarily will affect other threads, which may still want to print to the standard output. Parameters solve this by having a specific value per-thread. What happens is that each thread “inherits” the value from the thread that created it, and changes in one thread are visible only in that thread.

    The other problem is more subtle. Say that you have a parameter with a numeric value, and you want to do the following:

    (define (foo)
      (parameterize ([p ...whatever...])
        (foo)))
    

    In Scheme, “tail calls” are important — they are the basic tool for creating loops and much more. parameterize does some magic that allows it to change the parameter value temporarily but still preserve these tail calls. For example, in the above case, you will get an infinite loop, rather than get a stack overflow error — what happens is that each of these parameterize expressions can somehow detect when there’s an earlier parameterize that no longer needs to do its cleanup.

    Finally, parameterize actually uses two important parts of PLT to do its job: it uses thread cells to implement per-thread values, and it uses continuation marks to be able to preserve tail-calls. Each of these features is useful in itself.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.