[cpl] [Tema1] Rolul IF / WHILE
Raluca Grigoras
ralucav at gmail.com
Sat Oct 31 19:01:30 EET 2015
Dpdv sintactic constructia ar fi corecta.
Raluca
> On Oct 31, 2015, at 6:38 PM, Cosmin - Ioan PETRI?OR via cpl <cpl at cursuri.cs.pub.ro> wrote:
>
> Salutare,
>
> Ok, dar problema mea este de natura sintactica si nu semantica. Sa inteleg ca si din punct de vedere sintactic o constructie x = 2 + while ... ar fi gresita? As I was saying before, in manual sunt tratate identic cele doua statement-uri, cel putin sintactic vorbind.
>
> Cosmin
>
>
> From: Raluca Grigoras <ralucav at gmail.com>
> Sent: Saturday, October 31, 2015 6:34 PM
> To: Cosmin - Ioan PETRI?OR; Compilatoare
> Subject: Re: [cpl] [Tema1] Rolul IF / WHILE
>
> Salut,
>
> Tipul unei expresii IF este dat de tipul ultimei instructiuni/expresii din cele doua ramuri. Prin urmare o expresie IF poate avea tipul Int.
> Tipul unei expresii WHILE este mereu Void, in cazul in care ar aparea intr-o expresie de genul var x = 2 + while …, ar fi o eroare semantica, pentru ca tipul Void nu poate fi convertit la Int.
>
> Raluca
>
>
>
>> On Oct 31, 2015, at 6:23 PM, Cosmin - Ioan PETRI?OR via cpl <cpl at cursuri.cs.pub.ro <mailto:cpl at cursuri.cs.pub.ro>> wrote:
>>
>> Hello,
>>
>> Am vazut in manual, pag. 11, ca IF si WHILE sunt considerati operatori (mai mult decat atat, de acelasi rang). Fair enough.
>>
>> Problema este ca in teste am observat expresii de genul: var = 2 + if ... then ... else ... end; and I'm ok with that. Dar ce nu am reusit sa deslusesc este daca si WHILE are acelasi statut, pentru ca am vazut doar blocuri WHILE independente.
>>
>> So here comes my question: Putem folosi constructii WHILE in cadrul expresiilor, sau trebuie tratat separat de IF?
>>
>> Numai bine,
>> Cosmin
>> _______________________________________________
>> cpl mailing list
>> cpl at cursuri.cs.pub.ro <mailto:cpl at cursuri.cs.pub.ro>
>> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/cpl <http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/cpl>
> _______________________________________________
> cpl mailing list
> cpl at cursuri.cs.pub.ro <mailto:cpl at cursuri.cs.pub.ro>
> http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/cpl <http://cursuri.cs.pub.ro/cgi-bin/mailman/listinfo/cpl>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://cursuri.cs.pub.ro/pipermail/cpl/attachments/20151031/2a1239ba/attachment-0001.html>
More information about the cpl
mailing list