scope

how to avoid name conflicts coming from #define in C? (or C++)

一曲冷凌霜 提交于 2020-01-17 06:03:10
问题 This should be very basic question, and I can avoid this situation by changing some names but I think maybe there is something I am missing here. I have made a simplest code for this problem. conv.h : 1 struct convpar_ { 2 int K; 3 } convpar_; test.c : 1 #include <stdio.h> 2 #include "conv.h" 3 4 #define K 7 5 6 typedef struct convpar_ convpar; 7 8 void func1(convpar cp) 9 { 10 printf("cp.K = %d\n", cp.K); 11 } 12 13 main() 14 { 15 convpar cp = {K}; 16 17 func1(cp); 18 } If I do cc test.c -o

R: Source personal scripts keeping some functions hidden

流过昼夜 提交于 2020-01-17 05:06:44
问题 Follow up to this I want to source scripts inside a given environment, like in sys.source , but "exporting" only some functions and keeping the others private . I created this function: source2=function(script){ ps=paste0(script, "_") assign(ps, new.env(parent=baseenv())) assign(script, new.env(parent=get(ps))) private=function(f){ fn=deparse(substitute(f)) assign(fn, f, parent.env(parent.frame())) rm(list=fn, envir=parent.frame()) } assign("private", private, get(script)) sys.source(paste0

Scope in ExtJS 4 inside a function handler

这一生的挚爱 提交于 2020-01-17 03:25:34
问题 I've searched a little about the scope problem and found some stuff but I'm not sure they work for my case. I'm really confused atm so I thought I might as well ask directly to the forums. I have a tree panel. Inside that tree panel I have a dockedItem of xtype: 'textfield'. That textfield takes a value and uses it as a parameter in an ajax request via Ext.Ajax.Request inside a handler for the specialkey event. The server returns a JSON object on its response that gets decoded and contains

How to get identifiers scoped in a (LA)LR parser

谁说胖子不能爱 提交于 2020-01-17 01:24:07
问题 A disadvantage of a (LA)LR parser is that a reduce is only processed at the end of a rule. This is a problem in programming languages with scoped variables like javascript . Example: var a = 2; function (a) { a = 4; } See the above code example. A parser could look like: program : instruction program {} | {} ; instruction : command {} | function {} ; command : "var" identifier "=" literal ";" {} ; function : "function" "(" arguments ")" "{" program "}" {/*1*/} ; arguments : identifier {} |

How to fix ExtJS scoped CSS for IE?

谁说胖子不能爱 提交于 2020-01-16 19:45:29
问题 I'm using ExtJS 4.1.1 and some components don't display as expected in IE7. I checked ext-all-scoped.css and I noticed that these two classes .x-reset .x-ie do not appear in the right order, so the styles are not applied. I thought I could simply replace this string with the right one ( .x-ie .x-reset ) but there are many different cases such as .x-reset .x-strict .x-ie7 , .x-reset .x-quirks .x-ie8 and so on all along the file. Thereby, I'd rather like recompile the entire CSS file. Does

do{}while(0) - macro safety

寵の児 提交于 2020-01-16 14:53:13
问题 We know that multiline macros have to be inclosed in a do while(0) loop for them to be safely included anywhere in the code. For example this is 100% safe: #define swap( a , b ) \ do \ { \ int t = a ; \ a = b ; \ b = t ; \ } \ while(0) I would like to know if it is also safe to have a macro with a part of the code outside of the loop, and if it isn't, in what circumstances could problems occur. #define swap( a , b ) \ int t ; \ //should be in the same scope where the macro was called and

Scope with multiple where conditions based on multiple conditions

心已入冬 提交于 2020-01-16 12:33:24
问题 Is there possible to use something like scope :state, ->(state) { merge(where("start_time <= ? and end_time >= ?", Time.now.utc.beginning_of_day, Time.now.utc.beginning_of_day)) if state.include?("open") merge(where("end_time < ?", Time.now.utc.beginning_of_day)) if state.include?("closed") merge(where("start_time > ?", Time.now.utc.beginning_of_day)) if state.include?("upcoming") } If I use this scope, only the last one is functional. for example: state(["upcoming"]) -> work state(["open"])

Does Invoke-Command run in the current scope, or a child scope, when run locally?

末鹿安然 提交于 2020-01-16 09:15:07
问题 I was informed in a comment on another post that: As for Invoke-Command : unfortunately, the docs are incorrect: by default, local invocation happens in a child scope, but you can opt into same-scope execution with -NoNewScope . – mklement0 However, according to the help documentation(emphasis added): You can also use Invoke-Command on a local computer to evaluate or run a string in a script block as a command. Windows PowerShell converts the script block to a command and runs the command

Is it possible to read set_fact of a dynamically constructed host in different Ansible play

十年热恋 提交于 2020-01-16 09:10:03
问题 I'm aware of how to read set_fact across different plays. I have also read about issues regarding set_fact in another play. However, I did not come across any example where the set_fact used under a Play having dynamically constructed host using add_host and it now needs to be read by another play having hosts: localhost I was expecting host_vars to help me but the below playbook test shows that host_vars also does not help and I get a variable undefined error. You can run the playbook and

Switching views within the same controller whilst retaining scope data

﹥>﹥吖頭↗ 提交于 2020-01-16 01:18:49
问题 I have a page of data that can be viewed as a list or as markers on a map. It also has filtering in the sidebar. I currently have this structured as separate map and list pages but I want to merge them so that the filters remain when switching views. I have tried using ui-router but due to my markup I cannot keep the filtering within a parent state, as per my question here: How do I show multiple views in an abstract state template? My current markup is like this: <div class="main-container"