# General Usage

**URL:** https://discourse.julialang.org/c/usage/6.md?page=1003

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 1004

---

## [Why isn't isequal(x,y) = hash(x) == hash(y)](https://discourse.julialang.org/t/why-isnt-isequal-x-y-hash-x-hash-y/8300)

<div class="topic-metadata">

**Author:** [@jandehaan](https://discourse.julialang.org/u/jandehaan)\
**Replies:** 2\
**Last updated:** [January 12, 2018, 4:09am UTC](https://discourse.julialang.org/t/why-isnt-isequal-x-y-hash-x-hash-y/8300 "2018-01-12T04:09:52Z")

</div>

From the 0.6.2 documentation isequal is the comparison function used by hash tables (Dict). isequal(x,y) must imply that hash(x) == hash(y). This typically means that if you define your own == function then you must d…

---

## [Get type of field in parametric type](https://discourse.julialang.org/t/get-type-of-field-in-parametric-type/8210)

<div class="topic-metadata">

**Author:** [@tpoisot](https://discourse.julialang.org/u/tpoisot)\
**Replies:** 4\
**Last updated:** [January 12, 2018, 12:44am UTC](https://discourse.julialang.org/t/get-type-of-field-in-parametric-type/8210 "2018-01-12T00:44:20Z")

</div>

Let’s say I have a parametric type defined as mutable struct Example{T,N\<:Real} a::T b::Array{N,1} end I can create an object with something like, x = Example(:a, \[1, 2, 3\]) Then the type of x is Example{Symbol, …

---

## [Properties of Range](https://discourse.julialang.org/t/properties-of-range/8298)

<div class="topic-metadata">

**Author:** [@goldfita](https://discourse.julialang.org/u/goldfita)\
**Replies:** 1\
**Last updated:** [January 11, 2018, 11:13pm UTC](https://discourse.julialang.org/t/properties-of-range/8298 "2018-01-11T23:13:20Z")

</div>

Should I expect that the length of a range is preserved under arithmetic operations on the range? I ran into a bug where simply changing the sign in front of a range in an expression caused a dimension mismatch error. …

---

## [! for infix operators](https://discourse.julialang.org/t/for-infix-operators/8257)

<div class="topic-metadata">

**Author:** [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Replies:** 18\
**Last updated:** [January 11, 2018, 6:50pm UTC](https://discourse.julialang.org/t/for-infix-operators/8257 "2018-01-11T18:50:19Z")

</div>

From the docs: Predicate function negation: when the argument of ! is a function, it returns a function which computes the boolean negation of f. Hence, !iseven is a function that returns true if the argument is not …

---

## [Midpoints deprecation](https://discourse.julialang.org/t/midpoints-deprecation/8289)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 3\
**Last updated:** [January 11, 2018, 3:29pm UTC](https://discourse.julialang.org/t/midpoints-deprecation/8289 "2018-01-11T15:29:17Z")

</div>

Base.midpoints was deprecated for v0.6, and ostensibly moved to StatsBase, which appears to export the symbol but not define it. So I get Base.midpoints, with warnings. What should I do to get rid of the deprecation warn…

---

## [Function hist() not found](https://discourse.julialang.org/t/function-hist-not-found/8290)

<div class="topic-metadata">

**Author:** [@Bob\_Lin](https://discourse.julialang.org/u/Bob_Lin)\
**Replies:** 3\
**Last updated:** [January 11, 2018, 3:16pm UTC](https://discourse.julialang.org/t/function-hist-not-found/8290 "2018-01-11T15:16:46Z")

</div>

I am currently learning the Julia Language in JuliaBox and now I face a small problem. When I try to call it or enter ?hist, it seems to be undefined. with the message: No documentation found. Binding hist does not …

---

## [Overloading struct and related methods](https://discourse.julialang.org/t/overloading-struct-and-related-methods/8285)

<div class="topic-metadata">

**Author:** [@Oliver\_Lylloff](https://discourse.julialang.org/u/Oliver_Lylloff)\
**Replies:** 5\
**Last updated:** [January 11, 2018, 10:36am UTC](https://discourse.julialang.org/t/overloading-struct-and-related-methods/8285 "2018-01-11T10:36:11Z")

</div>

Hi there, I want to use a struct and related methods from the package ProximalOperators.jl. Specifically, I want to change the field lambda of an immutable struct. MWE: using ProximalOperators function foo(g::T) wher…

---

## [Gtk build fail, Ubuntu 16.04, Julia v0.6.0](https://discourse.julialang.org/t/gtk-build-fail-ubuntu-16-04-julia-v0-6-0/8276)

<div class="topic-metadata">

**Author:** [@skalet](https://discourse.julialang.org/u/skalet)\
**Replies:** 4\
**Last updated:** [January 11, 2018, 9:44am UTC](https://discourse.julialang.org/t/gtk-build-fail-ubuntu-16-04-julia-v0-6-0/8276 "2018-01-11T09:44:26Z")

</div>

I built Julia v0.6.0 from source on Ubuntu 16.04. Then the first thing I try to do is to install Gtk, which fails, the complete output and backtrace is given below. I get the same error when I try with the latest bina…

---

## [Is there a way to make macros consume forms past a newline?](https://discourse.julialang.org/t/is-there-a-way-to-make-macros-consume-forms-past-a-newline/8284)

<div class="topic-metadata">

**Author:** [@jballanc](https://discourse.julialang.org/u/jballanc)\
**Replies:** 3\
**Last updated:** [January 11, 2018, 9:25am UTC](https://discourse.julialang.org/t/is-there-a-way-to-make-macros-consume-forms-past-a-newline/8284 "2018-01-11T09:25:32Z")

</div>

Reading through the recent thread asking if there’s a way to mimic the behavior of Python’s decorators, it occurred to me that, while semantically Julia’s macros are strictly more powerful than method decorators, stylist…

---

## [Help making a literal function type](https://discourse.julialang.org/t/help-making-a-literal-function-type/8278)

<div class="topic-metadata">

**Author:** [@Mason](https://discourse.julialang.org/u/Mason)\
**Replies:** 2\
**Last updated:** [January 11, 2018, 2:37am UTC](https://discourse.julialang.org/t/help-making-a-literal-function-type/8278 "2018-01-11T02:37:54Z")

</div>

So I’m working on a bit of a pet project which involves rolling my own computer algebra system. So far its really fun but I’m getting stuck with trying to define a special type of function called a literal\_function. The …

---

## [Resolving dependencies with \`Requires\` in precompiled packages](https://discourse.julialang.org/t/resolving-dependencies-with-requires-in-precompiled-packages/8270)

<div class="topic-metadata">

**Author:** [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Replies:** 1\
**Last updated:** [January 10, 2018, 3:43pm UTC](https://discourse.julialang.org/t/resolving-dependencies-with-requires-in-precompiled-packages/8270 "2018-01-10T15:43:49Z")

</div>

Suppose I have modules A, C and B and that A contains using C; using B. If B contains @require C code and A and B are both precompiled, then code is never called and any functions declared there are never accessible fro…

---

## [Conda: newer version of conda exists run "..."](https://discourse.julialang.org/t/conda-newer-version-of-conda-exists-run/8124)

<div class="topic-metadata">

**Author:** [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Replies:** 1\
**Last updated:** [January 10, 2018, 1:32pm UTC](https://discourse.julialang.org/t/conda-newer-version-of-conda-exists-run/8124 "2018-01-10T13:32:56Z")

</div>

Does anyone else here have the following problem? using Conda; Conda.update(); INFO: Recompiling stale cache file C:\\Users\\Ilja\\.julia\\lib\\v0.6\\Conda.ji for module Conda. Solving environment: ...working... done # All…

---

## [Getting a stack trace with function argument values](https://discourse.julialang.org/t/getting-a-stack-trace-with-function-argument-values/529)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 12\
**Last updated:** [January 10, 2018, 11:06am UTC](https://discourse.julialang.org/t/getting-a-stack-trace-with-function-argument-values/529 "2018-01-10T11:06:30Z")

</div>

When an error is not caught, Julia shows a stack trace with the method signatures. This is informative, but sometimes the actual arguments to the functions would be very useful too. Is there a way to have them shown? Usi…

---

## [Why MYPACKAGE is forcing other package downgrade (with an unbounded require)?](https://discourse.julialang.org/t/why-mypackage-is-forcing-other-package-downgrade-with-an-unbounded-require/8229)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 5\
**Last updated:** [January 10, 2018, 9:36am UTC](https://discourse.julialang.org/t/why-mypackage-is-forcing-other-package-downgrade-with-an-unbounded-require/8229 "2018-01-10T09:36:30Z")

</div>

Hello I develop a package (OdsIO) whose require is: julia 0.5 PyCall 1.7 DataFrames 0.8.0 DataStructures 0.5.0 I have read the require file format specifications, and the format I use should indicate any version higher…

---

## [Some queries about macro Horner](https://discourse.julialang.org/t/some-queries-about-macro-horner/8258)

<div class="topic-metadata">

**Author:** [@Sabodhapati](https://discourse.julialang.org/u/Sabodhapati)\
**Replies:** 2\
**Last updated:** [January 10, 2018, 2:38am UTC](https://discourse.julialang.org/t/some-queries-about-macro-horner/8258 "2018-01-10T02:38:57Z")

</div>

In Macros for numerical performance: Horner’s methodhttps://github.com/stevengj/18S096-iap17/blob/master/lecture4/Metaprogramming.ipynb, macro hornor is defined as follows: copied from base/math.jl macro horner(x, p...)…

---

## [Call-site inlinine/noinline](https://discourse.julialang.org/t/call-site-inlinine-noinline/8254)

<div class="topic-metadata">

**Author:** [@foobar\_lv2](https://discourse.julialang.org/u/foobar_lv2)\
**Replies:** 0\
**Last updated:** [January 9, 2018, 6:06pm UTC](https://discourse.julialang.org/t/call-site-inlinine-noinline/8254 "2018-01-09T18:06:16Z")

</div>

I wanted to ask whether there currently is a way to specify inlining at the call-site (which would hopefully override any callee declarations). I found the issue https://github.com/JuliaLang/julia/issues/1106, which is c…

---

## [Outer constructor results in StackOverflowError](https://discourse.julialang.org/t/outer-constructor-results-in-stackoverflowerror/8246)

<div class="topic-metadata">

**Author:** [@tpoisot](https://discourse.julialang.org/u/tpoisot)\
**Replies:** 4\
**Last updated:** [January 9, 2018, 4:35pm UTC](https://discourse.julialang.org/t/outer-constructor-results-in-stackoverflowerror/8246 "2018-01-09T16:35:28Z")

</div>

I’m trying to add an outer constructor for a parametric type, so that the object is only returned if it passes some tests. Here’s a MRE of what I’m trying to do: abstract type MyAbstractType end mutable struct MyType{S…

---

## [Breaking circularity in fallback methods](https://discourse.julialang.org/t/breaking-circularity-in-fallback-methods/8219)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 4\
**Last updated:** [January 8, 2018, 4:25pm UTC](https://discourse.julialang.org/t/breaking-circularity-in-fallback-methods/8219 "2018-01-08T16:25:37Z")

</div>

I have two functions f(x, y) and g(x, y). For some types of x, it may be advantageous to reuse components of calculations when both are needed, for some other types this is not the case. On the other hand, sometimes I ju…

---

## [String encodings help](https://discourse.julialang.org/t/string-encodings-help/8188)

<div class="topic-metadata">

**Author:** [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Replies:** 7\
**Last updated:** [January 6, 2018, 8:21am UTC](https://discourse.julialang.org/t/string-encodings-help/8188 "2018-01-06T08:21:36Z")

</div>

I’m looking for some help in determining what character sets are compatible with UTF-8 and therefore safe to be transcoded from Vector{UInt8} using the String constructor. I’m not an expert with character coding and not…

---

## [Julia cookbook, help appreciated](https://discourse.julialang.org/t/julia-cookbook-help-appreciated/8204)

<div class="topic-metadata">

**Author:** [@ivo\_welch](https://discourse.julialang.org/u/ivo_welch)\
**Replies:** 4\
**Last updated:** [January 7, 2018, 1:14am UTC](https://discourse.julialang.org/t/julia-cookbook-help-appreciated/8204 "2018-01-07T01:14:35Z")

</div>

I am working on an open cookbook for Julia. It sits at http://julia.cookbook.tips/ . It should be complementary and not substitutional to the official Julia docs. I would think the cookbook already has its moments. t…

---

## [ODBC connection error](https://discourse.julialang.org/t/odbc-connection-error/8213)

<div class="topic-metadata">

**Author:** [@jzicker](https://discourse.julialang.org/u/jzicker)\
**Replies:** 0\
**Last updated:** [January 7, 2018, 12:57am UTC](https://discourse.julialang.org/t/odbc-connection-error/8213 "2018-01-07T00:57:56Z")

</div>

First time using ODBC.jl Attempting to access data in snowflake. I can see the driver is installed and when I use ODBC.DSN(…) I get UndefVarError: tZ not defined I searched code in odbc.jl and couldn’t find any r…

---

## [Semantic or structured logging](https://discourse.julialang.org/t/semantic-or-structured-logging/8200)

<div class="topic-metadata">

**Author:** [@stemann](https://discourse.julialang.org/u/stemann)\
**Replies:** 1\
**Last updated:** [January 6, 2018, 10:26pm UTC](https://discourse.julialang.org/t/semantic-or-structured-logging/8200 "2018-01-06T22:26:44Z")

</div>

@Chris\_Foster It seems the new logging framework / MicroLogging supports structured/semantic logging by allowing additional key/value pairs in addition to a message. Is it possible to only give a string interpolation exp…

---

## [Passing an array of structures through \`ccall\`, clarification](https://discourse.julialang.org/t/passing-an-array-of-structures-through-ccall-clarification/8151)

<div class="topic-metadata">

**Author:** [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Replies:** 9\
**Last updated:** [January 6, 2018, 7:41pm UTC](https://discourse.julialang.org/t/passing-an-array-of-structures-through-ccall-clarification/8151 "2018-01-06T19:41:55Z")

</div>

I tried to follow the discussion in because i need to solve a similar problem: C-API expects an array of struct. Do i understand correctly, that there are exactly two options: write glue code in C that interfaces a …

---

## [Good practices for package development in the Julia ecosystem](https://discourse.julialang.org/t/good-practices-for-package-development-in-the-julia-ecosystem/8175)

<div class="topic-metadata">

**Author:** [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Replies:** 12\
**Last updated:** [January 6, 2018, 6:32pm UTC](https://discourse.julialang.org/t/good-practices-for-package-development-in-the-julia-ecosystem/8175 "2018-01-06T18:32:18Z")

</div>

Sorry if these questions are very basic, I am a social scientist with no formal exposure to software development techniques, especially on how to integrate to an ecosystem of packages, so my knowledge about this is prett…

---

## [Scalar divided by range or array](https://discourse.julialang.org/t/scalar-divided-by-range-or-array/8196)

<div class="topic-metadata">

**Author:** [@mlhetland](https://discourse.julialang.org/u/mlhetland)\
**Replies:** 5\
**Last updated:** [January 6, 2018, 4:39pm UTC](https://discourse.julialang.org/t/scalar-divided-by-range-or-array/8196 "2018-01-06T16:39:49Z")

</div>

Mostly, it seems that using scalars and arithmetic operations with arrays and ranges gives me what I suspect. However, dividing a scalar by an array is not defined, whereas the elementwise version is (as opposed to other…

---

## [Is there a way to check how "far away" a pointer is from a page boundary?](https://discourse.julialang.org/t/is-there-a-way-to-check-how-far-away-a-pointer-is-from-a-page-boundary/8147)

<div class="topic-metadata">

**Author:** [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Replies:** 20\
**Last updated:** [January 6, 2018, 3:31pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-check-how-far-away-a-pointer-is-from-a-page-boundary/8147 "2018-01-06T15:31:48Z")

</div>

I am quite new to understanding how memory works so please do correct me if I get the terminology and concepts wrong. Update Base on @stevengj’s suggestion, here is an MVE of my function. The unsafe part is step1 but …

---

## [Benchmarking with PkgBenchmark.jl](https://discourse.julialang.org/t/benchmarking-with-pkgbenchmark-jl/3038)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 15\
**Last updated:** [January 6, 2018, 3:20pm UTC](https://discourse.julialang.org/t/benchmarking-with-pkgbenchmark-jl/3038 "2018-01-06T15:20:26Z")

</div>

Can you please share your workflow with PkgBenchmark.jl? From what I understood in the README, we are supposed to manually run the benchmarks locally and compare the results between two commits/branches. I wonder how do…

---

## [Interpolating function arguments](https://discourse.julialang.org/t/interpolating-function-arguments/8191)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 8\
**Last updated:** [January 6, 2018, 3:15pm UTC](https://discourse.julialang.org/t/interpolating-function-arguments/8191 "2018-01-06T15:15:52Z")

</div>

Say I have args = :(x,y) and I’d like to build goal = :(function(x,y) 0 end) The closest I’ve been able to get is :(function($args...) 0 end) but that simplifies to :(function ((x, y)...,) 0 end) Anyo…

---

## [Using eval inside macro?](https://discourse.julialang.org/t/using-eval-inside-macro/8183)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 4\
**Last updated:** [January 6, 2018, 12:34pm UTC](https://discourse.julialang.org/t/using-eval-inside-macro/8183 "2018-01-06T12:34:25Z")

</div>

I have a macro that takes a type as input and enhances it with a keyword constructor. struct Foo a;z end @macroexpand @keyword\_constructor Foo :(Foo(; a=nothing, z=nothing) = begin # In\[2\], line 9: Foo(a, …

---

## [Unsafe\_copyto! in function body problem](https://discourse.julialang.org/t/unsafe-copyto-in-function-body-problem/8187)

<div class="topic-metadata">

**Author:** [@Liso](https://discourse.julialang.org/u/Liso)\
**Replies:** 2\
**Last updated:** [January 5, 2018, 7:11pm UTC](https://discourse.julialang.org/t/unsafe-copyto-in-function-body-problem/8187 "2018-01-05T19:11:29Z")

</div>

julia\> function copy\_bits(s::String) assert(sizeof(s)\>=8) res = UInt(0xffff) # WARNING! Don't try to use zero(UInt)! p=reinterpret(Ptr{UInt8}, pointer\_from\_objref(res)) uns…

[Previous page](https://discourse.julialang.org/c/usage/6.md?page=1002)

[Next page](https://discourse.julialang.org/c/usage/6.md?page=1004)
