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

  • SEARCH
  • Home
  • 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 8742405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:29:39+00:00 2026-06-13T11:29:39+00:00

This question prompted the following question: Is there a way to view the special

  • 0

This question prompted the following question: Is there a way to view the special primitive functions that are in the call stack?

For example, create a function that returns the call stack on exit:

myFun <- function(obj){
  on.exit(print(sys.calls()))
  return(obj)
}

Calling this function and assigning its result to an object using assign avoids using special primitive functions:

> assign("myObj",myFun(4))
[[1]]
assign("myObj", myFun(4))

[[2]]
myFun(4)

But using the assignment operator, this gets left out of the stack

> `<-`(myObj, myFun(6))
[[1]]
myFun(6)

Granted, it might not be all that common to want to see the assignment operator in the call stack, but other functions such as rep and log also get hidden

  • 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-06-13T11:29:40+00:00Added an answer on June 13, 2026 at 11:29 am

    I don’t think there’s any way to access calls to primitive functions via the call stack. Here is why.

    When a “typical” R function is evaluated:

    1. The supplied arguments are matched to the formal arguments.
    2. A new environment (with a pointer to its enclosing environment) is created, and the formal arguments are assigned into it.
    3. The body of the function is evaluated in the newly created environment.

    The chain of enclosing environments that is built up when function calls are nested within one another is the “call stack” or “frame stack” to which sys.calls(), sys.frames() and the like provide some access.

    My strong suspicion is that calls to primitive functions don’t appear on the call stack because no R-side environment is created during their evaluation. No environment is created, so no environment appears on the call stack.

    For some more insight, here’s how John Chambers describes the evaluation of primitive functions on page 464 of Software for Data Analysis:

    Evaluation of a call to one of these functions starts off in the usual way,
    but when the evaluator discovers that the function object is a primitive
    rather than a function defined in R, it branches to an entirely different
    computation. The object only appears to be a function object with formal
    arguments and a call to the function .Primitive() with a string argument.
    In reality, it essentially contains only an index into a table that is part of
    the C code implementing the core of R. The entry of the table identifies a
    C routine in the core that is responsible for evaluating calls to this specific
    primitive. The evaluator will transfer control to that routine, and expects
    the routine to return a C-language pointer to the R object representing the
    value of the call.

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

Sidebar

Related Questions

These are the docs about .ToString() that has prompted this question. They state: Because
This question is inspired by this question , which features the following code snippet.
A recent crash prompted this question - I had two gui windows open. Is
What prompted this question: I'm trying to change the account under which a windows
This question is prompted by the rather militant refusal of developer Michael Rys to
Edit: The bug which prompted this question has now been fixed . In the
This is more of a language design rather than a programming question. The following
There are several questions that are similar to this, but none address this specific
I guess this question could be taken in two ways... (Generic) - is there
Question: I am testing functions in a package that I am developing and would

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.