Multiline method definition in Tonel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Multiline method definition in Tonel

Mariano Martinez Peck
Hi guys, 

I was reading the Tonel spec here [1] but it is not clear to me the case of the multiline method definitions. Are those allowed or not?  Say I have a method like this:

testWith: arg1 
     with: arg2 
     with: arg3

^ 42

Is that valid as Tonel format? Or tonel expects to have method definition in a one liner like:

testWith: arg1 with: arg2 with: arg3

^ 42
 

Thanks in advance, 
 

Reply | Threaded
Open this post in threaded view
|

Re: Multiline method definition in Tonel

Peter Uhnak
That's just whitespace... or more specifically any of these are fine (TonelParser>>extractSelector:)

```
separators := { 
Character space. 
Character tab. 
Character lf. 
Character newPage. 
Character cr. 
$: "not me though"}.
```

You can also try to parse it directly and see the result:

```
def := 'Class {
#name : #Whatever,
#superclass : #Object,
#category : ''Wherever''
}

{ #category : #protocol }
Whatever >> testWith: arg1 
with: arg2
with: arg3 [
^ 42
]
'.
TonelParser parseStream: def readStream.
```

Note that exporting it will result in a "normalized" format, so if you keep it in git you will see a change (this also applies to the ordering of methods and some optional stuff)

Peter

On Fri, Dec 7, 2018 at 5:57 PM Mariano Martinez Peck <[hidden email]> wrote:
Hi guys, 

I was reading the Tonel spec here [1] but it is not clear to me the case of the multiline method definitions. Are those allowed or not?  Say I have a method like this:

testWith: arg1 
     with: arg2 
     with: arg3

^ 42

Is that valid as Tonel format? Or tonel expects to have method definition in a one liner like:

testWith: arg1 with: arg2 with: arg3

^ 42
 

Thanks in advance, 
 

Reply | Threaded
Open this post in threaded view
|

Re: Multiline method definition in Tonel

Mariano Martinez Peck


On Sun, Dec 9, 2018 at 6:28 PM Peter Uhnak <[hidden email]> wrote:
That's just whitespace... or more specifically any of these are fine (TonelParser>>extractSelector:)

```
separators := { 
Character space. 
Character tab. 
Character lf. 
Character newPage. 
Character cr. 
$: "not me though"}.
```

You can also try to parse it directly and see the result:

```
def := 'Class {
#name : #Whatever,
#superclass : #Object,
#category : ''Wherever''
}

{ #category : #protocol }
Whatever >> testWith: arg1 
with: arg2
with: arg3 [
^ 42
]
'.
TonelParser parseStream: def readStream.
```


Thanks Peter!  I was afraid that TonelParser would break if tried to parse multiline method declarations. 
 
Note that exporting it will result in a "normalized" format, so if you keep it in git you will see a change (this also applies to the ordering of methods and some optional stuff)


OK. Thanks for letting me know. And for "normalized" you mean a classical oneliner right?

Thanks!
 

Peter

On Fri, Dec 7, 2018 at 5:57 PM Mariano Martinez Peck <[hidden email]> wrote:
Hi guys, 

I was reading the Tonel spec here [1] but it is not clear to me the case of the multiline method definitions. Are those allowed or not?  Say I have a method like this:

testWith: arg1 
     with: arg2 
     with: arg3

^ 42

Is that valid as Tonel format? Or tonel expects to have method definition in a one liner like:

testWith: arg1 with: arg2 with: arg3

^ 42
 

Thanks in advance, 
 



--
Reply | Threaded
Open this post in threaded view
|

Re: Multiline method definition in Tonel

Guillermo Polito
Usually Esteban was picky to be able to export and import methods maintaining the original indentation and formatting ^^.

On Mon, Dec 10, 2018 at 9:03 PM Mariano Martinez Peck <[hidden email]> wrote:


On Sun, Dec 9, 2018 at 6:28 PM Peter Uhnak <[hidden email]> wrote:
That's just whitespace... or more specifically any of these are fine (TonelParser>>extractSelector:)

```
separators := { 
Character space. 
Character tab. 
Character lf. 
Character newPage. 
Character cr. 
$: "not me though"}.
```

You can also try to parse it directly and see the result:

```
def := 'Class {
#name : #Whatever,
#superclass : #Object,
#category : ''Wherever''
}

{ #category : #protocol }
Whatever >> testWith: arg1 
with: arg2
with: arg3 [
^ 42
]
'.
TonelParser parseStream: def readStream.
```


Thanks Peter!  I was afraid that TonelParser would break if tried to parse multiline method declarations. 
 
Note that exporting it will result in a "normalized" format, so if you keep it in git you will see a change (this also applies to the ordering of methods and some optional stuff)


OK. Thanks for letting me know. And for "normalized" you mean a classical oneliner right?

Thanks!
 

Peter

On Fri, Dec 7, 2018 at 5:57 PM Mariano Martinez Peck <[hidden email]> wrote:
Hi guys, 

I was reading the Tonel spec here [1] but it is not clear to me the case of the multiline method definitions. Are those allowed or not?  Say I have a method like this:

testWith: arg1 
     with: arg2 
     with: arg3

^ 42

Is that valid as Tonel format? Or tonel expects to have method definition in a one liner like:

testWith: arg1 with: arg2 with: arg3

^ 42
 

Thanks in advance, 
 



--


--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - http://www.cnrs.fr


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: Multiline method definition in Tonel

EstebanLM
Yes, it should preserve the format. 
If not, there is bug :)

Esteban

On 12 Dec 2018, at 15:59, Guillermo Polito <[hidden email]> wrote:

Usually Esteban was picky to be able to export and import methods maintaining the original indentation and formatting ^^.

On Mon, Dec 10, 2018 at 9:03 PM Mariano Martinez Peck <[hidden email]> wrote:


On Sun, Dec 9, 2018 at 6:28 PM Peter Uhnak <[hidden email]> wrote:
That's just whitespace... or more specifically any of these are fine (TonelParser>>extractSelector:)

```
separators := { 
Character space. 
Character tab. 
Character lf. 
Character newPage. 
Character cr. 
$: "not me though"}.
```

You can also try to parse it directly and see the result:

```
def := 'Class {
#name : #Whatever,
#superclass : #Object,
#category : ''Wherever''
}

{ #category : #protocol }
Whatever >> testWith: arg1 
with: arg2
with: arg3 [
^ 42
]
'.
TonelParser parseStream: def readStream.
```


Thanks Peter!  I was afraid that TonelParser would break if tried to parse multiline method declarations. 
 
Note that exporting it will result in a "normalized" format, so if you keep it in git you will see a change (this also applies to the ordering of methods and some optional stuff)


OK. Thanks for letting me know. And for "normalized" you mean a classical oneliner right?

Thanks!
 

Peter

On Fri, Dec 7, 2018 at 5:57 PM Mariano Martinez Peck <[hidden email]> wrote:
Hi guys, 

I was reading the Tonel spec here [1] but it is not clear to me the case of the multiline method definitions. Are those allowed or not?  Say I have a method like this:

testWith: arg1 
     with: arg2 
     with: arg3

^ 42

Is that valid as Tonel format? Or tonel expects to have method definition in a one liner like:

testWith: arg1 with: arg2 with: arg3

^ 42
 

Thanks in advance, 
 



--


--
   
Guille Polito
Research Engineer


Centre de Recherche en Informatique, Signal et Automatique de Lille
CRIStAL - UMR 9189
French National Center for Scientific Research - http://www.cnrs.fr

Phone: +33 06 52 70 66 13