Skip to content

'{}' being 'bad practice' could go for some justification #1804

@MichaelChirico

Description

@MichaelChirico

adv-r/S4.Rmd

Lines 345 to 352 in 14bdb11

It is bad practice to use `{}` in the generic as it triggers a special case that is more expensive, and generally best avoided.
```{r}
# Don't do this!
setGeneric("myGeneric", function(x) {
standardGeneric("myGeneric")
})
```

Casually, it seems strange to expect a noteworthy performance hit from using {. And it's ambiguous when we expect that performance hit -- package build time, or run time?

I glanced at the setGeneric() code and didn't immediately spot any "edge case", it probably requires more careful reading to figure this out.

Moreover, there are multiple examples in ?setGeneric itself that use {:

https://github.com/r-devel/r-svn/blob/43449c0a9d00390293ce9c0d7df855edfb10c0e2/src/library/methods/man/setGeneric.Rd#L322-L340

A link to an external reference here would be good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions