Player is loading...

Embed

Copy embed code

Transcriptions

Note: this content has been automatically generated.
00:00:01
and i don't and plastic yeah i work in the land here at e. p. f. l. uh and
00:00:07
and i'm working on a metal programming for that the um
00:00:12
so first uh uh we're going to focus more on macros than other kind of a matter programming
00:00:18
in this presentation uh uh and so for me to to start the stock
00:00:22
where i'm going to quickly uh say something about this colour to markers and so
00:00:28
the implementation was a quite coupled with the the the compiler a galaxy comparing journals
00:00:35
this lead to some portability issues even lean in a different version of a scholar to
00:00:42
two ex uh and which make it quite impossible to two ports to dot
00:00:48
the there were quite a few times and of course it was deemed impossible
00:00:53
so what we did for lotteries redesign the core of the of
00:00:57
the button bright infrastructure and i and we focused on the in
00:01:03
firstly more uh more portable uh leveraging the a tasty file format that
00:01:09
we have now and we also focus on making this life simpler and safer for
00:01:15
both the implement there's of of the macros and the users of the macros
00:01:22
and and you also uh that's a new language features which sometimes are
00:01:28
i just can't just be used instead instead of the market that we have we would have uses colour to and
00:01:35
so we're going to cover the these three topics uh first is in line as a matter of programming feature
00:01:42
uh then we're going to cover much types to compute new
00:01:45
new types and then we'll get into michael's which is really
00:01:50
uh and user written code that will execute some code
00:01:53
to compute some new program that will be generated uh
00:01:59
in place and there we have two subsections which are the quotas places which is a simple high level a. p. i.
00:02:05
and then we have the take your facts which is the equivalent of the obstruction that we have right now a in
00:02:11
in this colour to macros but they're a bit more restrictive and we're going to see exactly what are the details of that later
00:02:20
so first in line so so in line seems like it's just um an optimisation i going
00:02:27
i'm going to take this call don i'm going to put it wherever i'm going to call
00:02:32
this method but later we're going to see how we can make this do much more so first uh to the syntax so we have a
00:02:41
this young man keyword that we can put beef in a deaf and in
00:02:45
this case we have a knock knock him metal that will take a message
00:02:50
print it and then we're computes on tonk well uh would print the result and then we'll return that result
00:02:57
so having this in anti war to current yes that this method will be
00:03:00
lined it might also be recursive so we can use log inside of log
00:03:06
and we also have a way to specialise the return type i'm going to
00:03:10
go more on that later and it's also the entry point for macros so
00:03:17
micro is just a way to implement this in line at that
00:03:23
so here we can see the club the object rather where we implement these lot function a method
00:03:29
and and here we we we defined an idea
00:03:32
of variable like bent which which is public and
00:03:37
then inside of the implementation what we do is print the message we increase the side and then we
00:03:43
compute the result of the out of print of the tonk um and finally we decrease the i bent
00:03:50
now uh the important point here is that a tonk most is a
00:03:55
an a binding because we don't want to computed before we print the message
00:04:01
and but no there's no but where we actually used this this log operation which with our
00:04:06
power function and we print a message just before the basically tells us which power were computing
00:04:13
well when when line this hold it will look something like this so the message
00:04:19
will be put it in a in a while then we're going to have the the print line just uh before
00:04:26
the i band will be going to prosecute because we're
00:04:28
not directly inside of the of the object anymore ah and
00:04:33
we are going to have then the computation of the power ah and
00:04:38
we're going to continue you with the online on and intonation would print
00:04:44
a result so as i said before it's important to have these distinctions
00:04:48
between and by name and by value so if we have a by name
00:04:52
parameter what we usually do is via evaluated the the um
00:04:58
the the argument and then pass the result of the function but with the by name parameter we
00:05:04
just passed away to computer this in the inside of the body of log
00:05:09
so we need to keep the semantics when when nine uh here we we basically to do that we just
00:05:15
in line completely the cold that was into punk directly in words used
00:05:21
and now imagine if the hour i dent variable would be private then whenever wherever
00:05:29
we're going to nine this we might actually not have access to this i dent
00:05:35
uh to overcome this limitation whenever we refer
00:05:39
to um to a private or a protected and
00:05:44
number uh we may create a and access or sun setters for those variables to be able to access them from outside
00:05:50
dodo successors will not be visible uh uh from the user it
00:05:54
would just be generate stuff that uh later in the pipeline um
00:06:00
now what about a recursive the in line and some code so
00:06:05
here we see a power function quite standard where we we um
00:06:11
if the the value is uh is the is the exponent is zero than we just returned
00:06:16
was one of the other exponent is uh he's
00:06:21
or we will multiply wants the value and then do the power of
00:06:26
x. to the power minus one and uh if we have a low power going to
00:06:32
multiplex twice and and uh
00:06:37
and do the exponent of that to the to the half of what
00:06:40
we had before so here we're using power inside of the definition of power
00:06:44
so how are we actually going to in line this code uh let's see for double
00:06:49
with the power of x. and then we know statically with the value of ten is and
00:06:57
therefore when we line this caught it will look something like that we see that the
00:07:02
because we knew statically ten we could constant fold it and use it wherever we had we had before and
00:07:08
and then we also know started we can also constant full
00:07:11
those uh conditions and know that the first two are are are
00:07:15
always falls so we don't we're only going to get the um the last branch therefore the actual result will be this code
00:07:24
and then we have a again a up a call to power which right you can
00:07:29
recursive mainline until we don't have any more and we get some code
00:07:33
that that looks like this which does not refer in any way to and
00:07:43
now what happens if we actually don't know statically the value of an example here
00:07:48
we have a but power where n. is just a parameter and we don't know so
00:07:52
restarting lining we're going to to get more and more code and if you see all those conditions inside of the use if
00:08:00
if this we're we're never going to be able to to know if they're
00:08:04
going to be true or false therefore this will be just anything it's a recursion
00:08:09
and to work on this issue we have a a or one
00:08:14
way to overcome this issue is to have this in lyman parameters so
00:08:18
what what it does is wherever we're going to call this power power function we need
00:08:25
the argument to that parameter to be account uh and a constant value on on constant value
00:08:30
therefore we're going to be able to consent form later on and this works well in
00:08:35
lieu primitive values that the compiler knows about on some kick ass as such as option
00:08:42
and basically things that the colour compare already knows how to optimise understands the semantics of it
00:08:49
no there's another way to achieve the same thing and for this particular case and it's a telling the if that
00:08:57
it must be reduced whenever it's in line so we had this this in line keyword but
00:09:03
this time on the on the if statement before they've segment to tell where apparently doing like this
00:09:10
if the condition is known then reduce it and if it's not then fail
00:09:16
and tell me that this thing cannot be reduced and don't try to continue
00:09:22
and this also but this will guarantee of that we only take one branch of that so if we know how this should be reduced
00:09:29
and that the and thinks that the variables if a decrease then we know that we're eventually going to finish
00:09:37
and and you're that we would get is something similar to that where is very uh we could
00:09:41
not reduced because and we don't we cannot reduce any closer because we don't know what and is if
00:09:48
now this doesn't only apply to to if then else but you
00:09:54
can also be used for a pattern matching uh with a much
00:09:58
so for this that's uh take this uh a simple encoding or for
00:10:03
they are not isolated you already have a natural longer uh which has
00:10:07
two two cases a zero or a subset successor of another not true
00:10:13
and we're going to use it to create a two int that method
00:10:18
that should be a result after in lining as just the
00:10:22
value to for this particular example because we have successor or successors
00:10:27
so how would be in the uh implement this then we put the line before the the match and then
00:10:35
this means that one of those branches should much whenever we online this code
00:10:41
in this case we're going too much twice over the successor and then at the end ones
00:10:45
on the zero and we're going to then consent for the last operation and created the two
00:10:53
and this also guarantees that we're only going to take one of those branches
00:10:59
by a star sometimes we we might want to be even more precise
00:11:04
what happens if we also want to refine the the type of what is returned
00:11:09
so for that we have this uh new notation where we're saying uh and the
00:11:16
result type is not a a normal result that but it's just a subtype of int
00:11:22
that means that after in lining this will either haven't or um or
00:11:28
more precise type such as a literal constant type like one two three
00:11:34
therefore we could just we write using the same implementation we could just get
00:11:42
it in mind and know that uh not too has actually typed literal too
00:11:49
and to see another example of this uh the c. introduce a a class directly where we
00:11:54
have a cost a reckless be that extends a and b. has a matter that it doesn't have
00:12:01
um and then we have unlimited choose that will take a billion on depending on what
00:12:07
uh if it's true or false it will either return a or b.
00:12:13
if it's true it would allow it to eight and if it's possible
00:12:17
return be so if you use that them uh that implementation we will
00:12:24
yay for val a of type approaches a choose of true will return on sunday but if we if we
00:12:33
which which was a falls we we can refine the type to something more precise which is b.
00:12:38
usually we will have just written a return type was a we would have gotten our there
00:12:44
and therefore we can actually use tons of a to restrict
00:12:49
the uh to to know that we can actually call method method a math on onto
00:12:55
the falls because we have a big which we would how would have been impossible before
00:13:02
and to that but last but not least in this category we i imagine if we want to
00:13:09
uh implement the set for function that will take a type parameter and returns set of that part
00:13:15
that type and and what we want is that if
00:13:20
we have an order on the par on the t. v. we want the uh to use
00:13:25
a three set and if we don't have an order would just fall back to her set
00:13:30
so it's hard to we would have to have done some and pride
00:13:33
very station of employees it's quite clunky in account clunky way but here
00:13:38
we can just say okay we have this him in pretty much much but here we don't we're not giving it anything to the much would
00:13:46
the the value that we're going to take is going to be searched so when uh when we do say case or the real
00:13:51
of the we're going to look for that ordering of the and if we have it then we're going to to take
00:13:57
that branch i would would instantiate the trees that if we don't have it then we would just fall back to the um
00:14:06
other set
00:14:08
and so so far we have seen how to uh and refine
00:14:13
in terms in terms and get more precise types from terms but
00:14:19
there's another way to get more precise types and it's getting getting
00:14:22
a type from another type so that's what that matches are for
00:14:27
so uh so for example that see this simple i don't much like so on the
00:14:33
right hand side we see that uh there isn't a type x. that much just some cases
00:14:38
usually we we uh please take one parameter for these things because we're
00:14:42
going too much on the parameter but we could have more type parameters
00:14:46
this case the first case will uh take a string and if it's a string our element
00:14:50
of uh our in the only element of a single bit correct or if it's an array
00:14:54
then we're going to bind a type that comes from that are a if it's an array
00:14:58
of into it would be and and if it's an array of when it will be brilliant
00:15:03
we use the same notation i seen normal pattern matching
00:15:05
aware at lower case um names a mean type bindings
00:15:12
and now that is an example so as i said um the element of strain would be equal to
00:15:17
correct it like you want to correct or and the element of an array of into would be just didn't
00:15:23
because we part to uh we will going to match the second case and
00:15:27
and the element of a list of float would be flawed because we much staircase
00:15:31
and the element of and of of near would be nothing because no one
00:15:36
is actually a list of not things so that's the nothing that we get there
00:15:43
well to get into a more complex example uh let's introduce this uh top obstruction
00:15:48
where we have a topple way it has to to stop types
00:15:52
a unit which is kind of the taking of the of the topple
00:15:55
aunt and then we have a console operator with the start calling the
00:16:01
that has a hat type undertaken type and we're going to construct um
00:16:07
couples by composing those types so but on below on the
00:16:11
left we can see how we would write to type this
00:16:14
i'm on a on the right we see the same thing but on the on the terms
00:16:21
and and now we're going to add some some interesting operations on this uh
00:16:28
the first one is the cons operator
00:16:31
so we're going to lie next to a produced some some actual call but would get is
00:16:38
that the return type is a con side which is well trivially the definition of the cons cons
00:16:44
so there is no you should there but now what happens if we go to um come cat then we tradition we wouldn't have
00:16:51
a direct way to to express that i have my last uh uh topple
00:16:55
and have my right couple and they want to take that corresponds to those two
00:16:59
two doubles concatenated was in code that we can place it's and some more complex machinery but here we
00:17:05
can just say okay give me those two types and i'm going to compute the the full concatenated type
00:17:14
and we do the same for size but in this case we're going to say that sizes
00:17:19
it's either and if i don't know the size of my topple statically from
00:17:23
the type or it's going to be a literal int if i know the size
00:17:30
to the to the the the first example but we already seen in
00:17:34
the in the remote can skew note this is the can cut implementation
00:17:39
it's quite safe or we take the left and the right s. x. and y.
00:17:44
then where we say that uh the result of can cut will always be a topple
00:17:49
uh and but maybe something more precise and then we did the actual
00:17:53
definition that will compute the type so we're going to say that is the
00:17:58
right hand side of that uh all of that can cut is empty
00:18:02
then we just take the the left hand side if we have um
00:18:07
and then to topple we're going to take the head and we're going to come cut with the tail in a knot were great concept would
00:18:14
concatenation of detail on white this is quite familiar because we would have implemented it almost the same way on this
00:18:23
where and the key difference here is that if you in the match ever and the top everything's
00:18:30
a type so the the scrutiny that type the patterns are types on the right hand side or types
00:18:35
and in the a normal case in the car can happen it's it's here we're we're pretty much on
00:18:40
time and then we have a thermos of butter and we have a right on site which is utter
00:18:46
now let's look at another and that much so this is the um that much for the a successor
00:18:53
of some particular in so ideally we should pass it a little
00:18:58
you troll didn't which is you either want to three and so on i want to return the successor of that and
00:19:05
so one way to implement it is like this which is straightforward but of
00:19:09
course this will not scale so we actually implemented directly in the compiler and
00:19:16
as and that can be found in the packets colour at compile time
00:19:21
s. for that type as of successor and now we can use this type
00:19:25
to compute size so size will take the the the type of the topple
00:19:31
we know that it will return at least uh at most i don't know if the the the
00:19:37
type of the topple is unit then we know statically that uh the
00:19:40
stop elise is empty and if not if it's not empty we can just
00:19:45
say that it's the successor of the size of the top which would be equivalent
00:19:49
to applause one it would have been doing the sucks size on the term level
00:19:56
oh
00:19:58
so not so far we have seen how to how to compute types but really precise lights but
00:20:04
we haven't seen how to get those types back into terms so for
00:20:08
this we have those two methods a constant value on cons value opt
00:20:13
the first one will take a literal and if it's a literal it would would just return that literal and
00:20:22
and if it's not it will fit compilation on the other hand the second one if
00:20:25
it's not a literal it will return on if it's adorable return some of that it all
00:20:31
now we can actually implement uh our in line method size because we're saying that we're tourist sites
00:20:38
alright inside we can just take that side that we computed the and as for the value
00:20:47
and then we can put too much on that value and just optimised away so if we actually know the
00:20:51
the value then we just use that value if not we're going to compute for but can compute at run time
00:20:59
so so far we've seen how to to generate code by
00:21:05
uh by leveraging the mostly the constant folding of the compiler
00:21:09
but here we're going to to introduce to to see how what happens if we uh we
00:21:14
actually want custom logic that should do the constant folding that's where winter just michael's which is
00:21:21
more the mayor of the old got to markets but we're going to start with the simpler simpler approach to
00:21:29
to implement them so for that we're going to introduce two two different concepts courses
00:21:34
like this so the first chords is has a visitation it has a quote um
00:21:41
i don't block inside of a plot there's an expression that expression in that case as a type t. and
00:21:49
what this does block means is not going to execute discord right now i'm just going to keep it as code
00:21:57
for later i don't want to use it later in some program and on the other hand have this place where
00:22:05
inside of some problem in this case inside of this quote i'm going to splice this piece of code and then
00:22:11
i'm going to you replace the call that is inside by this is of course this means that x. x. is
00:22:18
of type a extra fifty and whatever's inside of this uh splice is going to be computed
00:22:26
computer when we compute the coat but we're going to retain everything that is in between the cold and the splice
00:22:33
this quite similar to a stream interpol later uh the
00:22:36
syntax i uh is the signatures are quite similar um
00:22:42
but the difference is that whatever is the direct instead of a quote is actually after that that can be used within the splice like that
00:22:49
we're going to see some examples of that like we can do exactly the same
00:22:53
types we can prototype and then we can splice uptight into a piece of program
00:23:02
so now what how would you define the market with that so
00:23:07
we're going to retake the same in line that power of long i mean i can't as before
00:23:13
but instead of a implemented directly we're going to say okay have a splice here
00:23:18
and i'm going to compute this expression for x. an
00:23:21
unknown and i'm going to answer disco wherever eyeing lynette
00:23:27
so the user will actually not to see any of those expert types it will only see the line
00:23:34
and the the normal types that you would expect from the user and
00:23:42
but uh before i said that we had to a therapist lies inside of another quote or problem
00:23:48
so in this case we don't really have a code directly visible but we're assuming that by combining were
00:23:55
uh we're called is actually the program where we're in lang this this piece of code
00:24:02
and this is the except for and the only place where you can use just like that is not within another quote
00:24:09
no that's not parallel between the previous implementation and and
00:24:14
and how we would implement this um this x. this power x.
00:24:19
so first we can see that the and try to get ready for bed as so before we
00:24:25
have we had that in mind and which not becomes justin and so before we wanted to know with
00:24:32
to enforce it to be a constant value and i were just saying okay this is somebody that i know right now when
00:24:37
i'm executing this code and on the other hand the the the x. that before we just had it as some normal lose
00:24:46
parameter now we have it as an extra uh as an expert off long which means
00:24:51
that we have some code to refer to it but we don't actually know what's its value
00:24:58
and so now whatever we had the in line if
00:25:04
we're we expected it to partially a evaluate its condition and
00:25:09
then probably the the rim of the one of those branches instead of that we
00:25:14
just have a normal program that will just wrong all uh execute the end equals zero
00:25:20
it could be an older arbitrary a method that the
00:25:24
user defines but now the result will be a coat
00:25:29
which means that we're going to return a piece of code that we're going to start somewhere
00:25:36
and i can see that there's quite a lot of a syntactic overhead additional synthetic overhead for this
00:25:44
but this comes with the uh with the benefit of how a of being able to run arbitrary code
00:25:50
and here we see how to how we can just if our piece of code
00:25:55
in these cases is defining the one act x. and it's good to refer twice to
00:26:01
the value of x. that is defined somewhere else and then we're going to use that to compute the power expert would why and
00:26:09
and number minus two inside of the splice and we're going to take whatever was computed from there i inserted in this piece of code
00:26:20
and
00:26:23
so well tight macros cannot go wrong so we do have some
00:26:28
nice walls ah to to make this type check correctly and the the the basically the unique rule is
00:26:36
for any three variable reference the number of coded scopes on the
00:26:40
number of splice scopes between the reference and its definition must be cool
00:26:45
if we have this then we can ensure that if this program is
00:26:49
well well type whatever we're going to generate will also be well typed
00:26:55
um
00:26:58
so for example here we have a we we defined what the value right
00:27:02
and where is a good inside but you can see that there is for supplies and then according between
00:27:07
the definition and the u. site so we have the equal numbers and we can use it
00:27:13
and the same for a x. and and but in this case we first have a quote and
00:27:17
then we whatever you use x. is we have a splicing between he and the same for and
00:27:30
we can also see that the we have references for example too long and the times
00:27:34
operation another uh operations those are not really free variables because they're known statically in globally
00:27:41
so they don't depend on the current um contacts of this
00:27:43
method so those anything that is globally defined can be accessed
00:27:49
been inside of a court
00:27:54
now what about like bookmarks actually this becomes fairly trivial what because it's basically just
00:28:00
a combination of the special was returned that that we said before i don't um
00:28:07
i'm across somebody for a line at that so basically if we compute some expression we within that that's nice
00:28:14
if it's more uh if it's more precise than x. in this case then we're actually going to
00:28:19
insert something a that is more precise and we're going to use that types at the call psyched
00:28:26
just like with normal in line with the subtype return type
00:28:33
so what if we actually want to inspect inside and see what's the value inside of
00:28:40
of work of some expression let's take this example where we have a a couple are and
00:28:48
we want we want to swap the the elements and this particular implementation if it
00:28:53
receives a reference and it will just called a normal format that on the table but
00:28:58
if we receive it explicitly we'll just for the element and concerted topple directly
00:29:03
here we take this couple by name because in the second case where we swap
00:29:07
the double we don't want to evaluate the first of all in the first place
00:29:12
now actually implement this is quite straightforward because we can just
00:29:17
take this topple that we have as an input and just other much in it with the code as button so here we can see that
00:29:25
we're bottom we're expecting our out a couple of size two in
00:29:29
and we're going to get each of the other a reference which was the elements i we're going
00:29:33
to then construct another topple on we're going to put those elements in but in the reverse order
00:29:39
so one important note here is that this pattern is is fully typed
00:29:47
um and the type of x. one is is statically normal and will
00:29:52
be statically known on the other side when we were constructed there for everything
00:29:56
everything was again three types these has some limitations because we could not
00:30:01
ask uh i am i calling some method called apply without being a subtype
00:30:07
of function or something like that i'm going to look at the other
00:30:12
example we we're basically going to just a user topple ankles up on it
00:30:19
mm so lastly uh i added uh actually we can see that there is an extra parameter called reflection
00:30:27
this is what allows us to look to to decompose a topple uh
00:30:31
i'm going to go in and describe what it actually does entirely later
00:30:35
but for now as long as we just a lotta much on calls we just need to have it but we don't care about what's inside
00:30:43
well for now example uh to the previous example were we were pretty much on the shape of the tree
00:30:50
but sometimes we want to do to get some other properties of the of the
00:30:55
of the expression and semester we take the the power function like we had the the
00:31:02
in the previous version but this one is just the one that
00:31:06
just computes the power and then the power x. goodwill compute the cold
00:31:11
for a power a uh for a knowing and um we're going to use it in our implementation of this expert to that
00:31:21
will receive two expression so we don't statically know any of the values
00:31:25
but we can put too much on boats with this uh a contest
00:31:29
and extractor that will retire a much if the value inside
00:31:35
if that is is the expression is actually a value and we just return is the value
00:31:40
so if we know baldwin as we can just call a drawn to at compile time
00:31:44
the power function and then take that that value that we have computed and create an
00:31:49
expression from it are inserted into a problem if we only know the the um the
00:31:57
the excellent then we can join uh use the power expert to generate the optimal called for uh
00:32:04
and for that that doesn't reference a anymore on if you don't know anything then we can just
00:32:11
quote this the the power function would means that we're going to compute this power function later on it from time
00:32:21
and again we need this reflection and perfection parameter
00:32:29
so so far we we we've seen will bite mark russell now we're going to going to
00:32:35
what is more similar to to um to scott to macros and where
00:32:40
we are going to just use a an i. p. i. directly on trees
00:32:47
to uh really that a deep into all the properties of the of the expression
00:32:53
so first uh
00:32:57
we have this tasty concept we have it as a boat pacify format uh
00:33:03
which is the standard encoding for uh it's gonna treat type trees and these type
00:33:10
a history a estes uh have a source position
00:33:13
they also contain a scholar dot comments it's extended all
00:33:18
be on the other hand we have things to select which is what we use before
00:33:22
a a fast parameters so this is just an interface on top of those trees
00:33:27
that allow us to allows us to uh inspect and construct trees uh
00:33:32
all it also allows us to inspect positions on sky a a dot commands
00:33:38
and it's stop it you just ability of this interface he's given by the stability of the file format
00:33:46
so that's one of the reasons why we do not have the same portability problem us which colour
00:33:53
to my cross because our interface is not with the company itself is with this table five format in
00:34:02
so before i i i showed how to use this contest extractor but now we want to see how we actually implement it
00:34:08
so the implementation here we receive this reflection
00:34:14
which is our a. p. i. on three if um first word
00:34:19
to use it will just wanting pours the contents of this a reflection
00:34:22
which was you'll give us access to all the types of the methods
00:34:26
and everything that is all the logic that we could could do one on trees
00:34:31
so to use that we first at the bottom have an expression and
00:34:35
we will want to concede that means taking an expression on unix positive
00:34:42
and in this particular case because it's an expression it's actually a term which
00:34:46
is also type of tree um if that we're going to work on it
00:34:54
so we can also button much on different internal trees a it in
00:35:02
this case we're going to just uh if it's a little then we're going to take it uh if it's a
00:35:07
block with a anti statements we're just going to ignore the statement and say yeah it's it's an utterance fine um
00:35:15
but note that there is a a cast here and because we think
00:35:20
the value from one and a turn turn doesn't have been from a
00:35:23
the type information as we had the the expression so here we we
00:35:27
use some some some natural from the type system that this will actually succeed
00:35:31
but of course in this case we know it will because we know that we got an expression of that
00:35:36
heat so if it's the if it contains a value it must be of uh uh you have that same t.
00:35:43
mm
00:35:46
so we had we already have some um some quite advanced prototypes
00:35:50
so for one for one there is uh the shape history which users
00:35:56
especially in a is meaning bass and then much as an implicit match it doesn't use
00:36:00
any macros currently uh we're going to experiment to see what happens if we use them
00:36:06
um what else can we do and then the didn't envision potential before
00:36:12
of the topple is actually a simplification of what we actually doing the compiler
00:36:17
uh in our standard library to extend the temples and have
00:36:20
couples of our eighty more than twenty two and we basically their
00:36:25
eyes stop was to have a normal h. least um properties and
00:36:32
for that we just use much size and in line nothing more
00:36:36
and then we use of a few uh optimisation since i've i uh and
00:36:42
we also uh really implement a help for implementing a an all the micro since colour test uh did
00:36:52
well uh yeah it was quite a lot of work i and and then we have a couple of other uh outliers where we
00:37:00
we uh to some string the parameters per my present implemented markers
00:37:05
so there is the f. interpreter that business on the library which
00:37:08
uses the macros to check that uh in the contents of this year that the f. interpreter are it
00:37:14
are correctly formatted and it will not fail deaf the parsing of the formatting at one time um
00:37:22
and we also have an x. m. l. stream double later which uses a micro special and
00:37:28
specialise in line in this case you know the other one that didn't it's only use macros
00:37:33
and and the n. x. m. interpreter is
00:37:35
uh intended to replace the then facsimile charles
00:37:43
for thank you and is there any questions uh
00:37:54
hi
00:37:58
um
00:38:02
uh i see to win the centre
00:38:07
i uh work up
00:38:11
how does this connect with uh if it's rounds gallon me ah f. doesn't really connect um
00:38:20
so we had another all i actually we have another prototype where we we but we didn't use exactly micro
00:38:27
infrastructure but we use a tasty reflect a interface to to to um to take the the t. c. trees
00:38:35
and generated a semantic b. b. that um that uh metal uses
00:38:42
so it's kind of a separate but we can generate one from the other
00:38:48
thanks
00:38:50
um well the the any replacement well sue up
00:38:56
i'm reflection in particular well reflecting all the facts and
00:39:00
time yeah not not right now not with this infrastructure
00:39:17
two questions first one ah how do you raise has some
00:39:21
compilation errors from our methods and micro oh uh yeah um i
00:39:26
don't think that was like that but uh we have a couple
00:39:29
of uh of uh other methods in the compile time a package
00:39:33
a fourteen limit uh not that so if you you there isn't a scholar compile time
00:39:39
ever method but if you call inside of an unlimited and it gets in nine and then that branch is not eliminated
00:39:46
then it will uh uh uh any dinner with the message that you wrote inside
00:39:51
oh okay and i i'm what i'm ah ah sorry
00:39:55
uh and and for uh if we have a quotas places we have a similar but
00:40:01
different a mechanism to also raise exceptions and if we actually easy you'll lose a and
00:40:09
the um effect a. p. i. then we can even go a more precise for example in the
00:40:14
in the string the polluters we could get the error messages for uh some
00:40:18
part of the string and say this part of the string is not correctly formatted
00:40:23
oh okay i i also wanted to ask about the example would much thanks i notice that
00:40:28
you have matched and male type against and it troubles sorry oh yeah which kind of assumed ah
00:40:36
what if i want to match ah uptight exactly trouble
00:40:42
and this way i want to it's um i i didn't want
00:40:46
to accept this type of i'm it's rolled exactly it's herbal or something
00:40:52
uh_huh
00:40:57
i think this was in one of the next slide we just uh this one right oh yes uh
00:41:03
yeah i'm actually not sure uh and how we wouldn't code yeah um martin with
00:41:20
so so one thing you could do is uh you put most the scrutiny x. and type like box
00:41:30
so users would you use box of sex and do pattern matcher guns boxes which rubber
00:41:34
because boxes number it's it's exactly right so that's that's how you would do it i guess
00:41:45
uh_huh
00:41:48
i will be quasi quotes or does ah to the other caught some spices casablanca so
00:41:55
um yeah cause cause and the cause of places are quite a quite different because uh
00:42:02
causes license uh as i show them are just expressions
00:42:05
the quasi quotes were countries because because our uh um
00:42:10
i'm a nice way to uh obstruct over the trees so it's not
00:42:17
currently the plan to actually implement them but it would be possible to to
00:42:21
add it later just as that lay on top of the tree a. p. i.
00:42:25
but because we already had this nice uh my sports
00:42:28
places we usually can do most of the war directly on
00:42:33
that and whenever we have to be switched to the other it's usually not too big so it's so it has not
00:42:40
so for us a bean really necessary to write short called
00:42:47
yeah yeah yeah i'm sure experimental tool or it's it's really yeah sure false at three
00:42:57
it is of it so all the the first when it first features with that type matches on in line are
00:43:03
concrete features the the quotas places would be probably force colour to
00:43:09
one and and the other one uh the and the the the the
00:43:15
the uh reflects a we're going to use it internally at these uh i'm not
00:43:21
sure it would be it would be fully stable battery one but eventually it should be
00:43:28
also part of it because i in this case what
00:43:32
we're actually reflecting is the is the tasty format which
00:43:37
will be stable from we we we we want to ensure that would be stable from two one on words
00:43:43
so from there onwards we should also be able to just stay but have a stable a. p. i. for that
00:43:53
um we will in lining imbue solution to overcome type or a
00:43:58
sure are well you still need class text for actually a a
00:44:03
use we can leverage in line to to to leverage type arranger
00:44:07
uh i i and i actually showed some example to to uh
00:44:12
to then is with the the does a spy or that is present it now uh
00:44:16
uh uh where and if so then i guess if if you have a type parameter
00:44:22
uh i knew great under my method this method will be in line before it's the types
00:44:27
or rate so whenever we are going to specialise will already know the the more precise type information
00:44:34
now we have to discover for no that's not struggle for all the cases sometimes we we we
00:44:39
may need to find the correct it's a coding patterns to achieve all that we wanted to raise or
00:44:46
but uh for the most uh straightforward things it's it's trivial
00:44:54
um ease their rules um so as to when you should use
00:44:57
the line and when you should use macros and the role is uh
00:45:01
started in line is that uh works for your use case then
00:45:05
probably stick with it if you need more power then go to macros
00:45:09
because you you just about uh the the the nine definition is exactly the same
00:45:14
you don't want to choose interface that user will see so you create underlined or have you
00:45:17
you greater method analyse oh i need more than just change implementation to use something more powerful
00:45:27
um what reach what will happen if i created for you to put in a match that um
00:45:36
there are some mechanisms the the the the compiler will uh keep track of recursion and
00:45:42
if you go uh too far it will just tell you all we we we reach this maximum a recursion limit
00:45:48
and if it's actually a should uh i i if you actually
00:45:51
have a really long type uh you may increase that limits uh manually
00:45:59
uh huh thank you talk i am i okay okay terms
00:46:05
fantastic and i'm quite a lot um thank you anyway you mentions
00:46:09
tuesdays intend to the anonymous specific which i didn't have um
00:46:13
i i is there anything that it would be useful for kind
00:46:17
of an external tooling standpoint at this point or is right
00:46:20
now just the first phase of some at more general concepts oh
00:46:24
a tasty what we're already using tasty for the idea for example
00:46:28
so we get a all the information that the the id wants
00:46:31
from the tasty so we compiled on the base the and then they they just love that and also to the
00:46:36
trees the position advise a position it can find where the references are from that and all those kind of things
00:46:41
we also can do a documentation from it because we all have all the documents in there so we are actually
00:46:47
just combining and then there's another thing that will consume the tasty and generate the dock talks meeting they're happy thank you
00:46:59
uh_huh
00:47:05
oh
00:47:06
and so to talk and questions or how it's a inland there if uh represented in tasty
00:47:14
as a completely in latin righty or is it's him as a function or
00:47:19
oh um yeah so so in tasty we we we basically to the the uh
00:47:28
whenever we have uh uh we we keep the whole tree inside of the
00:47:31
of the of the file so whenever we're we just keep the tree we keep
00:47:36
we we mark doesn't line and we we we must have a bit the the body of the nine
00:47:40
methods to make it be in line will easily liable uh then whatever you're going to minute do what
00:47:47
we need to do is just going to taste you read the tasty take that to that is there
00:47:52
on take that tree directly and then the start a constant folding and doing the rest

