scope

How do I use enum values when their type is defined indirectly in another unit?

ⅰ亾dé卋堺 提交于 2019-12-11 13:44:36
问题 I am trying to reduce the number of Uses and am running into problems with Enums (* original unit, where types are defined etc *) unit unit1; type TSomeEnumType = (setValue1, setValue2, ...); ... (* global unit where all types are linked *) unit unit2; uses unit1; type TSomeEnumType = unit1.TSomeEnumType; ... (* form unit that will use the global unit *) unit unitform; uses unit2; ... procedure FormCreate(Sender : TObject); var ATypeTest : TSomeEnumType; begin ATypeTest := setValue1; (* error

Java Scoping & Visibility Rules

隐身守侯 提交于 2019-12-11 13:43:22
问题 I am coming back to writing code in Java after a long gap - most of my coding work over the past few years has been in PHP & JavaScript - and am discovering that I have to work harder to satisfy the Java compiler which is far more rigorous about issues such as variable scope and exception handling. A piece of code that caused me some trouble is shown below File file = new File(path, fname); FileOutputStream stream = null; try { stream = new FileOutputStream(file); stream.write(tosave.getBytes

Scrapy item extraction scope issue

荒凉一梦 提交于 2019-12-11 13:38:22
问题 I am having scope issues with returning a Scrapy item (players) in my pipeline. I'm fairly certain I know what the issue is but I'm not sure how to integrate the solution into my code. I am also certain that I now have the code correctly written for the pipeline to process. It's just I've declared the players item inside the parseRoster() function so I know it's scope is only limited to that function. Now my question is, where do I need to declare a players item in my code for it to be

lapply() emptied list step by step while processing

血红的双手。 提交于 2019-12-11 13:26:03
问题 First of all, excuse me for the bad title. I'm still so confused about this behavior, that I wasn't able to describe it; however I was able to reproduce it and broke it down to an (goofy) example. Please, could you be so kind and explain why other.list appears to be full of NULL s after calling lapply() ? some.list <- rep(list(rnorm(1)),33) other.list <- rep(list(), length = 33) lapply(seq_along(some.list), function(i, other.list) { other.list[[i]] <- some.list[[i]] browser() }, other.list) I

php oop variable scope

陌路散爱 提交于 2019-12-11 13:24:20
问题 So I have a class.. In its constructor I include the code which connects me to my database via the mysqli extension: class MyClass { public function __construct() { include("dbconnect"); } } dbconnect looks like this: $host = "localhost"; $user = "user"; $pass = "123"; $database = "myDatabase"; $mysqli = new mysqli($host, $user, $pass, $database); $mysqli->set_charset('utf8-bin'); Now to my problem: Since mysqli can be used OOP-Style, how do I get access to the variable in MyClass? function

Why is MonitorFromWindow missing/not declared? (C++/WINAPI)

你。 提交于 2019-12-11 13:22:13
问题 I'm trying out the Windows API, and I've run into a lot of problems. The most recent is this: I included Windows.h, and temporarily Winuser.h, yet the MonitorFromWindow (and the associated fields, like MONITOR_DEFAULTTONEAREST) are missing. Specifically, ...'MONITOR_DEFAULTTONEAREST' was not declared in this scope and ...'MonitorFromWindow' was not declared in this scope. Other methods show up just fine, like LoadImage and CreateWindow. Is there some inclusion I'm missing? I don't think it's

How to turn off global scope in XText 2.9?

≡放荡痞女 提交于 2019-12-11 12:59:19
问题 someone knows how to turn off the global scope in XText 2.9? I want to turn off the global scope in order to only can access the elements of the files that I import. For example: file1.mydsl: element A(C){ ; } subelement C{ ; } file2.mydsl: element B(C){ ; } This should return an error in file2.mydsl because I haven't imported "file1.mydsl". I should add the line - import "file1.mydsl" - to avoid the error. How can I do that in Xtext 2.9? I have a working code that does what I want but the

What is the default variable_scope in Tensorflow?

爷,独闯天下 提交于 2019-12-11 12:49:54
问题 What is the default global variable_scope in Tensorflow? How can I inspect the object? Does anyone have ideas about that? 回答1: Technically, there's no global variable scope for all variables . If you run x = tf.Variable(0.0, name='x') from the top level of your script, a new variable x without a variable scope will be created in the default graph. However, the situation is a bit different for tf.get_variable() function: x = tf.get_variable(name='x') The first thing it does is calls tf.get

Redeclare a variable from a different block in a short variable declaration

社会主义新天地 提交于 2019-12-11 12:30:34
问题 How can I redeclare a variable from a different block in a short variable declaration? func f() (err os.Error) { proc, err := os.StartProcess(blah blah blah) // the new err masks the return value? } There's a long thread about this, and an issue, but I'm interested in how to work around this for the time being. 回答1: The Go specification for short variable declarations is clear: a short variable declaration may redeclare variables provided they were originally declared in the same block with

Global functions and capturing values in swift

蹲街弑〆低调 提交于 2019-12-11 12:23:08
问题 Swift documentation says that closures and nested functions can capture values while global functions can not. Why then this is not a compilation error (in fact it looks like the global funciton myFunc() captures the value.) var myInt = 0 func myFunc() { myInt+=1 } print(myInt) //prints 0 myFunc() print(myInt) //prints 1 I am running this in Xcode playground, could that have something to do with it? Thanks 来源: https://stackoverflow.com/questions/36716013/global-functions-and-capturing-values