Why is に used instead of の? 「ハワイからおみやげにマカダミア•ナッツを買って来る」


> **(A)** ハワイからおみやげにマカダミア•ナッツを買って来る
>

>> I'll buy you guys a gift of macadamia nuts in Hawaii

> **(B)** ハワイからマカダミア•ナッツのおみやげを買って来る

I suppose に here indicates the purpose of the action like in the following:

> あなたはテレビゲームにお金を使いすぎます

If that's the case, would **B** sound unnatural because the noun modifier is
too long?

From the same book, の is being used instead in another example, but the noun
modifier is shorter:

> 田中さんのうちへ行く時、チーズのおみやげを持って行こう。




That に is a role/function marker like _as_ in English. See the following
questions:

  * [に to indicate the role you want something to play?](https://japanese.stackexchange.com/q/65432/5010)
  * [grammar of 前の誕生日プレゼントにもらった彼女の絵](https://japanese.stackexchange.com/q/73351/5010)
  * [Meaning of にと思って in a sentence](https://japanese.stackexchange.com/q/55453/5010)

マカダミアナッツのおみやげを買う is not wrong, but it's more natural to use おみやげに. の in ～のおみやげ
is more commonly used as a possession marker rather than an apposition marker
(e.g., 彼のお土産 is "his gift" or "gift for him"). If you want to use an
[appositive の](https://japanese.stackexchange.com/a/40896/5010),
おみやげのマカデミアナッツを買う sounds better (although it's still less common than おみやげに). I
don't think the length of マカデミアナッツ matters here.




That に is a role/function marker like _as_ in English. See the following
questions:

  * [に to indicate the role you want something to play?](https://japanese.stackexchange.com/q/65432/5010)
  * [grammar of 前の誕生日プレゼントにもらった彼女の絵](https://japanese.stackexchange.com/q/73351/5010)
  * [Meaning of にと思って in a sentence](https://japanese.stackexchange.com/q/55453/5010)

マカダミアナッツのおみやげを買う is not wrong, but it's more natural to use おみやげに. の in ～のおみやげ
is more commonly used as a possession marker rather than an apposition marker
(e.g., 彼のお土産 is "his gift" or "gift for him"). If you want to use an
[appositive の](https://japanese.stackexchange.com/a/40896/5010),
おみやげのマカデミアナッツを買う sounds better (although it's still less common than おみやげに). I
don't think the length of マカデミアナッツ matters here.

