Questions tagged [forward-reference]
48 questions
61
votes
5 answers
Why must I use the "this" keyword for forward references?
When I use the this keyword for accessing a non-static variable in a class, Java doesn't give any error. But when I don't use it, Java gives an error. Why must I use this?
I know when should normally I use this, but this example is very different…

Nomad
- 918
- 6
- 23
59
votes
4 answers
Is there a generic way to memoize in Scala?
I wanted to memoize this:
def fib(n: Int) = if(n <= 1) 1 else fib(n-1) + fib(n-2)
println(fib(100)) // times out
So I wrote this and this surprisingly compiles and works (I am surprised because fib references itself in its declaration):
case class…

pathikrit
- 32,469
- 37
- 142
- 221
21
votes
2 answers
what does do forwardRef in angular?
What does forwardRef do in angular, and what is its usage?
here is an example:
import {Component, Injectable, forwardRef} from '@angular/core';
export class ClassCL { value; }
@Component({
selector: 'my-app',
template: '
{{ text…

unos baghaii
- 2,539
- 4
- 25
- 42
14
votes
3 answers
What is the difference between forward declaration and forward reference?
What is the difference between forward declaration and forward reference?
Forward declaration is, in my head, when you declare a function that isn't yet implemented, but is this incorrect? Do you have to look at the specified situation for either…

mslot
- 4,959
- 9
- 44
- 76
10
votes
0 answers
Why is using uninitialized variables allowed in Scala?
Possible Duplicate:
Forward References - why does this code compile?
Scala and forward references
object Main extends App {
val a = 4
val b = a + c
val c = 5
println(b) // => 4
}
This will print 4 as c apparently is 0 when b is assigned.…

kornfridge
- 5,102
- 6
- 28
- 40
8
votes
1 answer
Implementing a recursive structure using angular2 components (without forwardRef)?
I have a recursive structure that's composed of two components:
OptionsMenuComponent (A menu)
MenuItemComponent (The menu items)
OptionsMenuComponent: (Template + Component)
Template:

Nir Tamir
- 81
- 5
6
votes
2 answers
How do I implement forward references in a compiler?
I'm creating a compiler with Lex and YACC (actually Flex and Bison). The language allows unlimited forward references to any symbol (like C#). The problem is that it's impossible to parse the language without knowing what an identifier is.
The only…

Zifre
- 26,504
- 11
- 85
- 105
6
votes
1 answer
const forwarding reference gives error C2440: 'initializing': cannot convert from 'const std::string' to 'const std::string &&'
The following gives a compiler error:
#include
const std::string& get_name();
int main(){
auto&& name1 = get_name();//should bind to whatever
const auto& name2 = get_name();//also ok
const auto&& name3 =…

darune
- 10,480
- 2
- 24
- 62
6
votes
1 answer
React Refs with TypeScript: Cannot read property 'current' of undefined
I'm building a React application using TypeScript.
I want to create button, that scrolls to a header of a child component on my main page.
I've created a ref in the child component, following this stack overflow answer and (tried to) use forward…

J. Hesters
- 13,117
- 31
- 133
- 249
6
votes
2 answers
React.forwardRef Causes Error with Styled Component
I am running React 16.3.1 and Styled Components 3.2.5 currently and am hitting an issue trying to use React.forwardRef.
I have an Input component that is comprised of a wrapper div that holds the label and input field. However, I want to be able to…

Yuschick
- 2,642
- 7
- 32
- 45
6
votes
6 answers
What is forward reference in C?
What is forward reference in C with respect to pointers?
Can I get an example?

Manoj Doubts
- 13,579
- 15
- 42
- 45
5
votes
0 answers
How to do double referencing in mongoose schema in Nestjs without forming a circular dependency?
author.module.ts
@Module({
imports: [
forwardRef(() => ArticleModule),
MongooseModule.forFeature([{ name: Author.name, schema: AuthorSchema }]),
],
controllers: [AuthorController],
providers: [AuthorService, AuthorsRepository,…

Harshit Jain
- 51
- 1
5
votes
2 answers
ref doesn't have a value inside event handlers
Aimed functionality:
When a user clicks a button, a list shows. When he clicks outside the list, it closes and the button should receive focus. (following accessibility guidelines)
What I tried:
const hideList = () => {
// This closes the…

Moaaz Bhnas
- 1,010
- 7
- 18
- 36
5
votes
1 answer
Angular2 recursive components
I am trying to deploy recursive components as discussed in these posts and plnkr:
How do I inject a parent component into a child component?
> `http://plnkr.co/edit/l7jsV0k7DbGJGXPFlSPr?p=preview`
Angular2 Recursive Templates in javascript
However,…

Benjamin McFerren
- 822
- 5
- 21
- 36
4
votes
1 answer
How to handle forward references of XML IDREF with JAXB XmlAdapter during unmarshal?
Is it possible to handle forward references of XML IDREF elements in JAXB XmlAdapter during the unmarshal process? For example, I have the following XML complexType:
…

holic87
- 791
- 2
- 17
- 29