Questions tagged [self-reference]

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Self-reference is the ability of a program (or logical sentence) to refer to itself, either directly or indirectly.

Useful Links:

Stanford Encyclopedia 'Self Reference' Entry

Related Tags:

536 questions
176
votes
6 answers

How to get a reference to a module inside the module itself?

How can I get a reference to a module from within that module? Also, how can I get a reference to the package containing that module?
Ram Rachum
  • 71,442
  • 73
  • 210
  • 338
37
votes
4 answers

R self reference

In R I find myself doing something like this a lot: adataframe[adataframe$col==something]<-adataframe[adataframe$col==something)]+1 This way is kind of long and tedious. Is there some way for me to reference the object I am trying to change such…
LostLin
  • 7,286
  • 11
  • 48
  • 71
31
votes
2 answers

How can I achieve a self-referencing many-to-many relationship on the SQLAlchemy ORM back referencing to the same attribute?

I'm trying to implement a self-referential many-to-many relationship using declarative on SQLAlchemy. The relationship represents friendship between two users. Online I've found (both in the documentation and Google) how to make a self-referential…
wocoburguesa
  • 688
  • 1
  • 5
  • 7
30
votes
1 answer

Self referencing / parent-child relationship in Entity Framework

I read quite a number of posts of programmers that run into the Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements, or store-generated values -exception when using…
26
votes
4 answers

how can I do self-reference with ruby on rails?

I want to self-referentiate a model in a RoR app but, I don't know exactly how. I want to save a linked list where the next node has the id of the previous one. how can I do this rails way? It is a one-to-one relation.
JRafaelM
  • 771
  • 2
  • 9
  • 23
26
votes
4 answers

TypeScript: self-referencing return type for static methods in inheriting classes

With Polymorphic this in TypeScript 1.7, as I discovered here, we can define a method in a class with a return type of this, and automatically, any classes that extend that class and inherit the methods, will have their return types set to their…
Merott
  • 6,527
  • 6
  • 32
  • 50
23
votes
3 answers

Is self-reference possible in MATLAB?

As noted here, functions in packages, as well as static methods in classes, still need to use a packagename.functionname syntax or import packagename.* for each function (since the imports are part of the function workspace and not global). This…
Tobias Kienzler
  • 21,611
  • 21
  • 111
  • 204
22
votes
9 answers

Self-reference for cell, column and row in worksheet functions

In a worksheet function in Excel, how do you self-reference the cell, column or row you're in?
Lance Roberts
  • 21,279
  • 29
  • 106
  • 128
21
votes
3 answers

Python: getting a reference to a function from inside itself

If I define a function: def f(x): return x+3 I can later store objects as attributes of the function, like so: f.thing="hello!" I would like to do this from inside the code of the function itself. Problem is, how do I get a reference to the…
Ram Rachum
  • 71,442
  • 73
  • 210
  • 338
20
votes
4 answers

c# generic self-referencing declarations

I've been reading Albaharis' "C# 5.0 in A Nutshell" and I've encountered this in Generics section and it is said to be legal: class Bar where T : Bar { ... } And it meant nothing to me, although I've read the whole chapter carefully. I…
emre
  • 263
  • 2
  • 7
19
votes
2 answers

Reflexive type parameter constraints: X where T : X ‒ any simpler alternatives?

Every so often I am making a simple interface more complicated by adding a self-referencing ("reflexive") type parameter constraint to it. For example, I might turn this: interface ICloneable { ICloneable Clone(); } class Sheep : ICloneable { …
stakx - no longer contributing
  • 77,057
  • 17
  • 151
  • 248
19
votes
4 answers

How can I refer to the class type a interface is implementing in Java?

I came to a problem with interfaces in a program I'm making. I want to create a interface which have one of its methods receiving/returning a reference to the type of the own object. It was something like: public interface I { ?…
Leonardo Raele
  • 1,150
  • 1
  • 14
  • 26
19
votes
1 answer

Entity Framework 4.1 Code First Self-Referencing One-to-Many and Many-to-Many Associations

I have a User that can have collection of users he likes... Another user can have collection of users he likes.... If User A likes User B and if User B likes User A, then they get to hang out. I need to send each other their contact info. How do we…
19
votes
6 answers

What is the best way to empty a self-referential MySQL table?

I have a self-referential MySQL table with a recursive parent_id: CREATE TABLE `recursive` ( `id` int(11) NOT NULL auto_increment, `parent_id` int(11) default NULL, `name` varchar(100) NOT NULL, PRIMARY KEY (`id`), KEY…
Mat
  • 67,636
  • 33
  • 83
  • 106
18
votes
5 answers

Building Self-Referencing Tuples

After seeing a conversation in a forum from many years ago that was never resolved, it caused me to wonder how one would correctly create a tuple that referenced itself. Technically, this is a very bad idea since tuples are supposed to be immutable.…
Noctis Skytower
  • 19,237
  • 15
  • 73
  • 103
1
2 3
35 36