Questions(ss) about function import and type, parsing, OCaml code importing, compiling and regex syntax

Hi !

[If you don’t understand my english, tell me, it may be normal :stuck_out_tongue: ]

I’ve some beginner questions (again). But certainly I don’t understand because I don’t understand the Julia’s behaviour. I’ve some knows about programming language (i’ve already made a little compiler, but that was some years ago).

  • What do we need to import functions in order to extend them ? If we can call them, that means their name are known, no ? So, what can’t you extend them ? What is the Julia’s behaviour ?

  • What about the functions type ? typeof(f) tells me typeof(f). If I’ve well understood, that’s because each function has its own type, and all the “functions” are methods. That means that I can’t tell, in some syntax example(f::Function{Int64,Int64}, arg::Int64) = f(x+1) - 1 which Function{Int64,Int64} is the function type Int64 -> Int64 ?
    (in fact, i’ve seen that seem to exists some ways to do this in the doc, but I havn’t understood)

  • Does there exist tools in order to do syntax analysis in Julia ? (to make a parser, as Menhir in OCaml) If no, is it possible to “import” OCaml code ? (i’ve seen it’s possible with at least C and Python code)

  • In a similar way, does there exist in Julia a package to manage the “inputs/parameters” of my program ? In example : julia myprogram.jl -o output -g parameter, a package which simplify the managing of the -o output and the -g parameter ?

  • Is it possible to “compile” Julia ? To make an executable, which would work without the Julia interpretor ?

  • I havn’t found the supported regex syntax in Julia. I’ve searched in the PCRE Ruby doc, but I havn’t found yet : is it somewhere ?

I think it’s all ! Thanks for reading and mayber answering ! (and thanks another time to the Julia’s developpers :smiley: )

Some answers for the questions I know:

For the other questions, I didn’t understand the first one, the one on OCaml I think the answer is « no », and the question about arguments you might want to consider but others may give better input

Regarding the first two questions:

  1. nope, you don’t need to import to define a method, you can also quality a name, eg

    Base.length(foo::Foo) = length(foo.contents)

    This is a design choice for Julia.

  2. See this discussion about function types for pointers.

1 Like
  • Thanks, that seems to do what I want !
  • ok :slight_smile:
  • I meant that I wanted the abstract syntax of the right regex in Julia language. It seemed to me that there could be little differences in the regex syntax among the languages. Am I wrong ?
  • What is the hidden behaviour of Julia indeed ?

  • Errr, this discussion is a little bit empty, linkless. If I ask, that means that I didn’t find answers, and I don’t have really time in order to read a thesis.

Correct, that’s not a feature of Julia right now. In most cases, we deal with this by duck-typing (that is, just accepting any function and throwing an error later on if it turns out to not accept the desired type).

If you really need to specify a particular method with specific input and output types, consider GitHub - yuyichao/FunctionWrappers.jl

Yet the people who answered your questions had time to read them, even though you put 5 of them in a single topic.

Some questions don’t have single-paragraph answers.


If you are referring to either explicit import or qualified method names, it has a simple explanation.


module Foo
using Bar # has no function baz
baz() = 1

Now imagine that the developers of Bar introduce their own function baz and export it. From that point you would be adding/overwriting methods to that, which can lead to bugs (search for type piracy).

EDIT I just realized that this is covered in the FAQ.

1 Like

From the doc I linked to, first paragraph of the regex section:

Julia has Perl-compatible regular expressions (regexes), as provided by the PCRE library.

This page has the PCRE syntax:

If anyone feels like making a contribution, adding a direct link to that to the docs would be great.



Thanks ! It’s exactly what I searched !