Replace .validLHS() with tryCatch()?

Open
#88 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Stale
Tech stack
r
Domain
data

Research direction

Locate the current .validLHS() usage and inspect how assignment errors are handled around the shown on.exit pattern. Compare the proposed try() and tryCatch() approaches, then establish the expected behavior before changing anything. Done requires a maintainer decision on the replacement and verification that assignment behavior remains correct.

Written by the indexing model from the issue text.

Description

The ultimate test of whether something can be assigned to is to actually try assigning to it.

It may therefore make sense to replace the

  if(.validLHS(xn,parent.frame())){  #If x not anonymous, set in calling env 
    on.exit(eval.parent(call('<-', xn, x)))
  }
  invisible(x) 

pattern with the much simpler

  on.exit(try(eval.parent(call('<-', xn, x)), silent = TRUE))
  invisible(x) 

or, since we don't care about the try-error object,

  on.exit(tryCatch(eval.parent(call('<-', xn, x)), error = function(e){}))
  invisible(x) 

Thoughts? @CarterButts ?

Dominant language
R
Stars
20
Forks
7
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from statnet/network

All issues in statnet/network

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.