Share this talk: 


Conference Program

Welcome!
June 11, 2019 · 5:03 p.m.
1574 views
A Tour of Scala 3
Martin Odersky, Professor EPFL, Co-founder Lightbend
June 11, 2019 · 5:15 p.m.
8337 views
A story of unification: from Apache Spark to MLflow
Reynold Xin, Databricks
June 12, 2019 · 9:15 a.m.
1267 views
In Types We Trust
Bill Venners, Artima, Inc
June 12, 2019 · 10:15 a.m.
1569 views
Creating Native iOS and Android Apps in Scala without tears
Zahari Dichev, Bullet.io
June 12, 2019 · 10:16 a.m.
2231 views
Techniques for Teaching Scala
Noel Welsh, Inner Product and Underscore
June 12, 2019 · 10:17 a.m.
1295 views
Future-proofing Scala: the TASTY intermediate representation
Guillaume Martres, student at EPFL
June 12, 2019 · 10:18 a.m.
1156 views
Metals: rich code editing for Scala in VS Code, Vim, Emacs and beyond
Ólafur Páll Geirsson, Scala Center
June 12, 2019 · 11:15 a.m.
4695 views
Akka Streams to the Extreme
Heiko Seeberger, independent consultant
June 12, 2019 · 11:16 a.m.
1552 views
Scala First: Lessons from 3 student generations
Bjorn Regnell, Lund Univ., Sweden.
June 12, 2019 · 11:17 a.m.
577 views
Cellular Automata: How to become an artist with a few lines
Maciej Gorywoda, Wire, Berlin
June 12, 2019 · 11:18 a.m.
386 views
Why Netflix ❤'s Scala for Machine Learning
Jeremy Smith & Aish, Netflix
June 12, 2019 · 12:15 p.m.
5026 views
Massively Parallel Distributed Scala Compilation... And You!
Stu Hood, Twitter
June 12, 2019 · 12:16 p.m.
958 views
Polymorphism in Scala
Petra Bierleutgeb
June 12, 2019 · 12:17 p.m.
1113 views
sbt core concepts
Eugene Yokota, Scala Team at Lightbend
June 12, 2019 · 12:18 p.m.
1655 views
Double your performance: Scala's missing optimizing compiler
Li Haoyi, author Ammonite, Mill, FastParse, uPickle, and many more.
June 12, 2019 · 2:30 p.m.
837 views
Making Our Future Better
Viktor Klang, Lightbend
June 12, 2019 · 2:31 p.m.
1682 views
Testing in the postapocalyptic future
Daniel Westheide, INNOQ
June 12, 2019 · 2:32 p.m.
498 views
Context Buddy: the tool that knows your code better than you
Krzysztof Romanowski, sphere.it conference
June 12, 2019 · 2:33 p.m.
393 views
The Shape(less) of Type Class Derivation in Scala 3
Miles Sabin, Underscore Consulting
June 12, 2019 · 3:30 p.m.
2321 views
Refactor all the things!
Daniela Sfregola, organizer of the London Scala User Group meetup
June 12, 2019 · 3:31 p.m.
514 views
Integrating Developer Experiences - Build Server Protocol
Justin Kaeser, IntelliJ Scala
June 12, 2019 · 3:32 p.m.
551 views
Managing an Akka Cluster on Kubernetes
Markus Jura, MOIA
June 12, 2019 · 3:33 p.m.
735 views
Serverless Scala - Functions as SuperDuperMicroServices
Josh Suereth, Donna Malayeri & James Ward, Author of Scala In Depth; Google ; Google
June 12, 2019 · 4:45 p.m.
936 views
How are we going to migrate to Scala 3.0, aka Dotty?
Lukas Rytz, Lightbend
June 12, 2019 · 4:46 p.m.
709 views
Concurrent programming in 2019: Akka, Monix or ZIO?
Adam Warski, co-founders of SoftwareMill
June 12, 2019 · 4:47 p.m.
1974 views
ScalaJS and Typescript: an unlikely romance
Jeremy Hughes, Lightbend
June 12, 2019 · 4:48 p.m.
1377 views
Pure Functional Database Programming‚ without JDBC
Rob Norris
June 12, 2019 · 5:45 p.m.
6374 views
Why you need to be reviewing open source code
Gris Cuevas Zambrano & Holden Karau, Google Cloud;
June 12, 2019 · 5:46 p.m.
484 views
Develop seamless web services with Mu
Oli Makhasoeva, 47 Degrees
June 12, 2019 · 5:47 p.m.
785 views
Implementing the Scala 2.13 collections
Stefan Zeiger, Lightbend
June 12, 2019 · 5:48 p.m.
810 views
Introduction to day 2
June 13, 2019 · 9:10 a.m.
250 views
Sustaining open source digital infrastructure
Bogdan Vasilescu, Assistant Professor at Carnegie Mellon University's School of Computer Science, USA
June 13, 2019 · 9:16 a.m.
374 views
Building a Better Scala Community
Kelley Robinson, Developer Evangelist at Twilio
June 13, 2019 · 10:15 a.m.
245 views
Run Scala Faster with GraalVM on any Platform
Vojin Jovanovic, Oracle
June 13, 2019 · 10:16 a.m.
1340 views
ScalaClean - full program static analysis at scale
Rory Graves
June 13, 2019 · 10:17 a.m.
463 views
Flare & Lantern: Accelerators for Spark and Deep Learning
Tiark Rompf, Assistant Professor at Purdue University
June 13, 2019 · 10:18 a.m.
380 views
Metaprogramming in Dotty
Nicolas Stucki, Ph.D. student at LAMP
June 13, 2019 · 11:15 a.m.
1250 views
Fast, Simple Concurrency with Scala Native
Richard Whaling, data engineer based in Chicago
June 13, 2019 · 11:16 a.m.
624 views
Pick your number type with Spire
Denis Rosset, postdoctoral researcher at Perimeter Institute
June 13, 2019 · 11:17 a.m.
245 views
Scala.js and WebAssembly, a tale of the dangers of the sea
Sébastien Doeraene, Executive director of the Scala Center
June 13, 2019 · 11:18 a.m.
661 views
Performance tuning Twitter services with Graal and ML
Chris Thalinger, Twitter
June 13, 2019 · 12:15 p.m.
2003 views
Supporting the Scala Ecosystem: Stories from the Line
Justin Pihony, Lightbend
June 13, 2019 · 12:16 p.m.
163 views
Compiling to preserve our privacy
Manohar Jonnalagedda and Jakob Odersky, Inpher
June 13, 2019 · 12:17 p.m.
301 views
Building Scala with Bazel
Natan Silnitsky, wix.com
June 13, 2019 · 12:18 p.m.
565 views
244 views
Asynchronous streams in direct style with and without macros
Philipp Haller, KTH Royal Institute of Technology in Stockholm
June 13, 2019 · 3:45 p.m.
304 views
Interactive Computing with Jupyter and Almond
Sören Brunk, USU Software AG
June 13, 2019 · 3:46 p.m.
681 views
Scala best practices I wish someone'd told me about
Nicolas Rinaudo, CTO of Besedo
June 13, 2019 · 3:47 p.m.
2702 views
High performance Privacy By Design using Matryoshka & Spark
Wiem Zine El Abidine and Olivier Girardot, Scala Backend Developer at MOIA / co-founder of Lateral Thoughts
June 13, 2019 · 3:48 p.m.
753 views
Immutable Sequential Maps – Keeping order while hashed
Odd Möller
June 13, 2019 · 4:45 p.m.
276 views
All the fancy things flexible dependency management can do
Alexandre Archambault, engineer at the Scala Center
June 13, 2019 · 4:46 p.m.
389 views
ScalaWebTest - integration testing made easy
Dani Rey, Unic AG
June 13, 2019 · 4:47 p.m.
468 views
Mellite: An Integrated Development Environment for Sound
Hanns Holger Rutz, Institute of Electronic Music and Acoustics (IEM), Graz
June 13, 2019 · 4:48 p.m.
213 views
Closing panel
Panel
June 13, 2019 · 5:54 p.m.
400 views