Iter has quit [Read error: 110 (Connection timed out)]
okui53 has quit [Read error: 110 (Connection timed out)]
mr_bubbs has joined #ocaml
GreyLensman has joined #ocaml
<Smerdyakov>
vincenz, what? (I was away.)
<vincenz>
well Cil uses frontc ;)
<vincenz>
(an updated version)
<Smerdyakov>
Cil is based on Frontc. Most all of it has been changed and improved.
<vincenz>
yup
<vincenz>
I think I'll use it
<vincenz>
but I still want to do the excercise of writing a c-parser, albeit not as robsut
<vincenz>
want to know something neat?
<vincenz>
{x x;} is valid
<vincenz>
(given x has been typedef in an outer scope)
<Smerdyakov>
I wouldn't necessarily call it "neat."
<Smerdyakov>
OCaml supports the same thing, since types and values are in separate namespaces.
<vincenz>
yup, but in c they aren't
<Smerdyakov>
Which shows that C is dumb, not the other way around. :P
<vincenz>
I'm not bashing ocaml
<vincenz>
I love ocaml
<Smerdyakov>
I'm just saying. It's "icky," not "neat."
<vincenz>
have any experience with pcaml?
<vincenz>
I mean camplp4
<Smerdyakov>
No
<vincenz>
damn
<vincenz>
I was thinking that it might be handy to automatically generate functions that dump an AST to ocaml-syntax
<Smerdyakov>
It doesn't seem tobe too popular.
<Smerdyakov>
If you want that, then you want Haskell, with automatic derivations of the Show type class. :)
<vincenz>
I looked at it once, you have to get into it quite a bit before being able to use it
<vincenz>
didn't feel like investing the time then
<vincenz>
What's new in ocaml 3.08?
<vincenz>
wrt 3.07
<Smerdyakov>
Halting problem library
<vincenz>
Halting problem library?
<Smerdyakov>
That was a CS joke. Maybe you should just read the release notes.
<vincenz>
I did
<vincenz>
some fixes, biggest thing seems to be the objects without class def
<Smerdyakov>
*Yawn*. Like anyone uses the OO stuff. ;)
<vincenz>
I dunnow, sometimes it's handy
<Smerdyakov>
Rarely
<vincenz>
though modules and Objects are imho completely interchangeable
<Smerdyakov>
Oh, no, that's quite wrong.
<vincenz>
just like c++-classes (without virtuals) and structs with explicti functions
<Smerdyakov>
Modules use static dispatch and objects dynamic dispatch.
<vincenz>
true
<vincenz>
but I rarely use inheritance
<vincenz>
so it boils down to the same
<Smerdyakov>
Inheritance is an orthogonal issue in OCaml.
<Smerdyakov>
Subtyping is by structural compatibility.
<vincenz>
anyways the reason I sometimes I choose objects is to encapsulate things
<Smerdyakov>
That would be the reason you should choose modules, if you aren't using dynamic dispatch.
<vincenz>
that way I don't need global variables, it's all nicely fitted in an object and you can then clone that..
<vincenz>
and I can clone it and all
<Smerdyakov>
You haven't yet said anything that shows why modules are undesirable for this.
<vincenz>
convenience
<vincenz>
personal choice
<vincenz>
;)
<Smerdyakov>
Abstract data types are much cleaner. Why use a feature with more conceptual baggage than you use?
<vincenz>
welll an environment table requires two parts
<vincenz>
the hashmap
<vincenz>
and a list of list of strings
<vincenz>
to push and pop contexts
<vincenz>
if I put them both in a class
<vincenz>
I can easily clone it
<vincenz>
and just pass on object to my lexer rule
<vincenz>
instead of passing two
<vincenz>
and it allows me to do env#add
<Smerdyakov>
Do you even know what I mean by "abstract data type"? It sounds like you don't.
<vincenz>
instead of EnvironmentModule.add env ..
<vincenz>
I'm only halfreading it's late
<vincenz>
yes I know what an ADT is, it's a signature
<Smerdyakov>
No.
<vincenz>
(like java interface or a pure abstract class in c++)
<Smerdyakov>
In ML, signatures may _contain_ abstract types.
<Smerdyakov>
But the concepts are not conflated.
<vincenz>
hmm
<Smerdyakov>
Plus, all you need is a balanced tree to implement functional environments.
<Smerdyakov>
No need for multiple components.
<vincenz>
with functional environment are you referring to the symboltable?
<vincenz>
and yes in ML signature can contain ADTs...I was referring to a more general term...I was seeing a signature like a java interface
<vincenz>
(like I said, my background is EE so I'm not familiar with the lingo)
<Smerdyakov>
I mean the environment ADT, which maps symbols to whatevers.
<vincenz>
yes
<vincenz>
you say a balanecd tree suffices?
<Smerdyakov>
Yes.
<Smerdyakov>
That's what I always use.
<vincenz>
so how do you know what bindings to remove on a pop_contexT?
<vincenz>
and why would it be balanced? whenever you're in any block...you only have one straight line back to the main_context
<Smerdyakov>
You never remove bindings. Conceptually, you have a separate environment value for every logically different environment.
<vincenz>
ah
<Smerdyakov>
The fact that it is balanced is only relevant for efficiency reasons. It has no effect on the tree ADT.
<vincenz>
well I looked a bit at frontc for inspiration,and they use a list of list of strings (each list of strings is a context so you ahve a stack) and when you pop a context yuo remove all the bindings in the top-context from the hashmap
<vincenz>
but I can see where you're going
<vincenz>
it seems to be something similar to what appel uses as first example in his book
<vincenz>
however
<vincenz>
if you're using balanced trees, don't you risk that each new environment has a complete new table due to table-pivoting instead of reusing the tree from the outer-environment?
gl has quit [Read error: 110 (Connection timed out)]
<Smerdyakov>
Balanced trees guarantee that almost all memory is re-used after an insert. At most O(log n) is new.
<vincenz>
true
<vincenz>
but how do balanced trees handle multiple entries with same key?
<Smerdyakov>
The structure itself encodes nothing about scope nesting.
<Smerdyakov>
It simply maintains a map from identifiers to data.
<Smerdyakov>
With the usual semantics where an inner scope identifier shadows an outer scope, this is "handled" by overwriting the old mapping.
<vincenz>
ah so it is still destructive, you still destroy the shadowed binding
<Smerdyakov>
Again, remember that we have (logically) a completely separate environments for each scope.
<vincenz>
yup
<Smerdyakov>
This is a pure functional structure. It is _impossible_ to do _anything_ destructive.
<vincenz>
which however suggest that the fact that you use a balanced tree is pure implementation details?
<vincenz>
I know
<vincenz>
I mean conceptually
<Smerdyakov>
I don't know what you mean by that.
<vincenz>
every environment has it's own tree
<Smerdyakov>
Yeah.
<vincenz>
aka, an inner environment does not reuse part of the tree of it's outer environment
<Smerdyakov>
If we forget about efficiency, "copying" the trees would work just as well, right
<vincenz>
yes, but you can use tree at a different level as well
<vincenz>
then you could have inside environment two
<vincenz>
env_table2->env_table1 as tree
<vincenz>
and at block 3
<vincenz>
env_table3 -> env_table1
<vincenz>
so basically one global tree
<vincenz>
(inverted...tree...root is at bottom)
<Smerdyakov>
Yes. You are thinking of trees of scopes. I am thinking of trees of variable mappings.
<vincenz>
can't you combine the two?
<Smerdyakov>
It is impossible to recover scoping structure from trees as I am proposing.
<Smerdyakov>
There is no significant value to "combining the two."
<Smerdyakov>
Logarithmic lookup time is pretty damned fast as it is.
<vincenz>
no true
<vincenz>
but with each environment having it's own tree
<vincenz>
you duplicate the values in a shared outer scope
<Smerdyakov>
Conceptually, but not in the real implementation.
<Smerdyakov>
You only duplicate O(log n) entries per insertion.
<Smerdyakov>
I consider that to be negligible.
<vincenz>
well on n insertions that's n log n
<Smerdyakov>
Which is only a log n factor worse than optimal.
<vincenz>
how so?
<vincenz>
with my system nothing is duplicated
<Smerdyakov>
You can't perform n operations in o(n) time.
<Smerdyakov>
With your system, nothing is duplicated, but you have to do work to undo changes.
<Smerdyakov>
It's not clear that you save much that way.
<vincenz>
well it's a tradeoff between time and space
<vincenz>
and I'm not sure I have to do work to undo changes
<vincenz>
in block 2 ...I construct a tree on top of tree of block 1
<vincenz>
then in block 3 I refetch the lbock 1 tree and do it again
<Smerdyakov>
Ah, gotcha.
<Smerdyakov>
Now it may be much more expensive to look up mappings.
<Smerdyakov>
Your structure is optimized for quick insertions and pays in lookup time.
<vincenz>
not really
<vincenz>
lookup time for me is
<vincenz>
(k log n/k)
<vincenz>
with k = depth
<vincenz>
n = num entries
<vincenz>
look in hashmap at block..if not found. bounce up (down?) the tree
<Smerdyakov>
Not really, since you have no guarantee that scopes will have comparable numbers of variables.
<Smerdyakov>
You might have all single-variable scopes.
<vincenz>
hmm true
<Smerdyakov>
Now you have the worst lookup structure imaginable.
<vincenz>
however c usually doesn't have such a deep scope
<vincenz>
block nesting is usually around 3....with 10 being a very pessimistic worst-case
<Smerdyakov>
If the majority of variables are at level 3, you will lose big time with your structure.
<vincenz>
(you mean in the most outerscope?)
<Smerdyakov>
No, the innermost scope.
<vincenz>
euhm no
<vincenz>
if all variables are innermost scope
<vincenz>
then it's just log n
<Smerdyakov>
Every mapping at the top level will need to do logarithmically many comparisons at levels 2 and 3 before being found.
<Smerdyakov>
When it might have been found right away with a single balanced tree.
<vincenz>
I guess
<vincenz>
I dunno
<Smerdyakov>
Also, you have shadowed bindings building up in the tree.
<Smerdyakov>
With enough variable name reuse, this can increase the total search time asymptotically.
<vincenz>
hehe
<vincenz>
it's obvious our backgrounsd differ
<Smerdyakov>
This is quite important for ML.
<vincenz>
EE is all about the common case, CS is all bout going into the details of worst case
<Smerdyakov>
A very common style is to redefine a variable over and over, where in an imperative language you might be assigning to it with expressions based on its past value.
<vincenz>
yes
<vincenz>
but I -am- working with c
<vincenz>
well c++ converted to c
<Smerdyakov>
Yes, and you've already said that you are doing this as a learning experience and don't even plan to use it for research, so it doesn't matter what you do!
<vincenz>
lol
<Smerdyakov>
Cil gives unique identifiers to all variables, so the issue goes away there.
<vincenz>
not really
<vincenz>
I want original variable-names
<vincenz>
cause I have to do source to source
<vincenz>
with as little name-mangling as possible
<vincenz>
aka
<Smerdyakov>
So? When will you be _looking_up_ original variable anmes?
<vincenz>
oh yeah
<vincenz>
can Cil regenerate c equal to it's input (not considering whitespace and comments)?
<Smerdyakov>
No
<vincenz>
hmm
<Smerdyakov>
It changes code to have at most one side effect per statement, for example.
<vincenz>
but can't you turn that processing off?
<Smerdyakov>
No. That's the format in which code is stored. There's no user-accessible structure for genuine C parse trees.
<vincenz>
hmm
<vincenz>
that might actually be a make or break
<Smerdyakov>
C is a write-only language, anyway.
<Smerdyakov>
I don't worry too much about generating readable output. :)
<vincenz>
I do
<Smerdyakov>
Why?
<vincenz>
because my transformation is one of many of this methodology flow-chain of imec for power-optimizations
<Smerdyakov>
So?
<vincenz>
and later steps need user-guidance
<vincenz>
which means code-comprehension
<Smerdyakov>
Ah, I see.
<vincenz>
if I completely change the code..
<vincenz>
they're methodology steps
<vincenz>
they're not compiler steps
<Smerdyakov>
I would think you'd never want to ask the user to understand code generated automatically.
<vincenz>
lots of exploration and such
<vincenz>
no, that's actually the big issue
<vincenz>
that the generated c-code is readable and understandable (preferably from just having read the initial source code)
<Smerdyakov>
Well, I would say that, first off, someone who cares about efficient code shouldn't be using C.
<vincenz>
well
<vincenz>
the issue is that most multimedia software (mpeg what not) is written in c
<vincenz>
and then if people want to put it on portable devices
<vincenz>
they have to optimize it for power
<Smerdyakov>
Where there are important optimizations that the compiler needs help to perform, the relevant hints should be included in the original software as annotations.
<vincenz>
something the people writing the multimedia software are not trained in
<vincenz>
for instance, my test-code right now is the wavelet-decoder of the VTC (mpeg4)
<Smerdyakov>
I would recommend trying to construct a system of annotations that will provide all the information you need, so that the user never needs to be queried.
<vincenz>
yup
<vincenz>
oh wait
<vincenz>
well the issue is that the subsequent steps are exploratory steps, aka profiling is added in and tests are made and then decisions are made
<vincenz>
to know what to explore you need to know the dominant ddts
<vincenz>
then after that
<vincenz>
exploration of how to transform the code in different tasks is done, yet again with manual code changes (this is not my research it's been done)
<vincenz>
and then other steps
<vincenz>
let me try to fetch the paper we sent to SIPS
<vincenz>
I think it shows a graph of the methodology flow
<Smerdyakov>
Well.... I probably wouldn't find it very interesting. Not my sort of thing.
<Smerdyakov>
And I'm leaving now. :)
<vincenz>
no need to read it, just the image, but alright
<vincenz>
anyways, I have my reasons for generating code as close as possible to the origina
_fab has joined #ocaml
fab__ has quit [Read error: 110 (Connection timed out)]
durnew has quit ["Leaving"]
avn has quit [Read error: 54 (Connection reset by peer)]
avn has joined #ocaml
GreyLensman has quit ["Leaving"]
Xolution has quit ["Leaving"]
avn has quit [Read error: 60 (Operation timed out)]
avn has joined #ocaml
mrsolo_ has joined #ocaml
mr_bubbs has left #ocaml []
domaro has joined #ocaml
<domaro>
wow, this many people actually use ocaml? lol
<domaro>
anyone use meta-ocaml?
domaro has left #ocaml []
mrsolo_ has quit [Read error: 113 (No route to host)]
mrsolo_ has joined #ocaml
vezenchio has joined #ocaml
mlh has quit [Client Quit]
<vincenz>
I googled
<vincenz>
no real explanation of what meta-ocaml is
gim has joined #ocaml
mlh has joined #ocaml
karryall has joined #ocaml
Frag-101 has quit [Remote closed the connection]
pflanze has joined #ocaml
gl has joined #ocaml
Axioplase has joined #ocaml
Axioplase has quit [Read error: 104 (Connection reset by peer)]
kinners has joined #ocaml
gl has quit [Read error: 104 (Connection reset by peer)]
Iter has joined #ocaml
kinners has quit ["leaving"]
schwarze has joined #ocaml
Xolution has joined #ocaml
jrosdahl has quit [Read error: 110 (Connection timed out)]
moonfish` has joined #ocaml
schwarze has quit ["El lenguaje ha muerto. Y todas las palabras se han vuelto sospechosas"]
<moonfish`>
is there a way to desugar cons? (::) gives me an error, but (@) works fine.
moonfish` is now known as moonfish
<gim>
let cons a b = a :: b ?
<moonfish>
yes, I know that; but *why* does (::) not work?
<moonfish>
the docs imply that (op) should work for all operators.
<karryall>
moonfish: (::) is a constructor
<karryall>
(@) is an identifier for a function
<karryall>
in caml constructor cannot be used as functions
<moonfish>
That makes sense, kind of. So when the manuals talk about the "cons operator" they are using incorrect terminology?
<karryall>
I'd say yes
<karryall>
where is that ?
moonfish has left #ocaml []
moonfish has joined #ocaml
<moonfish>
it's worse than I thought: "The expression expr1 :: expr2 stands for the constructor ( :: ) applied to the argument ( expr1 , expr2 )" [Section 6.7.3]
<karryall>
so, they're talking about a constructor, not an operator :)
<moonfish>
and imply that (::) is valid syntax!
<moonfish>
and in section 1.2 they talk about "the :: (``cons'') operator".
<karryall>
ah, well not explicitly
<moonfish>
at the very least there is an inconsistency between the explict references to cons as an operator vs cons as a constructor in different places in the manual.
<karryall>
it depends on your definition of operator
<karryall>
operator = identifier with special characters (: $ @ etc.) with infix parsing
<karryall>
:: is an operator and a constructor
<karryall>
@ is an operator and a function
<moonfish>
ah, I see.
<karryall>
you can partially apply constructor hence (::) is not allowed
agentDMT has joined #ocaml
<karryall>
I mean you *cannot*
<agentDMT>
new to ocaml... trying to figure out why i get this error Unbound value Scanf.Scanning.end_of_input when #use some provided code
<agentDMT>
can anyone help?
<moonfish>
thanks for your help. it all makes sense now. I wish the manuals were more clear & explicit on that point though.
mlh has quit [Client Quit]
agentDMT has quit ["Leaving"]
Tchou has joined #ocaml
Tchou is now known as Banana
<Banana>
greetings, folks.
jrosdahl has joined #ocaml
mrsolo_ has quit [Read error: 110 (Connection timed out)]
CosmicRay has joined #ocaml
monochrom has joined #ocaml
karryall has quit ["tcho"]
Smerdyakov has quit [Remote closed the connection]
_fab has quit []
Smerdyakov has joined #ocaml
bk_ has joined #ocaml
CosmicRay has left #ocaml []
mflux has quit [Remote closed the connection]
Hadaka has quit [Read error: 110 (Connection timed out)]
mflux has joined #ocaml
Naked has joined #ocaml
Naked is now known as Hadaka
vezenchio has quit ["Hydrocon technology produces two waste products: steam and green goo. We dispose of the steam through various vents, strategi]
gim has quit ["bye"]
mlh has joined #ocaml
zigong_ has quit [Read error: 104 (Connection reset by peer)]