Questions tagged [deferred-execution]

219 questions
1
vote
2 answers

Using LINQ .Select() to cast into new type is TOO slow?

Current project, broke head over this problem: Client Repository: public class ClientRepository { // Members private masterDataContext _db; // Constructor public ClientRepository() { _db = new masterDataContext(); …
vvohra87
  • 5,594
  • 4
  • 22
  • 34
1
vote
1 answer

Remove file on function failure

If I run this code: package main import "os" func pass() bool { return false } func main() { f, e := os.Create("file.txt") if e != nil { panic(e) } defer f.Close() if ! pass() { e := os.Remove("file.txt") if e !=…
Zombo
  • 1
  • 62
  • 391
  • 407
1
vote
4 answers

How to defer computation in C++ until needed?

In C++(*), is it possible to have a structure that "defers" some computation until needed (and maybe never does the computation if not necessary)? My use case is as follows: I have roughly a dozen bool variables, each of which is computed with some…
Matt
  • 952
  • 2
  • 8
  • 17
1
vote
3 answers

Why the extension method of where for LINQ in this code would print out a single number while it shouldn't print anything at all?

I've been reading about deferred evaluation of LINQ in the "Programming C#" book by Ian Griffiths. Deferred evaluation was explained through an example in which a Fibonacci method is defined to return a never-ending sequence. //code 1 static…
Mahsa
  • 362
  • 2
  • 15
1
vote
2 answers

Deferring function call in argument in python 3

I'm trying to add a cache of sorts to an expensive function using a fixed dictionary. Something like this: def func(arg): if arg in precomputed: return precomputed[arg] else: return expensive_function(arg) Now it would be a…
TheEnvironmentalist
  • 2,694
  • 2
  • 19
  • 46
1
vote
3 answers

Why is there a different runtime behaviour with deferred execution using the "yield" keyword in c#?

If you call the IgnoreNullItems extension method in the sammple code below the deferred execution works as expected however when using the IgnoreNullItemsHavingDifferentBehaviour the exception is raised immediately. Why? List testList =…
1
vote
0 answers

How to make sure that the following recursive function is resolved or completed and then do some operations?

i made a recursive function which will get the file details from a share point document library recursively but unable to know whether the recursive function is resolved or completed //function definition getFiles = function…
1
vote
1 answer

finalizing / post-processing chained methods

Assuming I have an Array-like object which allows for chaining methods like so: var ds = new DataSet(items); var subset = ds.filter(condition1).filter(condition2); Is there a way to execute code after the last method in the chain has been processed…
AnC
  • 4,099
  • 8
  • 43
  • 69
1
vote
0 answers

How does the implementation of range-v3's meta::defer work?

Here is the implementation of meta::defer: template