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 3332276
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:40:15+00:00 2026-05-17T23:40:15+00:00

Lately I have been interested in better understanding the optimizations done by compiler back-ends.

  • 0

Lately I have been interested in better understanding the optimizations done by compiler back-ends. I thought that using Mathematica to explore this might be helpful because it makes creating, displaying and manipulating syntax trees pretty easy.

I thought I would start simple and look at constant propagation. So I wrote a simple function and tried to look at the syntax tree.

f2[x_, y_] := Module[{temp1},
  temp1 = 5;
  Return[(x + temp1)*y];
  ]
FullForm[f2]

The result of FullForm[f2], however, was just f2. I know that the right hand side of this expression has to be stored somewhere in Mathematica, so my question is where is it and is it possible to modify it after creating this rule using the SetDelayed operator “:=”?

In the mean time I have discovered that I can use the Function symbol to achieve what I am aiming for, but I would still like to understand what Mathematica is doing a little better.

f1 = Function[{x, y}, Module[{temp1},
   temp1 = 5;
   Return[(x + temp1)*y]
   ]
  ]
TreeForm[f1]

alt text

  • 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-17T23:40:16+00:00Added an answer on May 17, 2026 at 11:40 pm

    Set and SetDelayed definitions with patterns produce so-called down-value definitions that can be accessed with DownValues:

    In[98]:= DownValues[f2]
    Out[98]= {HoldPattern[f2[x_, y_]] :> 
      Module[{temp1}, temp1 = 5; Return[(x + temp1) y];]}
    

    You can even assign back to DownValues[f2]:

    In[103]:= 
    DownValues[
      f2] = {HoldPattern[f2[x_, y_]] :> 
       Module[{temp1}, temp1 = 1234; Return[(x + temp1) y]]};
    
    
    In[104]:= f2[1, 2]
    Out[104]= 2470
    

    Simple assignments produce own-value definitions that can be accessed and manipulated with OwnValues:

    In[107]:= g=7;
    
    In[108]:= OwnValues[g]
    Out[108]= {HoldPattern[g]:>7}
    

    Here’s a tutorial with more information about value lists.

    HTH!

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

Sidebar

Related Questions

So lately I have been working on writing a simple compiler to better understand
I have been trying to learn more about lambda expressions lately, and thought of
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
What java GUI layout manager does everyone use? Lately, I have been using MigLayout
So lately I have been toying around with how Mathematica's pattern matching and term
Lately I have been finding that some of the ColdFusion applications on my production
My background is primarily as a Java Developer, but lately I have been doing
I have been researching and playing with functional programming lately, solely to broaden my
I have been thinking quite a bit here lately about screen scraping and what
I have been getting a number of attacks on my website lately, with a

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.