485
questions
2
votes
0
answers
41
views
Hot to fix problem with unconcurrent state crashes?
I have auto slider banner every 3 sec it goes to next banner and also you can manually change banner.
That's my launched effect and I use Horizontal Pager from foundation I also needed to calculate if ...
2
votes
0
answers
21
views
How does Android render styles after recomposition?
I'm pretty new with Android Compose so I decided to make an app where I can dynamically change the style after the client chooses a fruit. After changing the style, a couple of SVG files take that ...
1
vote
1
answer
58
views
Is it possible to update state in LaunchedEffect without Unsupported Concurrent change problem?
I've got ErrorScreen which is an overlay on my every screen. It collects errors from Flow. It has own errorState.
I'm not sure, but is it a proper way to handle this state and update?
From my ...
0
votes
0
answers
33
views
Volatile struct member assignment: side effects / undefined behavior
I am considering the following code:
#include <stdint.h>
typedef struct {
uint32_t a;
} foo_t;
volatile foo_t foo;
volatile uint32_t b;
int main(void)
{
foo.a = b;
return 0;
}
In ...
2
votes
2
answers
76
views
Will LINQ Any() ever enumerate without arguments?
Given the following:
var nums = GetNums();
Console.WriteLine(nums.Any());
Console.WriteLine(string.Join(", ", nums));
static IEnumerable<int> GetNums()
{
yield return 1;
...
2
votes
1
answer
59
views
When is a value captured by a LaunchedEffect?
I don't understand why the following two methods give different results:
@Composable
fun MainScreen2() {
var counter by remember { mutableIntStateOf(0) }
LaunchedEffect(key1 = Unit, block = {
...
1
vote
0
answers
71
views
Are function calls guaranteed to be strict in C? [duplicate]
In general in the C programming language operators have no guaranteed evaluation order, motivated by the fact that this frees up the compiler to perform optimizations related especially to pipelining.
...
3
votes
1
answer
67
views
Multiple FFI calls to a Haskell function with side-effects
I want to write a Haskell function that receives a vector and returns another one with the same size but delayed by a certain number of samples d (add zeroes at the start). Because the produced vector ...
0
votes
0
answers
45
views
Usage of RAP Side Effects for field added by virtual element
I have added a field ZTEST using virtual element in C_SalesOrderManage view.
Calculation of this field is dependent on 2 fields from another view C_SalesOrderItemManage.
Can this be achieved using RAP ...
-1
votes
1
answer
99
views
In C++, is cout<<printf("2") an undefined behavior? [duplicate]
The question comes from my friends, and they argued a lot about it.
The ones that think it's not UB say, obviously, printf is a function, so its side effect must happen before return value is set, and ...
3
votes
1
answer
92
views
Can a function be declared as pure at definition?
According to Webpack documentation:
It can be put in front of function calls to mark them as side-effect-free. Arguments passed to the function are not being marked by the annotation and may need to ...
1
vote
1
answer
2k
views
How to pass a value from a composable function to another composable function and return it modified to the caller function in kotlin?
I've started recently to learn Android and develop my own personal application. More precisely, I want to make a budget tracker and the problem I've just stumbled on is, as mentioned in the title, ...
3
votes
1
answer
407
views
Android Compose side effects: Side-Effect behavior
I'm probably missing some important composable recomposition concepts here but let me explain my doubt.
I was reading about side effects in Android Compose and I findout that specifically SideEffect ...
1
vote
1
answer
267
views
How can I use angular signals for a lot of side effects
So, I have the following code
import { Component, computed, model, signal } from '@angular/core'
import { IVillageWiseMember } from '../../../types/IVillageWisemember'
import { IDataWithPagination } ...
-4
votes
1
answer
85
views
Why side-effect for my node.js code not worked [closed]
I'm beginner in NodeJS(version v21.6.1) and I tried to implement a code in multiple modules to understand side-effect concept in JavaScript but the code not worked, why?
// main.js
import './...
1
vote
1
answer
123
views
Does Rust has a data type for encoding side effects as pure values?
I am doing some exercise from the book Grokking Functional Programming, the origin code examples are written in Scala, and I want to rewrite it with Rust and Rakulang.
In Scala's cats effect library, ...
5
votes
3
answers
200
views
Does Raku has a data type for encoding side effects as pure values?
I am doing some exercise from the book Grokking Functional Programming, the origin code examples are written in Scala, and I want to rewrite it with Raku.
In Scala's cats effect library, there is a ...
0
votes
0
answers
275
views
Angular async signal state management
I'm working on a medium sized Angular app and this is the situation:
The user gets auth'd and data A is requested. Once/if that comes through, data B must be requested. Data A is global. Data B is ...
0
votes
0
answers
17
views
How do I use effects and refs to set an automatic scroll behavoir when a user selects a product?
I'm working in Next using tailwind CSS. The goal is to setup a shop page that behaves like an instagram feed where the user clicks a product photo in the grid and the page renders all the same content ...
1
vote
0
answers
26
views
Chained comparisons not always executing functional calls (side-effects) [duplicate]
I was testing out comparison chaining and I noticed that in certain patterns the some of the function calls are not executed.
If I plan on using the function calls to do things what would be the best ...
0
votes
1
answer
137
views
LaunchedEffect starts more that once
I met the problem, which consists in that LaunchedEffect works incorrectly. I want to block in LaunchedEffect start once, when user click to corresponding NavigationBarItem, because block should send ...
0
votes
1
answer
98
views
How to Locally modify shared objects in Tasks to prevent Side Effects
I have an object shared between concurrent Tasks. It's for creating different JSONs using the same set of properties. Here is a simplified example of its class: (I call it builder but it's not really ...
1
vote
2
answers
43
views
Does change in state unmount functional component
I know that change in state triggers re-rendering of component. So my question is that, does change in state also unmount function component as part of re-rendering process?
main.jsx
const Fullnote = (...
2
votes
2
answers
75
views
Side effects executed less than expected (LINQ)
Here is a test using NUnit style:
[Test]
public void Test()
{
var i = 0;
var v = Enumerable.Repeat(0, 10).Select(x =>
{
i++;
return x;
}).Last();
Assert.That(v, ...
0
votes
1
answer
37
views
How to add if then else based on mutable variables in FParsec parsers?
I'm trying to add error recovery to an FParsec parser that consumes a comma-separated sequence in parentheses, e.g. "(a,b,c)".
I came across the following problem: Given the two inputs "...
1
vote
1
answer
209
views
Does typescript always assumes side effects are not allowed?
I have the following toy example where typescript warns me of an error:
type obj = {
ok: "ok" | "error",
}
function main(a: obj){
a.ok = "ok";
...
1
vote
1
answer
540
views
Updating local variables in jetpack compose and side effects
Reading about side effects in jetpack compose (thinking in compose), I find this example:
@Composable
@Deprecated("Example with bug")
fun ListWithBug(myList: List<String>) {
var ...
0
votes
0
answers
299
views
Request permission to send PUSH notifications in Compose and Android 13
A slightly non-trivial task: the project goes to MVI + orbit and a task has appeared to request permission to send push notifications. But the question is, what is the best way to do it? Conditionally,...
0
votes
2
answers
7k
views
what is DisposableEffect and under the hood in jetpack compose?
I've been trying to understand what is DisposableEffect and How it works for a while so I have searched on the internet for this and I saw that most of the documentation are similar explanation for ...
0
votes
1
answer
147
views
Haskells bind operator and the >> operator and their relation
I have recently posted a question about the >> operator, because even though I have read the LYAH walk the linee section I still have some gaps in my understanding. Below is some code/MVE that ...
0
votes
0
answers
429
views
Why am I getting a 'StopIteration' error when using mock's side effect?
Please see below my function, which uses the function Path, which I am trying to mock out and use side_effect to assign a different value for two function calls.
def some_function(input_file, file):
...
0
votes
1
answer
132
views
Side Effects of Function in Python
I'm a pretty novice programmer, and currently trying to solve the "Palindrome Linked List" program on Leetcode. My idea is to write a nested function called "reverse" which ...
1
vote
0
answers
495
views
How to handle side-effects in the context of Rollup tree-shaking?
rollupjs is flagging a side effect here:
renderer/Logger.ts (3:7) First side effect in renderer/Logger.ts is at (2:0)
1: import { Roarr } from "roarr";
2: export const Logger = Roarr.child({
...
0
votes
1
answer
3k
views
Delayed Side Effect in Compose
I have a delayed LaunchedEffect that runs every 5 second after the user makes camera to move:
public var isMoving: Boolean by mutableStateOf(false)
LaunchedEffect(isMoving) {
if (!isMoving) {
...
4
votes
1
answer
255
views
How to avoid deferring the initialization of static storage duration variables?
I have classes with side effects in their constructors, and objects of these classes are global objects that have static storage duration. During the initialization these objects register their ...
1
vote
1
answer
68
views
Undeterminable return sideeffect in Powershell
Given the following snipped with input $value='Line\"\nString' and $value_type='Interpolated'.
Note: $value contains literal escape sequences, not escaped characters.
The following variables are ...
0
votes
2
answers
40
views
Patching class attribute to return different values?
Given following production code, where file_path is of pathlib.Path type
previous_time = file_path.stat().st_mtime
# recreate the file
.....
if file_path.stat().st_mtime != previous_time:
# do ...
1
vote
1
answer
100
views
Is bash supposed to evaluate array index expressions for side-effects even when the indexing expression goes unused?
Weird thing I recently discovered: At least on my version of bash (4.2), it seems like the conditional operator does not evaluate the untaken path normally, but it does so for array indexing ...
0
votes
1
answer
516
views
use dispatch from useReducer in useEffect - React
In react I'm trying to do a GET request on first render in a useEffect and then dispatch the response to update the useReducer state.
Here is the code:
const [{ firstTime, typeOfDev, technologies },...
2
votes
0
answers
78
views
Why SideEffect is neccessary?
When I delete this method used in the Google theme class, there is no change. Google documents are also incomprehensible when explaining this topic as usual. Different articles have confused me with ...
0
votes
0
answers
99
views
Why does pre-increment not work for an overflow check, but post-increment does? [duplicate]
I attempted to write a function that increments an unsigned integer and checks if the result overflowed, by comparing the old value of the integer with the value after incrementing:
unsigned ...
-1
votes
1
answer
88
views
Need clarification of the meaning of "side effect" in C
I have read many discussions of what constitutes a "side effect" in C, and many seem to indicate that it must involve changing something that is not local to the function causing the change. ...
0
votes
1
answer
35
views
DerivedState inside SideEffect does not cause recomposition
In the scenario where I need to handle side effect and I need to pass firstItemVisibleIndex is bigger than 0 to the lambda function in the composable. Imagine I have this derivedState
val ...
1
vote
5
answers
222
views
Are a[i]=y++; and a[i++]=y; undefined behavior or unspecified in C language?
When I was looking for the expression v[i++]=i; why it is to define the behavior, I suddenly saw an explanation because the expression exists between two sequence points in the program, and the c ...
0
votes
2
answers
135
views
How can I communicate whether side effects have been successful or not?
With the Rust project I am working on I would like to keep the code as clean as I can but was having issues with side effects - more specifically how to communicate whether they have been successful ...
1
vote
0
answers
41
views
Functions that have no effect on global state
We have the notion of a pure function, whose return value depends only and entirely on its parameters, and which does not change global state.
Example:
def f(a, b):
return a+b
What would be the ...
4
votes
1
answer
6k
views
Alternative to peek in Java streams
There are lots of questions regarding peek in the Java Streams API. I'm looking for a way to complete the following common pattern using Java Streams. I can make it work with Streams, but it is non-...
1
vote
1
answer
1k
views
What's the difference between LaunchedEffect and Composable function
What's the difference between LaunchedEffect and Composable function?
Except coroutine scope in launch effect
val currentProgress = GlobalLoader.current
LaunchedEffect(progress) {
progress ?: ...
0
votes
1
answer
98
views
RXJS side-effect execution order
I have this huge object that I want to be able to set with a one simple function like below
private setPerson = (partialPerson: Partial<Person>) => {
this.person$.next({ ...this.person$....
1
vote
1
answer
119
views
Why is Racket evaluating both of these functions in one case, but not the other?
Defining the function my-if to use cond internally results in different behavior than using cond directly.
Using cond, the DrRacket interpreter only prints the string for the first displayln.
Code:
(...