Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make "global const" work #248

Closed
StefanKarpinski opened this issue Nov 2, 2011 · 0 comments
Closed

make "global const" work #248

StefanKarpinski opened this issue Nov 2, 2011 · 0 comments
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@StefanKarpinski
Copy link
Member

Tried this:

diff --git a/j/client.j b/j/client.j
index 1e0d5f9..0776a85 100644
--- a/j/client.j
+++ b/j/client.j
@@ -93,21 +93,21 @@ function _start()
     try
         ccall(:jl_register_toplevel_eh, Void, ())
         ccall(:jl_start_io_thread, Void, ())
-        global Workqueue = {}
-        global Waiting = HashTable(64)
+        global const Workqueue = empty(WorkItem)
+        global const Waiting = HashTable(64)

         if !anyp(a->(a=="--worker"), ARGS)
             # start in "head node" mode
-            global Scheduler = Task(()->event_loop(true), 1024*1024)
-            global PGRP = ProcessGroup(1, {LocalProcess()}, {Location("",0)})
+            global const Scheduler = Task(()->event_loop(true), 1024*1024)
+            global const PGRP = ProcessGroup(1, {LocalProcess()}, {Location("",0)})
             # make scheduler aware of current (root) task
             enq_work(roottask_wi)
             yield()
         else
-            global PGRP = ProcessGroup(0, {}, {})
+            global const PGRP = ProcessGroup(0, {}, {})
         end

-        global VARIABLES = {}
+        global const VARIABLES = empty(Symbol)

         # Load customized startup
         try
diff --git a/j/multi.j b/j/multi.j
index a093941..f36e7e1 100644
--- a/j/multi.j
+++ b/j/multi.j
@@ -991,7 +991,7 @@ function start_worker(wrfd)
     # close stdin; workers will not use it
     ccall(dlsym(libc, :close), Int32, (Int32,), int32(0))

-    global Scheduler = current_task()
+    global const Scheduler = current_task()

     worker_sockets = HashTable()
     add_fd_handler(sockfd, fd->accept_handler(fd, worker_sockets))
diff --git a/j/process.j b/j/process.j
index 33ea6b4..db5a0fe 100644
--- a/j/process.j
+++ b/j/process.j
@@ -29,9 +29,9 @@ process_success(s::ProcessExited) = (s.status == 0)

 type FileDes; fd::Int32; end

-global STDIN  = FileDes(ccall(:jl_stdin,  Int32, ()))
-global STDOUT = FileDes(ccall(:jl_stdout, Int32, ()))
-global STDERR = FileDes(ccall(:jl_stderr, Int32, ()))
+global const STDIN = FileDes(ccall(:jl_stdin,  Int32, ()))
+global const STDOUT = FileDes(ccall(:jl_stdout, Int32, ()))
+global const STDERR = FileDes(ccall(:jl_stderr, Int32, ()))

 isequal(fd1::FileDes, fd2::FileDes) = (fd1.fd == fd2.fd)

Doesn't work since global and const don't appear to play nicely together. Not sure all of this diff is correct, but the construct makes sense, at least — it should allow an inner scope to declare a global constant. The opposite order const global should probably also work (or be illegal).

@ghost ghost assigned JeffBezanson Nov 2, 2011
LilithHafner pushed a commit to LilithHafner/julia that referenced this issue Oct 11, 2021
* Made `WeightVec` a subtype of `RealVector`

* Added a few tests to weights.jl

* Changed parameterization of WeightVec.

- Parameterization to `WeightVec{S<:Real, T<:Real, T<:AbstractVector}`
- Uses triangular dispatch for julia version passed v"0.6.0-dev.2123"

* Moved constructors out of version check.

* Cleaned up WeightVec constructors.

* Fixed thrown `MethodError` call in `median(::AbstractArray, ::WeightVec)`
IanButterworth pushed a commit that referenced this issue Aug 28, 2024
…1061ecc (#55615)

Stdlib: Downloads
URL: https://github.com/JuliaLang/Downloads.jl.git
Stdlib branch: master
Julia branch: backports-release-1.11
Old commit: a9d274f
New commit: 1061ecc
Julia version: 1.11.0-rc2
Downloads version: 1.6.0(It's okay that it doesn't match)
Bump invoked by: @IanButterworth
Powered by:
[BumpStdlibs.jl](https://github.com/JuliaLang/BumpStdlibs.jl)

Diff:
JuliaLang/Downloads.jl@a9d274f...1061ecc

```
$ git log --oneline a9d274f..1061ecc
1061ecc Fix setting atexit. Fixes trailing download tasks during precompilation (#257)
b871386 Add debug information to `setopt` commands (#248)
51e5321 fix: use invokelatest for easy_hook, avoid race (#241)
05f9ec2 make precompile workload relocatable (#236)
2dd891a Hardcode doc edit backlink (#232)
```

Co-authored-by: Dilum Aluthge <dilum@aluthge.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants